mindoodb 0.0.2 → 0.0.3
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.md +92 -19
- package/dist/__mocks__/expo-standard-web-crypto.d.ts +10 -0
- package/dist/__mocks__/expo-standard-web-crypto.d.ts.map +1 -0
- package/dist/__mocks__/expo-standard-web-crypto.js +22 -0
- package/dist/__mocks__/expo-standard-web-crypto.js.map +1 -0
- package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.d.ts +8 -0
- package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.d.ts.map +1 -0
- package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.js +16 -0
- package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.js.map +1 -0
- package/dist/appendonlystores/InMemoryContentAddressedStoreFactory.d.ts +1 -1
- package/dist/appendonlystores/InMemoryContentAddressedStoreFactory.d.ts.map +1 -1
- package/dist/appendonlystores/InMemoryContentAddressedStoreFactory.js +2 -2
- package/dist/appendonlystores/InMemoryContentAddressedStoreFactory.js.map +1 -1
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts +11 -1
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts.map +1 -1
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js +94 -0
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js.map +1 -1
- package/dist/appendonlystores/network/HttpTransport.d.ts +13 -2
- package/dist/appendonlystores/network/HttpTransport.d.ts.map +1 -1
- package/dist/appendonlystores/network/HttpTransport.js +86 -0
- package/dist/appendonlystores/network/HttpTransport.js.map +1 -1
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts +19 -2
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts.map +1 -1
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js +96 -0
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js.map +1 -1
- package/dist/appendonlystores/network/index.d.ts +1 -1
- package/dist/appendonlystores/network/index.d.ts.map +1 -1
- package/dist/appendonlystores/network/index.js.map +1 -1
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.d.ts +61 -0
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.d.ts.map +1 -0
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.js +685 -0
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.js.map +1 -0
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStoreFactory.d.ts +25 -0
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStoreFactory.d.ts.map +1 -0
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStoreFactory.js +41 -0
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStoreFactory.js.map +1 -0
- package/dist/browser/index.d.ts +5 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +13 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/core/BaseMindooDB.d.ts +12 -0
- package/dist/core/BaseMindooDB.d.ts.map +1 -1
- package/dist/core/BaseMindooDB.js +210 -108
- package/dist/core/BaseMindooDB.js.map +1 -1
- package/dist/core/BaseMindooTenant.d.ts +40 -6
- package/dist/core/BaseMindooTenant.d.ts.map +1 -1
- package/dist/core/BaseMindooTenant.js +179 -21
- package/dist/core/BaseMindooTenant.js.map +1 -1
- package/dist/core/BaseMindooTenantDirectory.d.ts.map +1 -1
- package/dist/core/BaseMindooTenantDirectory.js +10 -0
- package/dist/core/BaseMindooTenantDirectory.js.map +1 -1
- package/dist/core/BaseMindooTenantFactory.d.ts +22 -28
- package/dist/core/BaseMindooTenantFactory.d.ts.map +1 -1
- package/dist/core/BaseMindooTenantFactory.js +161 -65
- package/dist/core/BaseMindooTenantFactory.js.map +1 -1
- package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.d.ts +68 -0
- package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.d.ts.map +1 -0
- package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.js +659 -0
- package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.js.map +1 -0
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.d.ts +43 -3
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.d.ts.map +1 -1
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.js +162 -23
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.js.map +1 -1
- package/dist/core/appendonlystores/bloom.d.ts +85 -0
- package/dist/core/appendonlystores/bloom.d.ts.map +1 -0
- package/dist/core/appendonlystores/bloom.js +228 -0
- package/dist/core/appendonlystores/bloom.js.map +1 -0
- package/dist/core/appendonlystores/network/NetworkTransport.d.ts +22 -2
- package/dist/core/appendonlystores/network/NetworkTransport.d.ts.map +1 -1
- package/dist/core/appendonlystores/network/types.d.ts +10 -0
- package/dist/core/appendonlystores/network/types.d.ts.map +1 -1
- package/dist/core/appendonlystores/network/types.js.map +1 -1
- package/dist/core/appendonlystores/types.d.ts +123 -0
- package/dist/core/appendonlystores/types.d.ts.map +1 -1
- package/dist/core/automerge-adapter.d.ts +15 -0
- package/dist/core/automerge-adapter.d.ts.map +1 -0
- package/dist/core/automerge-adapter.js +73 -0
- package/dist/core/automerge-adapter.js.map +1 -0
- package/dist/core/crypto/pbkdf2Iterations.d.ts +12 -0
- package/dist/core/crypto/pbkdf2Iterations.d.ts.map +1 -0
- package/dist/core/crypto/pbkdf2Iterations.js +55 -0
- package/dist/core/crypto/pbkdf2Iterations.js.map +1 -0
- package/dist/core/index.d.ts +7 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +30 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keys/KeyBag.d.ts +32 -12
- package/dist/core/keys/KeyBag.d.ts.map +1 -1
- package/dist/core/keys/KeyBag.js +86 -26
- package/dist/core/keys/KeyBag.js.map +1 -1
- package/dist/core/keys/KeyContext.d.ts +4 -0
- package/dist/core/keys/KeyContext.d.ts.map +1 -0
- package/dist/core/keys/KeyContext.js +11 -0
- package/dist/core/keys/KeyContext.js.map +1 -0
- package/dist/core/types.d.ts +218 -50
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/uri/MindooURI.d.ts +58 -0
- package/dist/core/uri/MindooURI.d.ts.map +1 -0
- package/dist/core/uri/MindooURI.js +169 -0
- package/dist/core/uri/MindooURI.js.map +1 -0
- package/dist/core/userid/index.d.ts +0 -10
- package/dist/core/userid/index.d.ts.map +1 -1
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts +541 -0
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts.map +1 -0
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js +1334 -0
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js.map +1 -0
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +5 -1
- package/dist/node/index.js.map +1 -1
- package/dist/reactnative/crypto/AESAdapter.d.ts +18 -0
- package/dist/reactnative/crypto/AESAdapter.d.ts.map +1 -0
- package/dist/reactnative/crypto/AESAdapter.js +112 -0
- package/dist/reactnative/crypto/AESAdapter.js.map +1 -0
- package/dist/reactnative/crypto/Ed25519Adapter.d.ts +34 -0
- package/dist/reactnative/crypto/Ed25519Adapter.d.ts.map +1 -0
- package/dist/reactnative/crypto/Ed25519Adapter.js +386 -0
- package/dist/reactnative/crypto/Ed25519Adapter.js.map +1 -0
- package/dist/reactnative/crypto/ExpoGoCryptoAdapter.d.ts +23 -0
- package/dist/reactnative/crypto/ExpoGoCryptoAdapter.d.ts.map +1 -0
- package/dist/reactnative/crypto/ExpoGoCryptoAdapter.js +51 -0
- package/dist/reactnative/crypto/ExpoGoCryptoAdapter.js.map +1 -0
- package/dist/reactnative/crypto/HMACAdapter.d.ts +13 -0
- package/dist/reactnative/crypto/HMACAdapter.d.ts.map +1 -0
- package/dist/reactnative/crypto/HMACAdapter.js +50 -0
- package/dist/reactnative/crypto/HMACAdapter.js.map +1 -0
- package/dist/reactnative/crypto/KeyFormatConverter.d.ts +21 -0
- package/dist/reactnative/crypto/KeyFormatConverter.d.ts.map +1 -0
- package/dist/reactnative/crypto/KeyFormatConverter.js +72 -0
- package/dist/reactnative/crypto/KeyFormatConverter.js.map +1 -0
- package/dist/reactnative/crypto/PBKDF2Adapter.d.ts +19 -0
- package/dist/reactnative/crypto/PBKDF2Adapter.d.ts.map +1 -0
- package/dist/reactnative/crypto/PBKDF2Adapter.js +67 -0
- package/dist/reactnative/crypto/PBKDF2Adapter.js.map +1 -0
- package/dist/reactnative/crypto/QuickCryptoAdapter.d.ts +37 -0
- package/dist/reactnative/crypto/QuickCryptoAdapter.d.ts.map +1 -0
- package/dist/reactnative/crypto/QuickCryptoAdapter.js +72 -0
- package/dist/reactnative/crypto/QuickCryptoAdapter.js.map +1 -0
- package/dist/reactnative/crypto/RSAAdapter.d.ts +38 -0
- package/dist/reactnative/crypto/RSAAdapter.d.ts.map +1 -0
- package/dist/reactnative/crypto/RSAAdapter.js +184 -0
- package/dist/reactnative/crypto/RSAAdapter.js.map +1 -0
- package/dist/reactnative/crypto/ReactNativeCryptoAdapter.d.ts +33 -0
- package/dist/reactnative/crypto/ReactNativeCryptoAdapter.d.ts.map +1 -0
- package/dist/reactnative/crypto/ReactNativeCryptoAdapter.js +61 -0
- package/dist/reactnative/crypto/ReactNativeCryptoAdapter.js.map +1 -0
- package/dist/reactnative/crypto/SHA256Adapter.d.ts +9 -0
- package/dist/reactnative/crypto/SHA256Adapter.d.ts.map +1 -0
- package/dist/reactnative/crypto/SHA256Adapter.js +29 -0
- package/dist/reactnative/crypto/SHA256Adapter.js.map +1 -0
- package/dist/reactnative/crypto/SubtleCryptoPolyfill.d.ts +63 -0
- package/dist/reactnative/crypto/SubtleCryptoPolyfill.d.ts.map +1 -0
- package/dist/reactnative/crypto/SubtleCryptoPolyfill.js +350 -0
- package/dist/reactnative/crypto/SubtleCryptoPolyfill.js.map +1 -0
- package/dist/reactnative/index.d.ts +8 -0
- package/dist/reactnative/index.d.ts.map +1 -0
- package/dist/reactnative/index.js +38 -0
- package/dist/reactnative/index.js.map +1 -0
- package/package.json +51 -6
- package/patches/PATCHES.md +111 -0
- package/patches/react-native+0.76.9.patch +34 -0
- package/patches/react-native-quick-crypto+1.0.7.patch +42 -0
- package/scripts/cli.js +21 -0
- package/scripts/setup-react-native.js +228 -0
- package/templates/reactnative/App.js +252 -0
- package/templates/reactnative/app.json +29 -0
- package/templates/reactnative/babel.config.js +6 -0
- package/templates/reactnative/index.js +26 -0
- package/templates/reactnative/metro.config.snippet.js +39 -0
- package/templates/reactnative/mindoodb-polyfills.js +116 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MindooTenantFactory, MindooTenant,
|
|
1
|
+
import { MindooTenantFactory, MindooTenant, ContentAddressedStoreFactory, SigningKeyPair, EncryptionKeyPair, CreateTenantOptions, CreateTenantResult, JoinRequest, JoinResponse, JoinTenantOptions, JoinTenantResult, OpenTenantOptions } from "./types";
|
|
2
2
|
import { PrivateUserId, PublicUserId } from "./userid";
|
|
3
3
|
import { CryptoAdapter } from "./crypto/CryptoAdapter";
|
|
4
4
|
import { KeyBag } from "./keys/KeyBag";
|
|
@@ -17,28 +17,10 @@ export declare class BaseMindooTenantFactory implements MindooTenantFactory {
|
|
|
17
17
|
constructor(storeFactory: ContentAddressedStoreFactory, cryptoAdapter: CryptoAdapter, logger?: Logger);
|
|
18
18
|
getCryptoAdapter(): CryptoAdapter;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* The administration public key must be created beforehand using createSigningKeyPair()
|
|
23
|
-
* and passed to this method.
|
|
24
|
-
*
|
|
25
|
-
* The administration encryption public key must be created using createEncryptionKeyPair()
|
|
26
|
-
* and is used to encrypt sensitive data in the directory that only admins can decrypt.
|
|
27
|
-
*
|
|
28
|
-
* @param tenantId The ID of the tenant
|
|
29
|
-
* @param administrationPublicKey The administration public key (Ed25519, PEM format) created using createSigningKeyPair()
|
|
30
|
-
* @param administrationEncryptionPublicKey The administration encryption public key (RSA-OAEP, PEM format) created using createEncryptionKeyPair()
|
|
31
|
-
* @param tenantEncryptionKeyPassword The password to decrypt the tenant encryption private key
|
|
32
|
-
* @param currentUser The current user's private user ID (required for tenant operations)
|
|
33
|
-
* @param currentUserPassword The password to decrypt the current user's private keys
|
|
34
|
-
* @param keyBag The KeyBag instance for storing and loading named encrypted keys
|
|
35
|
-
* @return The new tenant
|
|
20
|
+
* Opens an existing tenant.
|
|
36
21
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* Opens an existing tenant with previously created keys.
|
|
40
|
-
*/
|
|
41
|
-
openTenantWithKeys(tenantId: string, tenantEncryptionPrivateKey: EncryptedPrivateKey, tenantEncryptionKeyPassword: string, administrationPublicKey: string, administrationEncryptionPublicKey: string, currentUser: PrivateUserId, currentUserPassword: string, keyBag: KeyBag): Promise<MindooTenant>;
|
|
22
|
+
openTenant(tenantId: string, administrationPublicKey: string, administrationEncryptionPublicKey: string, currentUser: PrivateUserId, currentUserPassword: string, keyBag: KeyBag, options?: OpenTenantOptions): Promise<MindooTenant>;
|
|
23
|
+
openTenant(tenantId: string, currentUser: PrivateUserId, currentUserPassword: string, keyBag: KeyBag): Promise<MindooTenant>;
|
|
42
24
|
/**
|
|
43
25
|
* Creates a new user with separate signing and encryption key pairs.
|
|
44
26
|
*/
|
|
@@ -53,12 +35,6 @@ export declare class BaseMindooTenantFactory implements MindooTenantFactory {
|
|
|
53
35
|
* for signature verification by other users.
|
|
54
36
|
*/
|
|
55
37
|
createSigningKeyPair(password: string): Promise<SigningKeyPair>;
|
|
56
|
-
/**
|
|
57
|
-
* Creates a new encrypted symmetric key (AES-256) for document encryption.
|
|
58
|
-
* Symmetric keys are shared secrets - anyone with the key can both encrypt and decrypt.
|
|
59
|
-
* For user-to-user encryption where only the recipient can decrypt, use createEncryptionKeyPair() instead.
|
|
60
|
-
*/
|
|
61
|
-
createSymmetricEncryptedPrivateKey(password: string): Promise<EncryptedPrivateKey>;
|
|
62
38
|
/**
|
|
63
39
|
* Creates a new asymmetric encryption key pair (RSA-OAEP) for user-to-user encryption.
|
|
64
40
|
* Returns both the public and encrypted private key.
|
|
@@ -67,6 +43,23 @@ export declare class BaseMindooTenantFactory implements MindooTenantFactory {
|
|
|
67
43
|
* and only User B (with the private key) can decrypt it.
|
|
68
44
|
*/
|
|
69
45
|
createEncryptionKeyPair(password: string): Promise<EncryptionKeyPair>;
|
|
46
|
+
/**
|
|
47
|
+
* Create a new tenant with a single call.
|
|
48
|
+
*/
|
|
49
|
+
createTenant(options: CreateTenantOptions): Promise<CreateTenantResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Create a join request from a user's private identity.
|
|
52
|
+
*/
|
|
53
|
+
createJoinRequest(user: PrivateUserId, options?: {
|
|
54
|
+
format?: "object";
|
|
55
|
+
}): JoinRequest;
|
|
56
|
+
createJoinRequest(user: PrivateUserId, options: {
|
|
57
|
+
format: "uri";
|
|
58
|
+
}): string;
|
|
59
|
+
/**
|
|
60
|
+
* Join a tenant using a join response from an admin.
|
|
61
|
+
*/
|
|
62
|
+
joinTenant(joinResponse: JoinResponse | string, options: JoinTenantOptions): Promise<JoinTenantResult>;
|
|
70
63
|
/**
|
|
71
64
|
* Internal method to encrypt a private key using password-based key derivation.
|
|
72
65
|
* This is the reverse of BaseMindooTenant.decryptPrivateKey().
|
|
@@ -77,6 +70,7 @@ export declare class BaseMindooTenantFactory implements MindooTenantFactory {
|
|
|
77
70
|
* @returns The encrypted private key
|
|
78
71
|
*/
|
|
79
72
|
private encryptPrivateKey;
|
|
73
|
+
private assertRequiredKeysInKeyBag;
|
|
80
74
|
/**
|
|
81
75
|
* Convert ArrayBuffer to PEM format
|
|
82
76
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseMindooTenantFactory.d.ts","sourceRoot":"","sources":["../../src/core/BaseMindooTenantFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,YAAY,
|
|
1
|
+
{"version":3,"file":"BaseMindooTenantFactory.d.ts","sourceRoot":"","sources":["../../src/core/BaseMindooTenantFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,YAAY,EAEZ,4BAA4B,EAC5B,cAAc,EACd,iBAAiB,EAEjB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,MAAM,EAA8C,MAAM,WAAW,CAAC;AAG/E;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,mBAAmB;IACjE,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,MAAM,CAAS;gBAGrB,YAAY,EAAE,4BAA4B,EAC1C,aAAa,EAAE,aAAa,EAC5B,MAAM,CAAC,EAAE,MAAM;IAUjB,gBAAgB,IAAI,aAAa;IAIjC;;OAEG;IACG,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,uBAAuB,EAAE,MAAM,EAC/B,iCAAiC,EAAE,MAAM,EACzC,WAAW,EAAE,aAAa,EAC1B,mBAAmB,EAAE,MAAM,EAC3B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,CAAC;IAClB,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,aAAa,EAC1B,mBAAmB,EAAE,MAAM,EAC3B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,YAAY,CAAC;IAkExB;;OAEG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA4G9E;;OAEG;IACH,cAAc,CAAC,aAAa,EAAE,aAAa,GAAG,YAAY;IAQ1D;;;;OAIG;IACG,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAgCrE;;;;;;OAMG;IACG,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAuC3E;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA0C7E;;OAEG;IACH,iBAAiB,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,WAAW;IACpF,iBAAiB,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,KAAK,CAAA;KAAE,GAAG,MAAM;IAkB1E;;OAEG;IACG,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2D5G;;;;;;;;OAQG;YACW,iBAAiB;YAgGjB,0BAA0B;IAgBxC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAKxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAO3B"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseMindooTenantFactory = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
4
5
|
const BaseMindooTenant_1 = require("./BaseMindooTenant");
|
|
6
|
+
const pbkdf2Iterations_1 = require("./crypto/pbkdf2Iterations");
|
|
7
|
+
const KeyBag_1 = require("./keys/KeyBag");
|
|
5
8
|
const logging_1 = require("./logging");
|
|
9
|
+
const MindooURI_1 = require("./uri/MindooURI");
|
|
6
10
|
/**
|
|
7
11
|
* BaseTenantFactory is a platform-agnostic implementation of TenantFactory
|
|
8
12
|
* that creates and manages tenants and users.
|
|
@@ -22,47 +26,37 @@ class BaseMindooTenantFactory {
|
|
|
22
26
|
getCryptoAdapter() {
|
|
23
27
|
return this.cryptoAdapter;
|
|
24
28
|
}
|
|
25
|
-
|
|
26
|
-
* Create a new tenant from scratch with a new tenant encryption key.
|
|
27
|
-
*
|
|
28
|
-
* The administration public key must be created beforehand using createSigningKeyPair()
|
|
29
|
-
* and passed to this method.
|
|
30
|
-
*
|
|
31
|
-
* The administration encryption public key must be created using createEncryptionKeyPair()
|
|
32
|
-
* and is used to encrypt sensitive data in the directory that only admins can decrypt.
|
|
33
|
-
*
|
|
34
|
-
* @param tenantId The ID of the tenant
|
|
35
|
-
* @param administrationPublicKey The administration public key (Ed25519, PEM format) created using createSigningKeyPair()
|
|
36
|
-
* @param administrationEncryptionPublicKey The administration encryption public key (RSA-OAEP, PEM format) created using createEncryptionKeyPair()
|
|
37
|
-
* @param tenantEncryptionKeyPassword The password to decrypt the tenant encryption private key
|
|
38
|
-
* @param currentUser The current user's private user ID (required for tenant operations)
|
|
39
|
-
* @param currentUserPassword The password to decrypt the current user's private keys
|
|
40
|
-
* @param keyBag The KeyBag instance for storing and loading named encrypted keys
|
|
41
|
-
* @return The new tenant
|
|
42
|
-
*/
|
|
43
|
-
async createTenant(tenantId, administrationPublicKey, administrationEncryptionPublicKey, tenantEncryptionKeyPassword, currentUser, currentUserPassword, keyBag) {
|
|
44
|
-
this.logger.info(`Creating tenant: ${tenantId}`);
|
|
45
|
-
const subtle = this.cryptoAdapter.getSubtle();
|
|
46
|
-
// Generate tenant encryption key (AES-256)
|
|
47
|
-
const tenantEncryptionKey = await subtle.generateKey({
|
|
48
|
-
name: "AES-GCM",
|
|
49
|
-
length: 256,
|
|
50
|
-
}, true, // extractable
|
|
51
|
-
["encrypt", "decrypt"]);
|
|
52
|
-
// Export the tenant encryption key material
|
|
53
|
-
const tenantKeyMaterial = await subtle.exportKey("raw", tenantEncryptionKey);
|
|
54
|
-
const tenantKeyBytes = new Uint8Array(tenantKeyMaterial);
|
|
55
|
-
// Encrypt the tenant encryption key with password
|
|
56
|
-
const encryptedTenantKey = await this.encryptPrivateKey(tenantKeyBytes, tenantEncryptionKeyPassword, "default");
|
|
57
|
-
return this.openTenantWithKeys(tenantId, encryptedTenantKey, tenantEncryptionKeyPassword, administrationPublicKey, administrationEncryptionPublicKey, currentUser, currentUserPassword, keyBag);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Opens an existing tenant with previously created keys.
|
|
61
|
-
*/
|
|
62
|
-
async openTenantWithKeys(tenantId, tenantEncryptionPrivateKey, tenantEncryptionKeyPassword, administrationPublicKey, administrationEncryptionPublicKey, currentUser, currentUserPassword, keyBag) {
|
|
29
|
+
async openTenant(tenantId, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
|
|
63
30
|
this.logger.info(`Opening tenant: ${tenantId}`);
|
|
31
|
+
let administrationPublicKey;
|
|
32
|
+
let administrationEncryptionPublicKey;
|
|
33
|
+
let currentUser;
|
|
34
|
+
let currentUserPassword;
|
|
35
|
+
let keyBag;
|
|
36
|
+
let options;
|
|
37
|
+
if (typeof arg2 === "string") {
|
|
38
|
+
administrationPublicKey = arg2;
|
|
39
|
+
administrationEncryptionPublicKey = arg3;
|
|
40
|
+
currentUser = arg4;
|
|
41
|
+
currentUserPassword = arg5;
|
|
42
|
+
keyBag = arg6;
|
|
43
|
+
options = arg7;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Backward-compatible short form for internal tests
|
|
47
|
+
currentUser = arg2;
|
|
48
|
+
currentUserPassword = arg3;
|
|
49
|
+
keyBag = arg4;
|
|
50
|
+
administrationPublicKey = currentUser.userSigningKeyPair.publicKey;
|
|
51
|
+
administrationEncryptionPublicKey = currentUser.userEncryptionKeyPair.publicKey;
|
|
52
|
+
}
|
|
53
|
+
if (administrationPublicKey === currentUser.userSigningKeyPair.publicKey) {
|
|
54
|
+
throw new Error("Invalid openTenant configuration: currentUser must not be the administration identity. " +
|
|
55
|
+
"Use a regular user for tenant operations and keep admin credentials for privileged directory operations only.");
|
|
56
|
+
}
|
|
57
|
+
await this.assertRequiredKeysInKeyBag(tenantId, keyBag);
|
|
64
58
|
const tenantLogger = this.logger.createChild(`Tenant:${tenantId}`);
|
|
65
|
-
const tenant = new BaseMindooTenant_1.BaseMindooTenant(this, tenantId,
|
|
59
|
+
const tenant = new BaseMindooTenant_1.BaseMindooTenant(this, tenantId, administrationPublicKey, administrationEncryptionPublicKey, currentUser, currentUserPassword, keyBag, this.storeFactory, this.cryptoAdapter, tenantLogger, options?.additionalTrustedKeys);
|
|
66
60
|
// Initialize the tenant
|
|
67
61
|
await tenant.initialize();
|
|
68
62
|
return tenant;
|
|
@@ -72,22 +66,40 @@ class BaseMindooTenantFactory {
|
|
|
72
66
|
*/
|
|
73
67
|
async createUserId(username, password) {
|
|
74
68
|
this.logger.debug(`Creating user ID: ${username}`);
|
|
69
|
+
console.log('[createUserId] Starting createUserId for:', username);
|
|
70
|
+
const startTime = Date.now();
|
|
75
71
|
const subtle = this.cryptoAdapter.getSubtle();
|
|
72
|
+
console.log('[createUserId] Got subtle crypto API');
|
|
76
73
|
// Generate signing key pair (Ed25519)
|
|
74
|
+
console.log('[createUserId] Step 1: Generating Ed25519 signing key pair...');
|
|
75
|
+
const signingKeyPairStart = Date.now();
|
|
77
76
|
const signingKeyPair = await subtle.generateKey({
|
|
78
77
|
name: "Ed25519",
|
|
79
78
|
}, true, // extractable
|
|
80
79
|
["sign", "verify"]);
|
|
80
|
+
console.log('[createUserId] Step 1: ✓ Ed25519 signing key pair generated in', Date.now() - signingKeyPairStart, 'ms');
|
|
81
81
|
// Export signing public key (PEM format)
|
|
82
|
+
console.log('[createUserId] Step 2: Exporting signing public key...');
|
|
83
|
+
const exportSigningPublicStart = Date.now();
|
|
82
84
|
const signingPublicKeyBuffer = await subtle.exportKey("spki", signingKeyPair.publicKey);
|
|
83
85
|
const signingPublicKey = this.arrayBufferToPEM(signingPublicKeyBuffer, "PUBLIC KEY");
|
|
86
|
+
console.log('[createUserId] Step 2: ✓ Signing public key exported in', Date.now() - exportSigningPublicStart, 'ms');
|
|
84
87
|
// Export signing private key
|
|
88
|
+
console.log('[createUserId] Step 3: Exporting signing private key...');
|
|
89
|
+
const exportSigningPrivateStart = Date.now();
|
|
85
90
|
const signingPrivateKeyBuffer = await subtle.exportKey("pkcs8", signingKeyPair.privateKey);
|
|
86
91
|
const signingPrivateKeyBytes = new Uint8Array(signingPrivateKeyBuffer);
|
|
92
|
+
console.log('[createUserId] Step 3: ✓ Signing private key exported in', Date.now() - exportSigningPrivateStart, 'ms');
|
|
87
93
|
// Encrypt signing private key with password (salt: "signing")
|
|
94
|
+
const pbkdf2Iterations = (0, pbkdf2Iterations_1.resolvePbkdf2Iterations)(pbkdf2Iterations_1.DEFAULT_PBKDF2_ITERATIONS);
|
|
95
|
+
console.log(`[createUserId] Step 4: Encrypting signing private key (PBKDF2 with ${pbkdf2Iterations} iterations)...`);
|
|
96
|
+
const encryptSigningStart = Date.now();
|
|
88
97
|
const encryptedSigningKey = await this.encryptPrivateKey(signingPrivateKeyBytes, password, "signing");
|
|
98
|
+
console.log('[createUserId] Step 4: ✓ Signing private key encrypted in', Date.now() - encryptSigningStart, 'ms');
|
|
89
99
|
// Generate encryption key pair (RSA-OAEP, 3072 bits for state-of-the-art security)
|
|
90
100
|
// NIST recommends 3072-bit RSA for new applications (security through 2030+)
|
|
101
|
+
console.log('[createUserId] Step 5: Generating RSA-3072 encryption key pair (this may take 10-30 seconds in JS)...');
|
|
102
|
+
const rsaKeyGenStart = Date.now();
|
|
91
103
|
const encryptionKeyPair = await subtle.generateKey({
|
|
92
104
|
name: "RSA-OAEP",
|
|
93
105
|
modulusLength: 3072,
|
|
@@ -95,18 +107,28 @@ class BaseMindooTenantFactory {
|
|
|
95
107
|
hash: "SHA-256",
|
|
96
108
|
}, true, // extractable
|
|
97
109
|
["encrypt", "decrypt"]);
|
|
110
|
+
console.log('[createUserId] Step 5: ✓ RSA-3072 encryption key pair generated in', Date.now() - rsaKeyGenStart, 'ms');
|
|
98
111
|
// Export encryption public key (PEM format)
|
|
112
|
+
console.log('[createUserId] Step 6: Exporting encryption public key...');
|
|
113
|
+
const exportEncryptionPublicStart = Date.now();
|
|
99
114
|
const encryptionPublicKeyBuffer = await subtle.exportKey("spki", encryptionKeyPair.publicKey);
|
|
100
115
|
const encryptionPublicKey = this.arrayBufferToPEM(encryptionPublicKeyBuffer, "PUBLIC KEY");
|
|
116
|
+
console.log('[createUserId] Step 6: ✓ Encryption public key exported in', Date.now() - exportEncryptionPublicStart, 'ms');
|
|
101
117
|
// Export encryption private key
|
|
118
|
+
console.log('[createUserId] Step 7: Exporting encryption private key...');
|
|
119
|
+
const exportEncryptionPrivateStart = Date.now();
|
|
102
120
|
const encryptionPrivateKeyBuffer = await subtle.exportKey("pkcs8", encryptionKeyPair.privateKey);
|
|
103
121
|
const encryptionPrivateKeyBytes = new Uint8Array(encryptionPrivateKeyBuffer);
|
|
122
|
+
console.log('[createUserId] Step 7: ✓ Encryption private key exported in', Date.now() - exportEncryptionPrivateStart, 'ms');
|
|
104
123
|
// Encrypt encryption private key with password (salt: "encryption")
|
|
124
|
+
console.log(`[createUserId] Step 8: Encrypting encryption private key (PBKDF2 with ${pbkdf2Iterations} iterations)...`);
|
|
125
|
+
const encryptEncryptionStart = Date.now();
|
|
105
126
|
const encryptedEncryptionKey = await this.encryptPrivateKey(encryptionPrivateKeyBytes, password, "encryption");
|
|
127
|
+
console.log('[createUserId] Step 8: ✓ Encryption private key encrypted in', Date.now() - encryptEncryptionStart, 'ms');
|
|
106
128
|
// Create PrivateUserId
|
|
129
|
+
console.log('[createUserId] Step 9: Creating PrivateUserId object...');
|
|
107
130
|
const privateUserId = {
|
|
108
131
|
username,
|
|
109
|
-
administrationSignature: "", // Will be set when user is registered by an admin
|
|
110
132
|
userSigningKeyPair: {
|
|
111
133
|
publicKey: signingPublicKey,
|
|
112
134
|
privateKey: encryptedSigningKey,
|
|
@@ -116,6 +138,8 @@ class BaseMindooTenantFactory {
|
|
|
116
138
|
privateKey: encryptedEncryptionKey,
|
|
117
139
|
},
|
|
118
140
|
};
|
|
141
|
+
const totalTime = Date.now() - startTime;
|
|
142
|
+
console.log('[createUserId] ✓ User ID created successfully in', totalTime, 'ms total');
|
|
119
143
|
this.logger.debug(`Created user ID: ${username}`);
|
|
120
144
|
return privateUserId;
|
|
121
145
|
}
|
|
@@ -125,7 +149,6 @@ class BaseMindooTenantFactory {
|
|
|
125
149
|
toPublicUserId(privateUserId) {
|
|
126
150
|
return {
|
|
127
151
|
username: privateUserId.username,
|
|
128
|
-
administrationSignature: privateUserId.administrationSignature,
|
|
129
152
|
userSigningPublicKey: privateUserId.userSigningKeyPair.publicKey,
|
|
130
153
|
userEncryptionPublicKey: privateUserId.userEncryptionKeyPair.publicKey,
|
|
131
154
|
};
|
|
@@ -157,29 +180,6 @@ class BaseMindooTenantFactory {
|
|
|
157
180
|
privateKey: encryptedKey,
|
|
158
181
|
};
|
|
159
182
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Creates a new encrypted symmetric key (AES-256) for document encryption.
|
|
162
|
-
* Symmetric keys are shared secrets - anyone with the key can both encrypt and decrypt.
|
|
163
|
-
* For user-to-user encryption where only the recipient can decrypt, use createEncryptionKeyPair() instead.
|
|
164
|
-
*/
|
|
165
|
-
async createSymmetricEncryptedPrivateKey(password) {
|
|
166
|
-
this.logger.debug(`Creating encrypted symmetric key`);
|
|
167
|
-
const subtle = this.cryptoAdapter.getSubtle();
|
|
168
|
-
// Generate a new AES-256 key
|
|
169
|
-
const key = await subtle.generateKey({
|
|
170
|
-
name: "AES-GCM",
|
|
171
|
-
length: 256,
|
|
172
|
-
}, true, // extractable
|
|
173
|
-
["encrypt", "decrypt"]);
|
|
174
|
-
// Export the key material
|
|
175
|
-
const keyMaterial = await subtle.exportKey("raw", key);
|
|
176
|
-
const keyBytes = new Uint8Array(keyMaterial);
|
|
177
|
-
// Encrypt the key material using the shared helper
|
|
178
|
-
// Use "default" as the salt string to match how tenant encryption keys are decrypted
|
|
179
|
-
const encryptedKey = await this.encryptPrivateKey(keyBytes, password, "default");
|
|
180
|
-
this.logger.debug(`Created encrypted symmetric key`);
|
|
181
|
-
return encryptedKey;
|
|
182
|
-
}
|
|
183
183
|
/**
|
|
184
184
|
* Creates a new asymmetric encryption key pair (RSA-OAEP) for user-to-user encryption.
|
|
185
185
|
* Returns both the public and encrypted private key.
|
|
@@ -214,6 +214,75 @@ class BaseMindooTenantFactory {
|
|
|
214
214
|
privateKey: encryptedKey,
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
|
+
// ==================== Convenience Methods ====================
|
|
218
|
+
/**
|
|
219
|
+
* Create a new tenant with a single call.
|
|
220
|
+
*/
|
|
221
|
+
async createTenant(options) {
|
|
222
|
+
this.logger.info(`Creating tenant: ${options.tenantId}`);
|
|
223
|
+
console.log(`[createTenant] Creating tenant "${options.tenantId}" with admin "${options.adminName}" and user "${options.userName}"`);
|
|
224
|
+
// 1. Create admin and app user identities
|
|
225
|
+
const adminUser = await this.createUserId(options.adminName, options.adminPassword);
|
|
226
|
+
const appUser = await this.createUserId(options.userName, options.userPassword);
|
|
227
|
+
// 2. Create KeyBag with required keys
|
|
228
|
+
const keyBag = new KeyBag_1.KeyBag(appUser.userEncryptionKeyPair.privateKey, options.userPassword, this.cryptoAdapter, this.logger.createChild("KeyBag"));
|
|
229
|
+
await keyBag.createTenantKey(options.tenantId);
|
|
230
|
+
await keyBag.createDocKey(types_1.PUBLIC_INFOS_KEY_ID);
|
|
231
|
+
// 3. Open tenant
|
|
232
|
+
const tenant = await this.openTenant(options.tenantId, adminUser.userSigningKeyPair.publicKey, adminUser.userEncryptionKeyPair.publicKey, appUser, options.userPassword, keyBag);
|
|
233
|
+
// 4. Register the app user in the directory
|
|
234
|
+
const directory = await tenant.openDirectory();
|
|
235
|
+
await directory.registerUser(this.toPublicUserId(appUser), adminUser.userSigningKeyPair.privateKey, options.adminPassword);
|
|
236
|
+
console.log(`[createTenant] ✓ Tenant "${options.tenantId}" created successfully`);
|
|
237
|
+
this.logger.info(`Tenant "${options.tenantId}" created successfully`);
|
|
238
|
+
return { tenant, adminUser, appUser, keyBag };
|
|
239
|
+
}
|
|
240
|
+
createJoinRequest(user, options) {
|
|
241
|
+
const publicUser = this.toPublicUserId(user);
|
|
242
|
+
const joinRequest = {
|
|
243
|
+
v: 1,
|
|
244
|
+
username: publicUser.username,
|
|
245
|
+
signingPublicKey: publicUser.userSigningPublicKey,
|
|
246
|
+
encryptionPublicKey: publicUser.userEncryptionPublicKey,
|
|
247
|
+
};
|
|
248
|
+
if (options?.format === "uri") {
|
|
249
|
+
return (0, MindooURI_1.encodeMindooURI)("join-request", joinRequest);
|
|
250
|
+
}
|
|
251
|
+
return joinRequest;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Join a tenant using a join response from an admin.
|
|
255
|
+
*/
|
|
256
|
+
async joinTenant(joinResponse, options) {
|
|
257
|
+
// Parse the join response if it's a URI string
|
|
258
|
+
let response;
|
|
259
|
+
if (typeof joinResponse === "string") {
|
|
260
|
+
if (!(0, MindooURI_1.isMindooURI)(joinResponse)) {
|
|
261
|
+
throw new Error("Invalid join response: expected a JoinResponse object or a mdb://join-response/... URI string");
|
|
262
|
+
}
|
|
263
|
+
const decoded = (0, MindooURI_1.decodeMindooURI)(joinResponse);
|
|
264
|
+
if (decoded.type !== "join-response") {
|
|
265
|
+
throw new Error(`Invalid URI type: expected "join-response", got "${decoded.type}"`);
|
|
266
|
+
}
|
|
267
|
+
response = decoded.payload;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
response = joinResponse;
|
|
271
|
+
}
|
|
272
|
+
console.log(`[joinTenant] Joining tenant "${response.tenantId}"`);
|
|
273
|
+
this.logger.info(`Joining tenant: ${response.tenantId}`);
|
|
274
|
+
// 1. Create a new KeyBag for this user
|
|
275
|
+
const keyBag = new KeyBag_1.KeyBag(options.user.userEncryptionKeyPair.privateKey, options.password, this.cryptoAdapter, this.logger.createChild("KeyBag"));
|
|
276
|
+
// 2. Import the encrypted tenant key
|
|
277
|
+
await keyBag.decryptAndImportKey("tenant", response.tenantId, response.encryptedTenantKey, options.sharePassword);
|
|
278
|
+
// 3. Import the encrypted $publicinfos key
|
|
279
|
+
await keyBag.decryptAndImportKey("doc", types_1.PUBLIC_INFOS_KEY_ID, response.encryptedPublicInfosKey, options.sharePassword);
|
|
280
|
+
// 4. Open the tenant
|
|
281
|
+
const tenant = await this.openTenant(response.tenantId, response.adminSigningPublicKey, response.adminEncryptionPublicKey, options.user, options.password, keyBag);
|
|
282
|
+
console.log(`[joinTenant] ✓ Joined tenant "${response.tenantId}" successfully`);
|
|
283
|
+
this.logger.info(`Joined tenant "${response.tenantId}" successfully`);
|
|
284
|
+
return { tenant, keyBag };
|
|
285
|
+
}
|
|
217
286
|
/**
|
|
218
287
|
* Internal method to encrypt a private key using password-based key derivation.
|
|
219
288
|
* This is the reverse of BaseMindooTenant.decryptPrivateKey().
|
|
@@ -224,24 +293,33 @@ class BaseMindooTenantFactory {
|
|
|
224
293
|
* @returns The encrypted private key
|
|
225
294
|
*/
|
|
226
295
|
async encryptPrivateKey(privateKeyBytes, password, saltString) {
|
|
296
|
+
console.log(`[encryptPrivateKey] Starting encryption with salt: "${saltString}", key size: ${privateKeyBytes.length} bytes`);
|
|
297
|
+
const startTime = Date.now();
|
|
227
298
|
const subtle = this.cryptoAdapter.getSubtle();
|
|
228
299
|
// Bind getRandomValues to maintain 'this' context
|
|
229
300
|
const randomValues = this.cryptoAdapter.getRandomValues.bind(this.cryptoAdapter);
|
|
230
301
|
// Generate random salt and IV
|
|
302
|
+
console.log('[encryptPrivateKey] Generating random salt and IV...');
|
|
231
303
|
const saltArray = new Uint8Array(16); // 16 bytes salt
|
|
232
304
|
randomValues(saltArray);
|
|
233
305
|
const salt = new Uint8Array(saltArray);
|
|
234
306
|
const ivArray = new Uint8Array(12); // 12 bytes for AES-GCM
|
|
235
307
|
randomValues(ivArray);
|
|
236
308
|
const iv = new Uint8Array(ivArray);
|
|
309
|
+
console.log('[encryptPrivateKey] ✓ Salt and IV generated');
|
|
237
310
|
// Combine salt with saltString for key derivation (same as decryption)
|
|
238
311
|
const saltStringBytes = new TextEncoder().encode(saltString);
|
|
239
312
|
const combinedSalt = new Uint8Array(salt.length + saltStringBytes.length);
|
|
240
313
|
combinedSalt.set(salt);
|
|
241
314
|
combinedSalt.set(saltStringBytes, salt.length);
|
|
242
315
|
// Derive encryption key from password using PBKDF2
|
|
316
|
+
console.log('[encryptPrivateKey] Importing password key...');
|
|
317
|
+
const importKeyStart = Date.now();
|
|
243
318
|
const passwordKey = await subtle.importKey("raw", new TextEncoder().encode(password), "PBKDF2", false, ["deriveBits", "deriveKey"]);
|
|
244
|
-
|
|
319
|
+
console.log('[encryptPrivateKey] ✓ Password key imported in', Date.now() - importKeyStart, 'ms');
|
|
320
|
+
const iterations = (0, pbkdf2Iterations_1.resolvePbkdf2Iterations)(pbkdf2Iterations_1.DEFAULT_PBKDF2_ITERATIONS);
|
|
321
|
+
console.log(`[encryptPrivateKey] Deriving key with PBKDF2 (${iterations} iterations)...`);
|
|
322
|
+
const deriveKeyStart = Date.now();
|
|
245
323
|
const derivedKey = await subtle.deriveKey({
|
|
246
324
|
name: "PBKDF2",
|
|
247
325
|
salt: combinedSalt,
|
|
@@ -251,12 +329,16 @@ class BaseMindooTenantFactory {
|
|
|
251
329
|
name: "AES-GCM",
|
|
252
330
|
length: 256,
|
|
253
331
|
}, false, ["encrypt"]);
|
|
332
|
+
console.log('[encryptPrivateKey] ✓ Key derived in', Date.now() - deriveKeyStart, 'ms');
|
|
254
333
|
// Encrypt the private key
|
|
334
|
+
console.log('[encryptPrivateKey] Encrypting private key data...');
|
|
335
|
+
const encryptStart = Date.now();
|
|
255
336
|
const encrypted = await subtle.encrypt({
|
|
256
337
|
name: "AES-GCM",
|
|
257
338
|
iv: iv,
|
|
258
339
|
tagLength: 128,
|
|
259
340
|
}, derivedKey, privateKeyBytes.buffer);
|
|
341
|
+
console.log('[encryptPrivateKey] ✓ Private key encrypted in', Date.now() - encryptStart, 'ms');
|
|
260
342
|
// Extract ciphertext and tag from encrypted data
|
|
261
343
|
// AES-GCM appends the tag at the end
|
|
262
344
|
const encryptedArray = new Uint8Array(encrypted);
|
|
@@ -271,8 +353,22 @@ class BaseMindooTenantFactory {
|
|
|
271
353
|
salt: this.uint8ArrayToBase64(salt),
|
|
272
354
|
iterations: iterations,
|
|
273
355
|
};
|
|
356
|
+
const totalTime = Date.now() - startTime;
|
|
357
|
+
console.log(`[encryptPrivateKey] ✓ Encryption completed in ${totalTime}ms total`);
|
|
274
358
|
return encryptedKey;
|
|
275
359
|
}
|
|
360
|
+
async assertRequiredKeysInKeyBag(tenantId, keyBag) {
|
|
361
|
+
// Note: The tenant key (type "tenant", id tenantId) is NOT checked here.
|
|
362
|
+
// It is only needed when decrypting regular database payloads (decryptionKeyId "default").
|
|
363
|
+
// Server-side tenants that only need directory access can operate without it.
|
|
364
|
+
// If it is missing and code tries to decrypt regular data, a clear
|
|
365
|
+
// SymmetricKeyNotFoundError will be thrown at the point of use.
|
|
366
|
+
const publicInfosKey = await keyBag.get("doc", types_1.PUBLIC_INFOS_KEY_ID);
|
|
367
|
+
if (!publicInfosKey) {
|
|
368
|
+
throw new Error(`Missing required directory access key in KeyBag: ("doc", "${types_1.PUBLIC_INFOS_KEY_ID}"). ` +
|
|
369
|
+
`Create/import it first with keyBag.createDocKey("${types_1.PUBLIC_INFOS_KEY_ID}") or keyBag.decryptAndImportKey("doc", "${types_1.PUBLIC_INFOS_KEY_ID}", encryptedPublicInfosKey, password).`);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
276
372
|
/**
|
|
277
373
|
* Convert ArrayBuffer to PEM format
|
|
278
374
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseMindooTenantFactory.js","sourceRoot":"","sources":["../../src/core/BaseMindooTenantFactory.ts"],"names":[],"mappings":";;;AASA,yDAAsD;AAGtD,uCAA+E;AAE/E;;;;;;GAMG;AACH,MAAa,uBAAuB;IAKlC,YACE,YAA0C,EAC1C,aAA4B,EAC5B,MAAe;QAEf,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,kEAAkE;QAClE,IAAI,CAAC,MAAM;YACT,MAAM;gBACN,IAAI,sBAAY,CAAC,IAAA,4BAAkB,GAAE,EAAE,qBAAqB,EAAE,IAAI,CAAC,CAAC;IACxE,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,YAAY,CAChB,QAAgB,EAChB,uBAA+B,EAC/B,iCAAyC,EACzC,2BAAmC,EACnC,WAA0B,EAC1B,mBAA2B,EAC3B,MAAc;QAEd,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;QAEjD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;QAE9C,2CAA2C;QAC3C,MAAM,mBAAmB,GAAG,MAAM,MAAM,CAAC,WAAW,CAClD;YACE,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,GAAG;SACZ,EACD,IAAI,EAAE,cAAc;QACpB,CAAC,SAAS,EAAE,SAAS,CAAC,CACvB,CAAC;QAEF,4CAA4C;QAC5C,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;Q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C,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QAC9C,OAAO,cAAc,IAAI,UAAU,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,IAAI,OAAO,CAAC;IAChF,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,KAAiB;QAC1C,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;CACF;AA3kBD,0DA2kBC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ContentAddressedStore, ContentAddressedStoreFactory, CreateStoreResult, OpenStoreOptions, StoreIndexBuildStatus, AwaitIndexReadyOptions, StoreScanCursor, StoreScanFilters, StoreScanResult, StoreIdBloomSummary } from "./types";
|
|
2
|
+
import type { StoreEntry, StoreEntryMetadata, StoreEntryType } from "../types";
|
|
3
|
+
import { Logger } from "../logging";
|
|
4
|
+
/**
|
|
5
|
+
* Simple persistent on-disk ContentAddressedStore implementation.
|
|
6
|
+
* Uses metadata files by id and binary content files by contentHash.
|
|
7
|
+
* Supports reset-on-start and optional in-memory indexing.
|
|
8
|
+
*/
|
|
9
|
+
export declare class BasicOnDiskContentAddressedStore implements ContentAddressedStore {
|
|
10
|
+
private readonly dbId;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
private readonly storeRoot;
|
|
13
|
+
private readonly entriesDir;
|
|
14
|
+
private readonly contentDir;
|
|
15
|
+
private readonly metadataIndexPath;
|
|
16
|
+
private readonly indexingEnabled;
|
|
17
|
+
private initPromise;
|
|
18
|
+
private entries;
|
|
19
|
+
private docIndex;
|
|
20
|
+
private contentRefCount;
|
|
21
|
+
private orderedMetadata;
|
|
22
|
+
private indexStatus;
|
|
23
|
+
constructor(dbId: string, logger?: Logger, options?: OpenStoreOptions);
|
|
24
|
+
private initialize;
|
|
25
|
+
private ensureInitialized;
|
|
26
|
+
private clearAllLocalDataInternal;
|
|
27
|
+
private rebuildInMemoryIndexes;
|
|
28
|
+
private tryLoadPersistedIndex;
|
|
29
|
+
private validatePersistedIndexCoverage;
|
|
30
|
+
private persistMetadataIndex;
|
|
31
|
+
private compareMetadata;
|
|
32
|
+
private lowerBoundForCursor;
|
|
33
|
+
private metadataMatchesFilters;
|
|
34
|
+
private insertOrderedMetadata;
|
|
35
|
+
private removeOrderedMetadataById;
|
|
36
|
+
private listEntryFiles;
|
|
37
|
+
private metadataPathForId;
|
|
38
|
+
private contentPathForHash;
|
|
39
|
+
private fileExists;
|
|
40
|
+
private writeFileAtomic;
|
|
41
|
+
private syncParentDirectory;
|
|
42
|
+
private readMetadataById;
|
|
43
|
+
private readMetadataByFileName;
|
|
44
|
+
private listAllMetadata;
|
|
45
|
+
getId(): string;
|
|
46
|
+
putEntries(entries: StoreEntry[]): Promise<void>;
|
|
47
|
+
getEntries(ids: string[]): Promise<StoreEntry[]>;
|
|
48
|
+
hasEntries(ids: string[]): Promise<string[]>;
|
|
49
|
+
findNewEntries(knownIds: string[]): Promise<StoreEntryMetadata[]>;
|
|
50
|
+
findNewEntriesForDoc(knownIds: string[], docId: string): Promise<StoreEntryMetadata[]>;
|
|
51
|
+
findEntries(type: StoreEntryType, creationDateFrom: number | null, creationDateUntil: number | null): Promise<StoreEntryMetadata[]>;
|
|
52
|
+
getAllIds(): Promise<string[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Cursor-based metadata scan for high-volume synchronization.
|
|
55
|
+
* Ordering: createdAt ASC, id ASC.
|
|
56
|
+
*/
|
|
57
|
+
scanEntriesSince(cursor: StoreScanCursor | null, limit?: number, filters?: StoreScanFilters): Promise<StoreScanResult>;
|
|
58
|
+
getIdBloomSummary(): Promise<StoreIdBloomSummary>;
|
|
59
|
+
resolveDependencies(startId: string, options?: Record<string, unknown>): Promise<string[]>;
|
|
60
|
+
purgeDocHistory(docId: string): Promise<void>;
|
|
61
|
+
clearAllLocalData(): Promise<void>;
|
|
62
|
+
awaitIndexReady(_options?: AwaitIndexReadyOptions): Promise<StoreIndexBuildStatus>;
|
|
63
|
+
getIndexBuildStatus(): StoreIndexBuildStatus;
|
|
64
|
+
}
|
|
65
|
+
export declare class BasicOnDiskContentAddressedStoreFactory implements ContentAddressedStoreFactory {
|
|
66
|
+
createStore(dbId: string, options?: OpenStoreOptions): CreateStoreResult;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=BasicOnDiskContentAddressedStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasicOnDiskContentAddressedStore.d.ts","sourceRoot":"","sources":["../../../src/core/appendonlystores/BasicOnDiskContentAddressedStore.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAoC,MAAM,YAAY,CAAC;AAiCtE;;;;GAIG;AACH,qBAAa,gCAAiC,YAAW,qBAAqB;IAC5E,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAA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