mindoodb 0.0.86 → 0.0.88
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/README-server.md +5 -2
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts.map +1 -1
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js +2 -1
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js.map +1 -1
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts +151 -12
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts.map +1 -1
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js +340 -24
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js.map +1 -1
- package/dist/browser/index.mjs +14 -0
- package/dist/core/BaseMindooDB.d.ts +67 -9
- package/dist/core/BaseMindooDB.d.ts.map +1 -1
- package/dist/core/BaseMindooDB.js +261 -12
- package/dist/core/BaseMindooDB.js.map +1 -1
- package/dist/core/BaseMindooTenant.d.ts +29 -0
- package/dist/core/BaseMindooTenant.d.ts.map +1 -1
- package/dist/core/BaseMindooTenant.js +111 -6
- package/dist/core/BaseMindooTenant.js.map +1 -1
- package/dist/core/BaseMindooTenantDirectory.d.ts +93 -0
- package/dist/core/BaseMindooTenantDirectory.d.ts.map +1 -1
- package/dist/core/BaseMindooTenantDirectory.js +292 -0
- package/dist/core/BaseMindooTenantDirectory.js.map +1 -1
- package/dist/core/BaseMindooTenantFactory.d.ts.map +1 -1
- package/dist/core/BaseMindooTenantFactory.js +2 -1
- package/dist/core/BaseMindooTenantFactory.js.map +1 -1
- package/dist/core/MindooDBServerAdmin.d.ts.map +1 -1
- package/dist/core/MindooDBServerAdmin.js +2 -1
- package/dist/core/MindooDBServerAdmin.js.map +1 -1
- package/dist/core/accesscontrol/directoryProjection.d.ts.map +1 -1
- package/dist/core/accesscontrol/directoryProjection.js +19 -0
- package/dist/core/accesscontrol/directoryProjection.js.map +1 -1
- package/dist/core/accesscontrol/evaluate.d.ts +14 -0
- package/dist/core/accesscontrol/evaluate.d.ts.map +1 -1
- package/dist/core/accesscontrol/evaluate.js +42 -1
- package/dist/core/accesscontrol/evaluate.js.map +1 -1
- package/dist/core/accesscontrol/types.d.ts +88 -4
- package/dist/core/accesscontrol/types.d.ts.map +1 -1
- package/dist/core/accesscontrol/types.js +114 -1
- package/dist/core/accesscontrol/types.js.map +1 -1
- package/dist/core/appendonlystores/network/AuthenticationService.d.ts +6 -0
- package/dist/core/appendonlystores/network/AuthenticationService.d.ts.map +1 -1
- package/dist/core/appendonlystores/network/AuthenticationService.js +8 -7
- package/dist/core/appendonlystores/network/AuthenticationService.js.map +1 -1
- package/dist/core/appendonlystores/network/IrohNetworkTransport.d.ts.map +1 -1
- package/dist/core/appendonlystores/network/IrohNetworkTransport.js +12 -0
- package/dist/core/appendonlystores/network/IrohNetworkTransport.js.map +1 -1
- package/dist/core/appendonlystores/rpc/RpcContentAddressedStore.d.ts +6 -0
- package/dist/core/appendonlystores/rpc/RpcContentAddressedStore.d.ts.map +1 -1
- package/dist/core/appendonlystores/rpc/RpcContentAddressedStore.js +20 -1
- package/dist/core/appendonlystores/rpc/RpcContentAddressedStore.js.map +1 -1
- package/dist/core/appendonlystores/sqlite/SqliteContentAddressedStore.d.ts +7 -0
- package/dist/core/appendonlystores/sqlite/SqliteContentAddressedStore.d.ts.map +1 -1
- package/dist/core/appendonlystores/sqlite/SqliteContentAddressedStore.js +18 -0
- package/dist/core/appendonlystores/sqlite/SqliteContentAddressedStore.js.map +1 -1
- package/dist/core/appendonlystores/syncStores.d.ts.map +1 -1
- package/dist/core/appendonlystores/syncStores.js +25 -5
- package/dist/core/appendonlystores/syncStores.js.map +1 -1
- package/dist/core/appendonlystores/types.d.ts +7 -1
- package/dist/core/appendonlystores/types.d.ts.map +1 -1
- package/dist/core/appendonlystores/types.js +1 -0
- package/dist/core/appendonlystores/types.js.map +1 -1
- package/dist/core/builtinDbInvariants.d.ts +49 -0
- package/dist/core/builtinDbInvariants.d.ts.map +1 -1
- package/dist/core/builtinDbInvariants.js +86 -1
- package/dist/core/builtinDbInvariants.js.map +1 -1
- package/dist/core/crypto/AuthChallenge.d.ts +68 -0
- package/dist/core/crypto/AuthChallenge.d.ts.map +1 -0
- package/dist/core/crypto/AuthChallenge.js +118 -0
- package/dist/core/crypto/AuthChallenge.js.map +1 -0
- package/dist/core/crypto/DomainStatement.d.ts +5 -3
- package/dist/core/crypto/DomainStatement.d.ts.map +1 -1
- package/dist/core/crypto/DomainStatement.js +5 -3
- package/dist/core/crypto/DomainStatement.js.map +1 -1
- package/dist/core/crypto/encryptedFields.d.ts +11 -0
- package/dist/core/crypto/encryptedFields.d.ts.map +1 -1
- package/dist/core/crypto/encryptedFields.js +18 -0
- package/dist/core/crypto/encryptedFields.js.map +1 -1
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +17 -6
- package/dist/core/index.js.map +1 -1
- package/dist/core/query/executeQuery.d.ts.map +1 -1
- package/dist/core/query/executeQuery.js +5 -1
- package/dist/core/query/executeQuery.js.map +1 -1
- package/dist/core/query/executeQueryInclude.d.ts.map +1 -1
- package/dist/core/query/executeQueryInclude.js +2 -0
- package/dist/core/query/executeQueryInclude.js.map +1 -1
- package/dist/core/query/queryView.d.ts.map +1 -1
- package/dist/core/query/queryView.js +5 -1
- package/dist/core/query/queryView.js.map +1 -1
- package/dist/core/types.d.ts +143 -8
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/userkeys/index.d.ts +1 -0
- package/dist/core/userkeys/index.d.ts.map +1 -1
- package/dist/core/userkeys/index.js +5 -1
- package/dist/core/userkeys/index.js.map +1 -1
- package/dist/core/userkeys/sealedValues.d.ts +54 -0
- package/dist/core/userkeys/sealedValues.d.ts.map +1 -0
- package/dist/core/userkeys/sealedValues.js +67 -0
- package/dist/core/userkeys/sealedValues.js.map +1 -0
- package/dist/core/utils/dynamicImportInterop.d.ts +10 -0
- package/dist/core/utils/dynamicImportInterop.d.ts.map +1 -0
- package/dist/core/utils/dynamicImportInterop.js +22 -0
- package/dist/core/utils/dynamicImportInterop.js.map +1 -0
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts.map +1 -1
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js +7 -0
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js.map +1 -1
- package/dist/server/DeviceDiscoveryService.d.ts.map +1 -1
- package/dist/server/DeviceDiscoveryService.js +3 -4
- package/dist/server/DeviceDiscoveryService.js.map +1 -1
- package/dist/server/SystemAdminAuth.d.ts.map +1 -1
- package/dist/server/SystemAdminAuth.js +3 -4
- package/dist/server/SystemAdminAuth.js.map +1 -1
- package/dist/server/TenantManager.d.ts +36 -0
- package/dist/server/TenantManager.d.ts.map +1 -1
- package/dist/server/TenantManager.js +234 -4
- package/dist/server/TenantManager.js.map +1 -1
- package/dist/server/http/MindooDBServerCore.d.ts.map +1 -1
- package/dist/server/http/MindooDBServerCore.js +7 -0
- package/dist/server/http/MindooDBServerCore.js.map +1 -1
- package/dist/server/peer/PeerAuthService.d.ts.map +1 -1
- package/dist/server/peer/PeerAuthService.js +3 -4
- package/dist/server/peer/PeerAuthService.js.map +1 -1
- package/dist/server/peer/PeerReplicator.d.ts.map +1 -1
- package/dist/server/peer/PeerReplicator.js +2 -1
- package/dist/server/peer/PeerReplicator.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,8 @@ import { KeyBag } from "./keys/KeyBag";
|
|
|
5
5
|
import { UserKeyManager } from "./userkeys/UserKeyManager";
|
|
6
6
|
import type { PendingUserKeyDevice, UserKeyEnrollmentStatus } from "./userkeys/types";
|
|
7
7
|
import type { EntryRecipients } from "./userkeys/sealedTypes";
|
|
8
|
+
import type { RecipientOptions, RecipientSpec } from "./userkeys/sealedTypes";
|
|
9
|
+
import { type SealedValue } from "./userkeys/sealedValues";
|
|
8
10
|
import { MindooDocSigner } from "./crypto/MindooDocSigner";
|
|
9
11
|
import { Logger } from "./logging";
|
|
10
12
|
import { type LocalCacheStore } from "./cache/LocalCacheStore";
|
|
@@ -170,6 +172,19 @@ export declare class BaseMindooTenant implements MindooTenant {
|
|
|
170
172
|
rememberSealedGenerations(keyId: string, generations: Uint8Array[]): void;
|
|
171
173
|
getSealedGenerations(keyId: string): Uint8Array[];
|
|
172
174
|
ingestSealedRecipients(keyId: string, recipients: EntryRecipients): Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* Seals `value` to people (their published User-Keys) or devices, for a
|
|
177
|
+
* field of a document encrypted with another key (see {@link SealedValue}).
|
|
178
|
+
* `options` as for sealed documents: the current user is included unless
|
|
179
|
+
* `includeSelf` is false; `strict` fails on a recipient without a published
|
|
180
|
+
* User-Key instead of leaving them out.
|
|
181
|
+
*/
|
|
182
|
+
sealValue(value: Uint8Array, recipients: RecipientSpec[], options?: RecipientOptions): Promise<SealedValue>;
|
|
183
|
+
/**
|
|
184
|
+
* Opens a {@link SealedValue} with this identity's User-Key (any generation)
|
|
185
|
+
* or device key. Returns null when it is not sealed to them.
|
|
186
|
+
*/
|
|
187
|
+
openSealedValue(sealed: SealedValue): Promise<Uint8Array | null>;
|
|
173
188
|
ingestSealedFromEntries(keyId: string, entries: Array<{
|
|
174
189
|
recipients?: EntryRecipients;
|
|
175
190
|
createdAt: number;
|
|
@@ -411,6 +426,20 @@ export declare class BaseMindooTenant implements MindooTenant {
|
|
|
411
426
|
* and the full ticket so the same handshake runs over Iroh RPC.
|
|
412
427
|
*/
|
|
413
428
|
publishToServer(serverUrl: string, options?: PublishToServerOptions): Promise<void>;
|
|
429
|
+
/**
|
|
430
|
+
* Adds the server the tenant was just published to as a trusted witness
|
|
431
|
+
* (docs/accesscontrol.md §6.4). The server stamps every entry it accepts;
|
|
432
|
+
* without this directory document those receipts come from an untrusted key,
|
|
433
|
+
* and once access control is switched on every stamped entry is quarantined.
|
|
434
|
+
* Trust is evaluated at the receipt's `receivedAt`, so it has to be in place
|
|
435
|
+
* before the first entry is pushed: that is why the publish flow writes it.
|
|
436
|
+
*
|
|
437
|
+
* Needs the administration private key: {@link PublishToServerOptions.adminSigningKey}
|
|
438
|
+
* and `adminPassword`, or a `systemAdminUser` that is the tenant admin (demo
|
|
439
|
+
* servers with open tenant creation). Without it a warning is logged and the
|
|
440
|
+
* admin has to call `MindooTenantDirectory.addTrustedWitness()` before pushing.
|
|
441
|
+
*/
|
|
442
|
+
private trustServerAsWitness;
|
|
414
443
|
private resolveIrohDial;
|
|
415
444
|
private publishToIrohServer;
|
|
416
445
|
private authenticateAsSystemAdminOverIroh;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseMindooTenant.d.ts","sourceRoot":"","sources":["../../src/core/BaseMindooTenant.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,qBAAqB,EACrB,4BAA4B,EAE5B,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,YAAY,EAGZ,yBAAyB,EACzB,sBAAsB,EAEtB,sBAAsB,EAIvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAkB,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseMindooTenant.d.ts","sourceRoot":"","sources":["../../src/core/BaseMindooTenant.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,qBAAqB,EACrB,4BAA4B,EAE5B,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,YAAY,EAGZ,yBAAyB,EACzB,sBAAsB,EAEtB,sBAAsB,EAIvB,MAAM,SAAS,CAAC;AACjB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GAClE,OAAO,CAAC,MAAM,CAAC;IAwBlB,8FAA8F;IACxF,mBAAmB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ7D;;;;;OAKG;IACG,sBAAsB,CAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,KAAK,CAAC;QAAE,KAAK,EAAE,UAAU,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAchF;;;;;;;;OAQG;IACG,wCAAwC,CAC5C,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,MAAM,CAAC;IAiClB,oEAAoE;IACpE,OAAO,CAAC,4BAA4B;IAIpC;;;;;;OAMG;cACa,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA8B7E;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,qCAAqC,IAAI,OAAO;IAI1D;;;;;;;;;;OAUG;IACG,wBAAwB,CAC5B,OAAO,EAAE,UAAU,EACnB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,UAAU,CAAC;IAgEtB;;;;;;;OAOG;IACG,wBAAwB,CAC5B,gBAAgB,EAAE,UAAU,EAC5B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,UAAU,CAAC;CA2DvB"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BaseMindooTenant = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
const userid_1 = require("./userid");
|
|
6
|
+
const AuthChallenge_1 = require("./crypto/AuthChallenge");
|
|
6
7
|
const BaseMindooDB_1 = require("./BaseMindooDB");
|
|
7
8
|
const BaseMindooTenantDirectory_1 = require("./BaseMindooTenantDirectory");
|
|
8
9
|
const grantKeys_1 = require("./accesscontrol/grantKeys");
|
|
@@ -11,6 +12,7 @@ const types_2 = require("./userkeys/types");
|
|
|
11
12
|
const validateUserKeyDocument_1 = require("./userkeys/validateUserKeyDocument");
|
|
12
13
|
const sealedTypes_1 = require("./userkeys/sealedTypes");
|
|
13
14
|
const recipients_1 = require("./userkeys/recipients");
|
|
15
|
+
const sealedValues_1 = require("./userkeys/sealedValues");
|
|
14
16
|
const sealedCrypto_1 = require("./userkeys/sealedCrypto");
|
|
15
17
|
const MindooDocSigner_1 = require("./crypto/MindooDocSigner");
|
|
16
18
|
const RSAEncryption_1 = require("./crypto/RSAEncryption");
|
|
@@ -33,6 +35,7 @@ const CacheManager_1 = require("./cache/CacheManager");
|
|
|
33
35
|
const databaseIdValidation_1 = require("./databaseIdValidation");
|
|
34
36
|
const BackgroundTaskTracker_1 = require("./BackgroundTaskTracker");
|
|
35
37
|
const singleFlight_1 = require("./utils/singleFlight");
|
|
38
|
+
const dynamicImportInterop_1 = require("./utils/dynamicImportInterop");
|
|
36
39
|
/**
|
|
37
40
|
* BaseMindooTenant is a platform-agnostic implementation of MindooTenant
|
|
38
41
|
* that works in both browser and server environments.
|
|
@@ -402,6 +405,41 @@ class BaseMindooTenant {
|
|
|
402
405
|
});
|
|
403
406
|
this.sealedGenerations.delete(keyId);
|
|
404
407
|
}
|
|
408
|
+
/**
|
|
409
|
+
* Seals `value` to people (their published User-Keys) or devices, for a
|
|
410
|
+
* field of a document encrypted with another key (see {@link SealedValue}).
|
|
411
|
+
* `options` as for sealed documents: the current user is included unless
|
|
412
|
+
* `includeSelf` is false; `strict` fails on a recipient without a published
|
|
413
|
+
* User-Key instead of leaving them out.
|
|
414
|
+
*/
|
|
415
|
+
async sealValue(value, recipients, options) {
|
|
416
|
+
const resolved = await (0, recipients_1.resolveRecipientSpecs)({
|
|
417
|
+
tenant: this,
|
|
418
|
+
specs: recipients,
|
|
419
|
+
options,
|
|
420
|
+
addedBy: this.currentUser.userSigningKeyPair.publicKey,
|
|
421
|
+
now: (0, timeSource_1.semanticNow)(),
|
|
422
|
+
});
|
|
423
|
+
const { contentKey, ciphertext } = await (0, sealedValues_1.encryptSealedValueContent)(this.cryptoAdapter, value);
|
|
424
|
+
const sealed = await (0, recipients_1.sealToTargets)({ tenant: this, generations: [contentKey], targets: resolved.targets, epoch: 1 });
|
|
425
|
+
return {
|
|
426
|
+
v: sealedValues_1.SEALED_VALUE_VERSION,
|
|
427
|
+
ciphertext,
|
|
428
|
+
recipients: sealed,
|
|
429
|
+
to: resolved.targets.map((target) => ({ kind: target.kind, keyFingerprint: target.keyFingerprint })),
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Opens a {@link SealedValue} with this identity's User-Key (any generation)
|
|
434
|
+
* or device key. Returns null when it is not sealed to them.
|
|
435
|
+
*/
|
|
436
|
+
async openSealedValue(sealed) {
|
|
437
|
+
const privateKeys = [
|
|
438
|
+
...(await this.userKeys.getUserKeyCryptoKeysForReconcile()),
|
|
439
|
+
await this.getEncryptionPrivateKeyForReconcile(),
|
|
440
|
+
].filter((key) => !!key);
|
|
441
|
+
return (0, sealedValues_1.openSealedValueWithKeys)({ crypto: this.cryptoAdapter, sealed, privateKeys });
|
|
442
|
+
}
|
|
405
443
|
async ingestSealedFromEntries(keyId, entries) {
|
|
406
444
|
if (!(0, sealedTypes_1.isSealedKeyId)(keyId))
|
|
407
445
|
return;
|
|
@@ -991,6 +1029,12 @@ class BaseMindooTenant {
|
|
|
991
1029
|
// canReadDatabase).
|
|
992
1030
|
if (typeof directory.canReadDatabase === "function") {
|
|
993
1031
|
const canRead = await directory.canReadDatabase(id);
|
|
1032
|
+
// Deposit right (doc_deposit, §6.10): the database opens so the user can
|
|
1033
|
+
// create sealed documents and push them; the server refuses every read.
|
|
1034
|
+
if (!canRead && typeof directory.canDepositDatabase === "function" && (await directory.canDepositDatabase(id))) {
|
|
1035
|
+
this.logger.info(`Opening database "${id}" for deposit only (no read access)`);
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
994
1038
|
if (!canRead) {
|
|
995
1039
|
this.logger.warn(`Denied database open for ${currentUser.username}: no read access to database "${id}"`);
|
|
996
1040
|
throw new Error(`User "${currentUser.username}" does not have read access to database "${id}".`);
|
|
@@ -1419,6 +1463,15 @@ class BaseMindooTenant {
|
|
|
1419
1463
|
await directory.registerUser(publicUserId, options.adminSigningKey, options.adminPassword, undefined, deviceLabel, {
|
|
1420
1464
|
distributeKeyIds: [],
|
|
1421
1465
|
});
|
|
1466
|
+
if ((options.depositPrefixes?.length ?? 0) > 0 || (options.accessPrefixes?.length ?? 0) > 0) {
|
|
1467
|
+
if (typeof directory.setGrantPersonalDatabaseRights !== "function") {
|
|
1468
|
+
throw new Error("This directory cannot record personal-database rights (depositPrefixes, accessPrefixes)");
|
|
1469
|
+
}
|
|
1470
|
+
await directory.setGrantPersonalDatabaseRights(publicUserId.username, {
|
|
1471
|
+
...(options.depositPrefixes?.length ? { depositPrefixes: options.depositPrefixes } : {}),
|
|
1472
|
+
...(options.accessPrefixes?.length ? { accessPrefixes: options.accessPrefixes } : {}),
|
|
1473
|
+
}, options.adminSigningKey, options.adminPassword);
|
|
1474
|
+
}
|
|
1422
1475
|
const userPublicKey = typeof request.userPublicKey === "string" ? request.userPublicKey.trim() : "";
|
|
1423
1476
|
if (userPublicKey) {
|
|
1424
1477
|
const userKeyDoc = await this.userKeys.createPendingFromJoin({
|
|
@@ -1590,6 +1643,7 @@ class BaseMindooTenant {
|
|
|
1590
1643
|
adminSigningPublicKey: this.administrationPublicKey,
|
|
1591
1644
|
adminEncryptionPublicKey: this.administrationEncryptionPublicKey,
|
|
1592
1645
|
};
|
|
1646
|
+
let serverSigningPublicKey;
|
|
1593
1647
|
try {
|
|
1594
1648
|
const serverInfoResponse = await fetch(`${baseUrl}/.well-known/mindoodb-server-info`, {
|
|
1595
1649
|
headers: {
|
|
@@ -1614,6 +1668,7 @@ class BaseMindooTenant {
|
|
|
1614
1668
|
|| typeof serverInfoBody.encryptionPublicKey !== "string") {
|
|
1615
1669
|
throw new Error("The server returned an invalid .well-known payload.");
|
|
1616
1670
|
}
|
|
1671
|
+
serverSigningPublicKey = readServerSigningPublicKey(serverInfoBody);
|
|
1617
1672
|
const rsaEncryption = new RSAEncryption_1.RSAEncryption(this.cryptoAdapter);
|
|
1618
1673
|
requestBody.encryptedPublicInfosKey = this.uint8ArrayToBase64(await rsaEncryption.encrypt(publicInfosKeyBytes, serverInfoBody.encryptionPublicKey));
|
|
1619
1674
|
}
|
|
@@ -1653,6 +1708,48 @@ class BaseMindooTenant {
|
|
|
1653
1708
|
}
|
|
1654
1709
|
console.log(`[publishToServer] ✓ Tenant "${this.tenantId}" published to server successfully`);
|
|
1655
1710
|
this.logger.info(`Tenant "${this.tenantId}" published to server successfully`);
|
|
1711
|
+
await this.trustServerAsWitness(serverSigningPublicKey, baseUrl, options);
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* Adds the server the tenant was just published to as a trusted witness
|
|
1715
|
+
* (docs/accesscontrol.md §6.4). The server stamps every entry it accepts;
|
|
1716
|
+
* without this directory document those receipts come from an untrusted key,
|
|
1717
|
+
* and once access control is switched on every stamped entry is quarantined.
|
|
1718
|
+
* Trust is evaluated at the receipt's `receivedAt`, so it has to be in place
|
|
1719
|
+
* before the first entry is pushed: that is why the publish flow writes it.
|
|
1720
|
+
*
|
|
1721
|
+
* Needs the administration private key: {@link PublishToServerOptions.adminSigningKey}
|
|
1722
|
+
* and `adminPassword`, or a `systemAdminUser` that is the tenant admin (demo
|
|
1723
|
+
* servers with open tenant creation). Without it a warning is logged and the
|
|
1724
|
+
* admin has to call `MindooTenantDirectory.addTrustedWitness()` before pushing.
|
|
1725
|
+
*/
|
|
1726
|
+
async trustServerAsWitness(serverSigningPublicKey, serverUrl, options) {
|
|
1727
|
+
if (options?.skipTrustedWitness)
|
|
1728
|
+
return;
|
|
1729
|
+
if (!serverSigningPublicKey) {
|
|
1730
|
+
this.logger.warn(`[publishToServer] ${serverUrl} did not report a signing key; it was not added as a trusted witness`);
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
let adminKey = options?.adminSigningKey;
|
|
1734
|
+
let adminPassword = options?.adminPassword;
|
|
1735
|
+
if ((!adminKey || adminPassword === undefined) &&
|
|
1736
|
+
options?.systemAdminUser &&
|
|
1737
|
+
options.systemAdminPassword !== undefined &&
|
|
1738
|
+
options.systemAdminUser.userSigningKeyPair.publicKey === this.administrationPublicKey) {
|
|
1739
|
+
adminKey = options.systemAdminUser.userSigningKeyPair.privateKey;
|
|
1740
|
+
adminPassword = options.systemAdminPassword;
|
|
1741
|
+
}
|
|
1742
|
+
const directory = await this.openDirectory();
|
|
1743
|
+
const trustedNow = await directory.getTrustedWitnessKeysAt?.(Date.now());
|
|
1744
|
+
if (trustedNow?.has(serverSigningPublicKey))
|
|
1745
|
+
return;
|
|
1746
|
+
if (!adminKey || adminPassword === undefined || !directory.addTrustedWitness) {
|
|
1747
|
+
console.warn(`[publishToServer] ${serverUrl} was not added as a trusted witness (no administration key given). ` +
|
|
1748
|
+
`Call directory.addTrustedWitness() before pushing data, or entries it stamps are quarantined once access control is enabled.`);
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
await directory.addTrustedWitness({ witnessPublicKey: serverSigningPublicKey, serverUrl }, adminKey, adminPassword);
|
|
1752
|
+
this.logger.info(`Added ${serverUrl} as a trusted witness of tenant "${this.tenantId}"`);
|
|
1656
1753
|
}
|
|
1657
1754
|
resolveIrohDial(serverUrl, options) {
|
|
1658
1755
|
if (!(0, irohLocator_1.isIrohLocator)(serverUrl) && !options?.irohTicket) {
|
|
@@ -1668,7 +1765,7 @@ class BaseMindooTenant {
|
|
|
1668
1765
|
return { ticket, io: options.irohStreamIO };
|
|
1669
1766
|
}
|
|
1670
1767
|
async publishToIrohServer(target, options) {
|
|
1671
|
-
const
|
|
1768
|
+
const IrohNetworkTransport = (0, dynamicImportInterop_1.namedExport)(await import("./appendonlystores/network/IrohNetworkTransport.js"), "IrohNetworkTransport");
|
|
1672
1769
|
const transport = new IrohNetworkTransport(target.io, target.ticket, {
|
|
1673
1770
|
tenantId: this.tenantId,
|
|
1674
1771
|
});
|
|
@@ -1681,6 +1778,7 @@ class BaseMindooTenant {
|
|
|
1681
1778
|
adminEncryptionPublicKey: this.administrationEncryptionPublicKey,
|
|
1682
1779
|
};
|
|
1683
1780
|
let supportsSystemAdmin = false;
|
|
1781
|
+
let serverSigningPublicKey;
|
|
1684
1782
|
try {
|
|
1685
1783
|
const serverInfo = await transport.getServerInfo();
|
|
1686
1784
|
if (!serverInfo
|
|
@@ -1690,6 +1788,7 @@ class BaseMindooTenant {
|
|
|
1690
1788
|
throw new Error("The server returned an invalid Iroh server-info payload.");
|
|
1691
1789
|
}
|
|
1692
1790
|
supportsSystemAdmin = serverInfo.supportsSystemAdmin === true;
|
|
1791
|
+
serverSigningPublicKey = readServerSigningPublicKey(serverInfo);
|
|
1693
1792
|
const rsaEncryption = new RSAEncryption_1.RSAEncryption(this.cryptoAdapter);
|
|
1694
1793
|
requestBody.encryptedPublicInfosKey = this.uint8ArrayToBase64(await rsaEncryption.encrypt(publicInfosKeyBytes, serverInfo.encryptionPublicKey));
|
|
1695
1794
|
}
|
|
@@ -1717,13 +1816,14 @@ class BaseMindooTenant {
|
|
|
1717
1816
|
await transport.registerTenant(token, this.tenantId, requestBody);
|
|
1718
1817
|
console.log(`[publishToServer] ✓ Tenant "${this.tenantId}" published to server successfully`);
|
|
1719
1818
|
this.logger.info(`Tenant "${this.tenantId}" published to server successfully`);
|
|
1819
|
+
await this.trustServerAsWitness(serverSigningPublicKey, `iroh:${target.ticket}`, options);
|
|
1720
1820
|
}
|
|
1721
1821
|
async authenticateAsSystemAdminOverIroh(transport, adminUser, adminPassword) {
|
|
1722
1822
|
const subtle = this.cryptoAdapter.getSubtle();
|
|
1723
1823
|
const signingKeyBuffer = await this.decryptPrivateKey(adminUser.userSigningKeyPair.privateKey, adminPassword, "signing");
|
|
1724
1824
|
const signingKey = await subtle.importKey("pkcs8", signingKeyBuffer, { name: "Ed25519" }, false, ["sign"]);
|
|
1725
1825
|
const { challenge } = await transport.requestSystemChallenge(adminUser.username, adminUser.userSigningKeyPair.publicKey);
|
|
1726
|
-
const messageBytes =
|
|
1826
|
+
const messageBytes = (0, AuthChallenge_1.authChallengeSigningBytes)(challenge);
|
|
1727
1827
|
const signatureBuffer = await subtle.sign({ name: "Ed25519" }, signingKey, messageBytes);
|
|
1728
1828
|
const result = await transport.authenticateSystem(challenge, new Uint8Array(signatureBuffer));
|
|
1729
1829
|
if (!result.success || !result.token) {
|
|
@@ -1754,7 +1854,7 @@ class BaseMindooTenant {
|
|
|
1754
1854
|
}
|
|
1755
1855
|
const { challenge } = (await challengeRes.json());
|
|
1756
1856
|
// Step 2: Sign the challenge
|
|
1757
|
-
const messageBytes =
|
|
1857
|
+
const messageBytes = (0, AuthChallenge_1.authChallengeSigningBytes)(challenge);
|
|
1758
1858
|
const signatureBuffer = await subtle.sign({ name: "Ed25519" }, signingKey, messageBytes);
|
|
1759
1859
|
const signatureBase64 = this.uint8ArrayToBase64(new Uint8Array(signatureBuffer));
|
|
1760
1860
|
// Step 3: Authenticate
|
|
@@ -1790,14 +1890,14 @@ class BaseMindooTenant {
|
|
|
1790
1890
|
}
|
|
1791
1891
|
const remoteStorePromise = (async () => {
|
|
1792
1892
|
// Lazy-import network modules to avoid circular dependencies and keep core lightweight
|
|
1793
|
-
const
|
|
1893
|
+
const ClientNetworkContentAddressedStore = (0, dynamicImportInterop_1.namedExport)(await import("../appendonlystores/network/ClientNetworkContentAddressedStore.js"), "ClientNetworkContentAddressedStore");
|
|
1794
1894
|
const transport = irohTarget
|
|
1795
|
-
? new (await import("./appendonlystores/network/IrohNetworkTransport.js"))
|
|
1895
|
+
? new ((0, dynamicImportInterop_1.namedExport)(await import("./appendonlystores/network/IrohNetworkTransport.js"), "IrohNetworkTransport"))(irohTarget.io, irohTarget.ticket, {
|
|
1796
1896
|
tenantId: this.tenantId,
|
|
1797
1897
|
dbId: validDbId,
|
|
1798
1898
|
storeKind,
|
|
1799
1899
|
})
|
|
1800
|
-
: new (await import("../appendonlystores/network/HttpTransport.js"))
|
|
1900
|
+
: new ((0, dynamicImportInterop_1.namedExport)(await import("../appendonlystores/network/HttpTransport.js"), "HttpTransport"))({
|
|
1801
1901
|
baseUrl: `${normalizedServerUrl}/${this.tenantId}`,
|
|
1802
1902
|
tenantId: this.tenantId,
|
|
1803
1903
|
dbId: validDbId,
|
|
@@ -2485,4 +2585,9 @@ BaseMindooTenant.DB_CACHE_RECORD_TYPES = [
|
|
|
2485
2585
|
*/
|
|
2486
2586
|
BaseMindooTenant.ENCRYPTION_MODE_RANDOM = 0x00;
|
|
2487
2587
|
BaseMindooTenant.ENCRYPTION_MODE_DETERMINISTIC = 0x01;
|
|
2588
|
+
/** The server's Ed25519 signing key (its witness key) from its server-info payload. */
|
|
2589
|
+
function readServerSigningPublicKey(serverInfo) {
|
|
2590
|
+
const key = serverInfo?.signingPublicKey;
|
|
2591
|
+
return typeof key === "string" && key.length > 0 ? key : undefined;
|
|
2592
|
+
}
|
|
2488
2593
|
//# sourceMappingURL=BaseMindooTenant.js.map
|