mindoodb 0.0.1 → 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.
Files changed (206) hide show
  1. package/README.md +97 -24
  2. package/dist/__mocks__/expo-standard-web-crypto.d.ts +10 -0
  3. package/dist/__mocks__/expo-standard-web-crypto.d.ts.map +1 -0
  4. package/dist/__mocks__/expo-standard-web-crypto.js +22 -0
  5. package/dist/__mocks__/expo-standard-web-crypto.js.map +1 -0
  6. package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.d.ts +8 -0
  7. package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.d.ts.map +1 -0
  8. package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.js +16 -0
  9. package/dist/appendonlystores/BasicOnDiskContentAddressedStoreFactory.js.map +1 -0
  10. package/dist/appendonlystores/InMemoryContentAddressedStoreFactory.d.ts +1 -1
  11. package/dist/appendonlystores/InMemoryContentAddressedStoreFactory.d.ts.map +1 -1
  12. package/dist/appendonlystores/InMemoryContentAddressedStoreFactory.js +2 -2
  13. package/dist/appendonlystores/InMemoryContentAddressedStoreFactory.js.map +1 -1
  14. package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts +19 -2
  15. package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts.map +1 -1
  16. package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js +133 -22
  17. package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js.map +1 -1
  18. package/dist/appendonlystores/network/HttpTransport.d.ts +20 -3
  19. package/dist/appendonlystores/network/HttpTransport.d.ts.map +1 -1
  20. package/dist/appendonlystores/network/HttpTransport.js +136 -21
  21. package/dist/appendonlystores/network/HttpTransport.js.map +1 -1
  22. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts +33 -3
  23. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts.map +1 -1
  24. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js +148 -27
  25. package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js.map +1 -1
  26. package/dist/appendonlystores/network/index.d.ts +1 -1
  27. package/dist/appendonlystores/network/index.d.ts.map +1 -1
  28. package/dist/appendonlystores/network/index.js.map +1 -1
  29. package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.d.ts +61 -0
  30. package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.d.ts.map +1 -0
  31. package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.js +685 -0
  32. package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.js.map +1 -0
  33. package/dist/browser/appendonlystores/IndexedDBContentAddressedStoreFactory.d.ts +25 -0
  34. package/dist/browser/appendonlystores/IndexedDBContentAddressedStoreFactory.d.ts.map +1 -0
  35. package/dist/browser/appendonlystores/IndexedDBContentAddressedStoreFactory.js +41 -0
  36. package/dist/browser/appendonlystores/IndexedDBContentAddressedStoreFactory.js.map +1 -0
  37. package/dist/browser/index.d.ts +5 -0
  38. package/dist/browser/index.d.ts.map +1 -1
  39. package/dist/browser/index.js +13 -1
  40. package/dist/browser/index.js.map +1 -1
  41. package/dist/core/BaseMindooDB.d.ts +38 -4
  42. package/dist/core/BaseMindooDB.d.ts.map +1 -1
  43. package/dist/core/BaseMindooDB.js +810 -329
  44. package/dist/core/BaseMindooDB.js.map +1 -1
  45. package/dist/core/BaseMindooTenant.d.ts +42 -6
  46. package/dist/core/BaseMindooTenant.d.ts.map +1 -1
  47. package/dist/core/BaseMindooTenant.js +259 -93
  48. package/dist/core/BaseMindooTenant.js.map +1 -1
  49. package/dist/core/BaseMindooTenantDirectory.d.ts +3 -1
  50. package/dist/core/BaseMindooTenantDirectory.d.ts.map +1 -1
  51. package/dist/core/BaseMindooTenantDirectory.js +50 -40
  52. package/dist/core/BaseMindooTenantDirectory.js.map +1 -1
  53. package/dist/core/BaseMindooTenantFactory.d.ts +25 -29
  54. package/dist/core/BaseMindooTenantFactory.d.ts.map +1 -1
  55. package/dist/core/BaseMindooTenantFactory.js +175 -73
  56. package/dist/core/BaseMindooTenantFactory.js.map +1 -1
  57. package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.d.ts +68 -0
  58. package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.d.ts.map +1 -0
  59. package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.js +659 -0
  60. package/dist/core/appendonlystores/BasicOnDiskContentAddressedStore.js.map +1 -0
  61. package/dist/core/appendonlystores/InMemoryContentAddressedStore.d.ts +50 -4
  62. package/dist/core/appendonlystores/InMemoryContentAddressedStore.d.ts.map +1 -1
  63. package/dist/core/appendonlystores/InMemoryContentAddressedStore.js +204 -39
  64. package/dist/core/appendonlystores/InMemoryContentAddressedStore.js.map +1 -1
  65. package/dist/core/appendonlystores/bloom.d.ts +85 -0
  66. package/dist/core/appendonlystores/bloom.d.ts.map +1 -0
  67. package/dist/core/appendonlystores/bloom.js +228 -0
  68. package/dist/core/appendonlystores/bloom.js.map +1 -0
  69. package/dist/core/appendonlystores/network/AuthenticationService.d.ts +3 -0
  70. package/dist/core/appendonlystores/network/AuthenticationService.d.ts.map +1 -1
  71. package/dist/core/appendonlystores/network/AuthenticationService.js +21 -17
  72. package/dist/core/appendonlystores/network/AuthenticationService.js.map +1 -1
  73. package/dist/core/appendonlystores/network/NetworkTransport.d.ts +36 -2
  74. package/dist/core/appendonlystores/network/NetworkTransport.d.ts.map +1 -1
  75. package/dist/core/appendonlystores/network/types.d.ts +10 -0
  76. package/dist/core/appendonlystores/network/types.d.ts.map +1 -1
  77. package/dist/core/appendonlystores/network/types.js.map +1 -1
  78. package/dist/core/appendonlystores/types.d.ts +137 -1
  79. package/dist/core/appendonlystores/types.d.ts.map +1 -1
  80. package/dist/core/automerge-adapter.d.ts +15 -0
  81. package/dist/core/automerge-adapter.d.ts.map +1 -0
  82. package/dist/core/automerge-adapter.js +73 -0
  83. package/dist/core/automerge-adapter.js.map +1 -0
  84. package/dist/core/crypto/MindooDocSigner.d.ts +3 -1
  85. package/dist/core/crypto/MindooDocSigner.d.ts.map +1 -1
  86. package/dist/core/crypto/MindooDocSigner.js +9 -5
  87. package/dist/core/crypto/MindooDocSigner.js.map +1 -1
  88. package/dist/core/crypto/RSAEncryption.d.ts +3 -1
  89. package/dist/core/crypto/RSAEncryption.d.ts.map +1 -1
  90. package/dist/core/crypto/RSAEncryption.js +13 -9
  91. package/dist/core/crypto/RSAEncryption.js.map +1 -1
  92. package/dist/core/crypto/pbkdf2Iterations.d.ts +12 -0
  93. package/dist/core/crypto/pbkdf2Iterations.d.ts.map +1 -0
  94. package/dist/core/crypto/pbkdf2Iterations.js +55 -0
  95. package/dist/core/crypto/pbkdf2Iterations.js.map +1 -0
  96. package/dist/core/index.d.ts +7 -2
  97. package/dist/core/index.d.ts.map +1 -1
  98. package/dist/core/index.js +30 -1
  99. package/dist/core/index.js.map +1 -1
  100. package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.d.ts +1 -1
  101. package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.js +2 -2
  102. package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.js.map +1 -1
  103. package/dist/core/indexing/virtualviews/index.d.ts +1 -1
  104. package/dist/core/indexing/virtualviews/index.js +1 -1
  105. package/dist/core/keys/KeyBag.d.ts +36 -13
  106. package/dist/core/keys/KeyBag.d.ts.map +1 -1
  107. package/dist/core/keys/KeyBag.js +96 -31
  108. package/dist/core/keys/KeyBag.js.map +1 -1
  109. package/dist/core/keys/KeyContext.d.ts +4 -0
  110. package/dist/core/keys/KeyContext.d.ts.map +1 -0
  111. package/dist/core/keys/KeyContext.js +11 -0
  112. package/dist/core/keys/KeyContext.js.map +1 -0
  113. package/dist/core/logging/LogLevel.d.ts +21 -0
  114. package/dist/core/logging/LogLevel.d.ts.map +1 -0
  115. package/dist/core/logging/LogLevel.js +56 -0
  116. package/dist/core/logging/LogLevel.js.map +1 -0
  117. package/dist/core/logging/Logger.d.ts +37 -0
  118. package/dist/core/logging/Logger.d.ts.map +1 -0
  119. package/dist/core/logging/Logger.js +3 -0
  120. package/dist/core/logging/Logger.js.map +1 -0
  121. package/dist/core/logging/MindooLogger.d.ts +28 -0
  122. package/dist/core/logging/MindooLogger.d.ts.map +1 -0
  123. package/dist/core/logging/MindooLogger.js +217 -0
  124. package/dist/core/logging/MindooLogger.js.map +1 -0
  125. package/dist/core/logging/index.d.ts +4 -0
  126. package/dist/core/logging/index.d.ts.map +1 -0
  127. package/dist/core/logging/index.js +10 -0
  128. package/dist/core/logging/index.js.map +1 -0
  129. package/dist/core/types.d.ts +313 -77
  130. package/dist/core/types.d.ts.map +1 -1
  131. package/dist/core/types.js +2 -0
  132. package/dist/core/types.js.map +1 -1
  133. package/dist/core/uri/MindooURI.d.ts +58 -0
  134. package/dist/core/uri/MindooURI.d.ts.map +1 -0
  135. package/dist/core/uri/MindooURI.js +169 -0
  136. package/dist/core/uri/MindooURI.js.map +1 -0
  137. package/dist/core/userid/index.d.ts +0 -10
  138. package/dist/core/userid/index.d.ts.map +1 -1
  139. package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts +541 -0
  140. package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts.map +1 -0
  141. package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js +1334 -0
  142. package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js.map +1 -0
  143. package/dist/node/index.d.ts +1 -0
  144. package/dist/node/index.d.ts.map +1 -1
  145. package/dist/node/index.js +5 -1
  146. package/dist/node/index.js.map +1 -1
  147. package/dist/reactnative/crypto/AESAdapter.d.ts +18 -0
  148. package/dist/reactnative/crypto/AESAdapter.d.ts.map +1 -0
  149. package/dist/reactnative/crypto/AESAdapter.js +112 -0
  150. package/dist/reactnative/crypto/AESAdapter.js.map +1 -0
  151. package/dist/reactnative/crypto/Ed25519Adapter.d.ts +34 -0
  152. package/dist/reactnative/crypto/Ed25519Adapter.d.ts.map +1 -0
  153. package/dist/reactnative/crypto/Ed25519Adapter.js +386 -0
  154. package/dist/reactnative/crypto/Ed25519Adapter.js.map +1 -0
  155. package/dist/reactnative/crypto/ExpoGoCryptoAdapter.d.ts +23 -0
  156. package/dist/reactnative/crypto/ExpoGoCryptoAdapter.d.ts.map +1 -0
  157. package/dist/reactnative/crypto/ExpoGoCryptoAdapter.js +51 -0
  158. package/dist/reactnative/crypto/ExpoGoCryptoAdapter.js.map +1 -0
  159. package/dist/reactnative/crypto/HMACAdapter.d.ts +13 -0
  160. package/dist/reactnative/crypto/HMACAdapter.d.ts.map +1 -0
  161. package/dist/reactnative/crypto/HMACAdapter.js +50 -0
  162. package/dist/reactnative/crypto/HMACAdapter.js.map +1 -0
  163. package/dist/reactnative/crypto/KeyFormatConverter.d.ts +21 -0
  164. package/dist/reactnative/crypto/KeyFormatConverter.d.ts.map +1 -0
  165. package/dist/reactnative/crypto/KeyFormatConverter.js +72 -0
  166. package/dist/reactnative/crypto/KeyFormatConverter.js.map +1 -0
  167. package/dist/reactnative/crypto/PBKDF2Adapter.d.ts +19 -0
  168. package/dist/reactnative/crypto/PBKDF2Adapter.d.ts.map +1 -0
  169. package/dist/reactnative/crypto/PBKDF2Adapter.js +67 -0
  170. package/dist/reactnative/crypto/PBKDF2Adapter.js.map +1 -0
  171. package/dist/reactnative/crypto/QuickCryptoAdapter.d.ts +37 -0
  172. package/dist/reactnative/crypto/QuickCryptoAdapter.d.ts.map +1 -0
  173. package/dist/reactnative/crypto/QuickCryptoAdapter.js +72 -0
  174. package/dist/reactnative/crypto/QuickCryptoAdapter.js.map +1 -0
  175. package/dist/reactnative/crypto/RSAAdapter.d.ts +38 -0
  176. package/dist/reactnative/crypto/RSAAdapter.d.ts.map +1 -0
  177. package/dist/reactnative/crypto/RSAAdapter.js +184 -0
  178. package/dist/reactnative/crypto/RSAAdapter.js.map +1 -0
  179. package/dist/reactnative/crypto/ReactNativeCryptoAdapter.d.ts +33 -0
  180. package/dist/reactnative/crypto/ReactNativeCryptoAdapter.d.ts.map +1 -0
  181. package/dist/reactnative/crypto/ReactNativeCryptoAdapter.js +61 -0
  182. package/dist/reactnative/crypto/ReactNativeCryptoAdapter.js.map +1 -0
  183. package/dist/reactnative/crypto/SHA256Adapter.d.ts +9 -0
  184. package/dist/reactnative/crypto/SHA256Adapter.d.ts.map +1 -0
  185. package/dist/reactnative/crypto/SHA256Adapter.js +29 -0
  186. package/dist/reactnative/crypto/SHA256Adapter.js.map +1 -0
  187. package/dist/reactnative/crypto/SubtleCryptoPolyfill.d.ts +63 -0
  188. package/dist/reactnative/crypto/SubtleCryptoPolyfill.d.ts.map +1 -0
  189. package/dist/reactnative/crypto/SubtleCryptoPolyfill.js +350 -0
  190. package/dist/reactnative/crypto/SubtleCryptoPolyfill.js.map +1 -0
  191. package/dist/reactnative/index.d.ts +8 -0
  192. package/dist/reactnative/index.d.ts.map +1 -0
  193. package/dist/reactnative/index.js +38 -0
  194. package/dist/reactnative/index.js.map +1 -0
  195. package/package.json +51 -6
  196. package/patches/PATCHES.md +111 -0
  197. package/patches/react-native+0.76.9.patch +34 -0
  198. package/patches/react-native-quick-crypto+1.0.7.patch +42 -0
  199. package/scripts/cli.js +21 -0
  200. package/scripts/setup-react-native.js +228 -0
  201. package/templates/reactnative/App.js +252 -0
  202. package/templates/reactnative/app.json +29 -0
  203. package/templates/reactnative/babel.config.js +6 -0
  204. package/templates/reactnative/index.js +26 -0
  205. package/templates/reactnative/metro.config.snippet.js +39 -0
  206. package/templates/reactnative/mindoodb-polyfills.js +116 -0
@@ -1,7 +1,8 @@
1
- import { MindooTenantFactory, MindooTenant, EncryptedPrivateKey, ContentAddressedStoreFactory, SigningKeyPair, EncryptionKeyPair } from "./types";
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";
5
+ import { Logger } from "./logging";
5
6
  /**
6
7
  * BaseTenantFactory is a platform-agnostic implementation of TenantFactory
7
8
  * that creates and manages tenants and users.
@@ -12,31 +13,14 @@ import { KeyBag } from "./keys/KeyBag";
12
13
  export declare class BaseMindooTenantFactory implements MindooTenantFactory {
13
14
  private cryptoAdapter;
14
15
  private storeFactory;
15
- constructor(storeFactory: ContentAddressedStoreFactory, cryptoAdapter: CryptoAdapter);
16
+ private logger;
17
+ constructor(storeFactory: ContentAddressedStoreFactory, cryptoAdapter: CryptoAdapter, logger?: Logger);
16
18
  getCryptoAdapter(): CryptoAdapter;
17
19
  /**
18
- * Create a new tenant from scratch with a new tenant encryption key.
19
- *
20
- * The administration public key must be created beforehand using createSigningKeyPair()
21
- * and passed to this method.
22
- *
23
- * The administration encryption public key must be created using createEncryptionKeyPair()
24
- * and is used to encrypt sensitive data in the directory that only admins can decrypt.
25
- *
26
- * @param tenantId The ID of the tenant
27
- * @param administrationPublicKey The administration public key (Ed25519, PEM format) created using createSigningKeyPair()
28
- * @param administrationEncryptionPublicKey The administration encryption public key (RSA-OAEP, PEM format) created using createEncryptionKeyPair()
29
- * @param tenantEncryptionKeyPassword The password to decrypt the tenant encryption private key
30
- * @param currentUser The current user's private user ID (required for tenant operations)
31
- * @param currentUserPassword The password to decrypt the current user's private keys
32
- * @param keyBag The KeyBag instance for storing and loading named encrypted keys
33
- * @return The new tenant
20
+ * Opens an existing tenant.
34
21
  */
35
- createTenant(tenantId: string, administrationPublicKey: string, administrationEncryptionPublicKey: string, tenantEncryptionKeyPassword: string, currentUser: PrivateUserId, currentUserPassword: string, keyBag: KeyBag): Promise<MindooTenant>;
36
- /**
37
- * Opens an existing tenant with previously created keys.
38
- */
39
- 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>;
40
24
  /**
41
25
  * Creates a new user with separate signing and encryption key pairs.
42
26
  */
@@ -51,12 +35,6 @@ export declare class BaseMindooTenantFactory implements MindooTenantFactory {
51
35
  * for signature verification by other users.
52
36
  */
53
37
  createSigningKeyPair(password: string): Promise<SigningKeyPair>;
54
- /**
55
- * Creates a new encrypted symmetric key (AES-256) for document encryption.
56
- * Symmetric keys are shared secrets - anyone with the key can both encrypt and decrypt.
57
- * For user-to-user encryption where only the recipient can decrypt, use createEncryptionKeyPair() instead.
58
- */
59
- createSymmetricEncryptedPrivateKey(password: string): Promise<EncryptedPrivateKey>;
60
38
  /**
61
39
  * Creates a new asymmetric encryption key pair (RSA-OAEP) for user-to-user encryption.
62
40
  * Returns both the public and encrypted private key.
@@ -65,6 +43,23 @@ export declare class BaseMindooTenantFactory implements MindooTenantFactory {
65
43
  * and only User B (with the private key) can decrypt it.
66
44
  */
67
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>;
68
63
  /**
69
64
  * Internal method to encrypt a private key using password-based key derivation.
70
65
  * This is the reverse of BaseMindooTenant.decryptPrivateKey().
@@ -75,6 +70,7 @@ export declare class BaseMindooTenantFactory implements MindooTenantFactory {
75
70
  * @returns The encrypted private key
76
71
  */
77
72
  private encryptPrivateKey;
73
+ private assertRequiredKeysInKeyBag;
78
74
  /**
79
75
  * Convert ArrayBuffer to PEM format
80
76
  */
@@ -1 +1 @@
1
- {"version":3,"file":"BaseMindooTenantFactory.d.ts","sourceRoot":"","sources":["../../src/core/BaseMindooTenantFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,4BAA4B,EAC5B,cAAc,EACd,iBAAiB,EAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,mBAAmB;IACjE,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,YAAY,CAA+B;gBAEvC,YAAY,EAAE,4BAA4B,EAAE,aAAa,EAAE,aAAa;IAKpF,gBAAgB,IAAI,aAAa;IAIjC;;;;;;;;;;;;;;;;;OAiBG;IACG,YAAY,CAChB,QAAQ,EAAE,MAAM,EAChB,uBAAuB,EAAE,MAAM,EAC/B,iCAAiC,EAAE,MAAM,EACzC,2BAA2B,EAAE,MAAM,EACnC,WAAW,EAAE,aAAa,EAC1B,mBAAmB,EAAE,MAAM,EAC3B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,YAAY,CAAC;IAsCxB;;OAEG;IACG,kBAAkB,CACtB,QAAQ,EAAE,MAAM,EAChB,0BAA0B,EAAE,mBAAmB,EAC/C,2BAA2B,EAAE,MAAM,EACnC,uBAAuB,EAAE,MAAM,EAC/B,i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,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,7 +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");
8
+ const logging_1 = require("./logging");
9
+ const MindooURI_1 = require("./uri/MindooURI");
5
10
  /**
6
11
  * BaseTenantFactory is a platform-agnostic implementation of TenantFactory
7
12
  * that creates and manages tenants and users.
@@ -10,53 +15,48 @@ const BaseMindooTenant_1 = require("./BaseMindooTenant");
10
15
  * allowing the same implementation to work in browsers and Node.js.
11
16
  */
12
17
  class BaseMindooTenantFactory {
13
- constructor(storeFactory, cryptoAdapter) {
18
+ constructor(storeFactory, cryptoAdapter, logger) {
14
19
  this.storeFactory = storeFactory;
15
20
  this.cryptoAdapter = cryptoAdapter;
21
+ // Create root logger if not provided (for backward compatibility)
22
+ this.logger =
23
+ logger ||
24
+ new logging_1.MindooLogger((0, logging_1.getDefaultLogLevel)(), "MindooTenantFactory", true);
16
25
  }
17
26
  getCryptoAdapter() {
18
27
  return this.cryptoAdapter;
19
28
  }
20
- /**
21
- * Create a new tenant from scratch with a new tenant encryption key.
22
- *
23
- * The administration public key must be created beforehand using createSigningKeyPair()
24
- * and passed to this method.
25
- *
26
- * The administration encryption public key must be created using createEncryptionKeyPair()
27
- * and is used to encrypt sensitive data in the directory that only admins can decrypt.
28
- *
29
- * @param tenantId The ID of the tenant
30
- * @param administrationPublicKey The administration public key (Ed25519, PEM format) created using createSigningKeyPair()
31
- * @param administrationEncryptionPublicKey The administration encryption public key (RSA-OAEP, PEM format) created using createEncryptionKeyPair()
32
- * @param tenantEncryptionKeyPassword The password to decrypt the tenant encryption private key
33
- * @param currentUser The current user's private user ID (required for tenant operations)
34
- * @param currentUserPassword The password to decrypt the current user's private keys
35
- * @param keyBag The KeyBag instance for storing and loading named encrypted keys
36
- * @return The new tenant
37
- */
38
- async createTenant(tenantId, administrationPublicKey, administrationEncryptionPublicKey, tenantEncryptionKeyPassword, currentUser, currentUserPassword, keyBag) {
39
- console.log(`[BaseTenantFactory] Creating tenant: ${tenantId}`);
40
- const subtle = this.cryptoAdapter.getSubtle();
41
- // Generate tenant encryption key (AES-256)
42
- const tenantEncryptionKey = await subtle.generateKey({
43
- name: "AES-GCM",
44
- length: 256,
45
- }, true, // extractable
46
- ["encrypt", "decrypt"]);
47
- // Export the tenant encryption key material
48
- const tenantKeyMaterial = await subtle.exportKey("raw", tenantEncryptionKey);
49
- const tenantKeyBytes = new Uint8Array(tenantKeyMaterial);
50
- // Encrypt the tenant encryption key with password
51
- const encryptedTenantKey = await this.encryptPrivateKey(tenantKeyBytes, tenantEncryptionKeyPassword, "default");
52
- return this.openTenantWithKeys(tenantId, encryptedTenantKey, tenantEncryptionKeyPassword, administrationPublicKey, administrationEncryptionPublicKey, currentUser, currentUserPassword, keyBag);
53
- }
54
- /**
55
- * Opens an existing tenant with previously created keys.
56
- */
57
- async openTenantWithKeys(tenantId, tenantEncryptionPrivateKey, tenantEncryptionKeyPassword, administrationPublicKey, administrationEncryptionPublicKey, currentUser, currentUserPassword, keyBag) {
58
- console.log(`[BaseTenantFactory] Opening tenant: ${tenantId}`);
59
- const tenant = new BaseMindooTenant_1.BaseMindooTenant(this, tenantId, tenantEncryptionPrivateKey, tenantEncryptionKeyPassword, administrationPublicKey, administrationEncryptionPublicKey, currentUser, currentUserPassword, keyBag, this.storeFactory, this.cryptoAdapter);
29
+ async openTenant(tenantId, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
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);
58
+ const tenantLogger = this.logger.createChild(`Tenant:${tenantId}`);
59
+ const tenant = new BaseMindooTenant_1.BaseMindooTenant(this, tenantId, administrationPublicKey, administrationEncryptionPublicKey, currentUser, currentUserPassword, keyBag, this.storeFactory, this.cryptoAdapter, tenantLogger, options?.additionalTrustedKeys);
60
60
  // Initialize the tenant
61
61
  await tenant.initialize();
62
62
  return tenant;
@@ -65,23 +65,41 @@ class BaseMindooTenantFactory {
65
65
  * Creates a new user with separate signing and encryption key pairs.
66
66
  */
67
67
  async createUserId(username, password) {
68
- console.log(`[BaseTenantFactory] Creating user ID: ${username}`);
68
+ this.logger.debug(`Creating user ID: ${username}`);
69
+ console.log('[createUserId] Starting createUserId for:', username);
70
+ const startTime = Date.now();
69
71
  const subtle = this.cryptoAdapter.getSubtle();
72
+ console.log('[createUserId] Got subtle crypto API');
70
73
  // Generate signing key pair (Ed25519)
74
+ console.log('[createUserId] Step 1: Generating Ed25519 signing key pair...');
75
+ const signingKeyPairStart = Date.now();
71
76
  const signingKeyPair = await subtle.generateKey({
72
77
  name: "Ed25519",
73
78
  }, true, // extractable
74
79
  ["sign", "verify"]);
80
+ console.log('[createUserId] Step 1: ✓ Ed25519 signing key pair generated in', Date.now() - signingKeyPairStart, 'ms');
75
81
  // Export signing public key (PEM format)
82
+ console.log('[createUserId] Step 2: Exporting signing public key...');
83
+ const exportSigningPublicStart = Date.now();
76
84
  const signingPublicKeyBuffer = await subtle.exportKey("spki", signingKeyPair.publicKey);
77
85
  const signingPublicKey = this.arrayBufferToPEM(signingPublicKeyBuffer, "PUBLIC KEY");
86
+ console.log('[createUserId] Step 2: ✓ Signing public key exported in', Date.now() - exportSigningPublicStart, 'ms');
78
87
  // Export signing private key
88
+ console.log('[createUserId] Step 3: Exporting signing private key...');
89
+ const exportSigningPrivateStart = Date.now();
79
90
  const signingPrivateKeyBuffer = await subtle.exportKey("pkcs8", signingKeyPair.privateKey);
80
91
  const signingPrivateKeyBytes = new Uint8Array(signingPrivateKeyBuffer);
92
+ console.log('[createUserId] Step 3: ✓ Signing private key exported in', Date.now() - exportSigningPrivateStart, 'ms');
81
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();
82
97
  const encryptedSigningKey = await this.encryptPrivateKey(signingPrivateKeyBytes, password, "signing");
98
+ console.log('[createUserId] Step 4: ✓ Signing private key encrypted in', Date.now() - encryptSigningStart, 'ms');
83
99
  // Generate encryption key pair (RSA-OAEP, 3072 bits for state-of-the-art security)
84
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();
85
103
  const encryptionKeyPair = await subtle.generateKey({
86
104
  name: "RSA-OAEP",
87
105
  modulusLength: 3072,
@@ -89,18 +107,28 @@ class BaseMindooTenantFactory {
89
107
  hash: "SHA-256",
90
108
  }, true, // extractable
91
109
  ["encrypt", "decrypt"]);
110
+ console.log('[createUserId] Step 5: ✓ RSA-3072 encryption key pair generated in', Date.now() - rsaKeyGenStart, 'ms');
92
111
  // Export encryption public key (PEM format)
112
+ console.log('[createUserId] Step 6: Exporting encryption public key...');
113
+ const exportEncryptionPublicStart = Date.now();
93
114
  const encryptionPublicKeyBuffer = await subtle.exportKey("spki", encryptionKeyPair.publicKey);
94
115
  const encryptionPublicKey = this.arrayBufferToPEM(encryptionPublicKeyBuffer, "PUBLIC KEY");
116
+ console.log('[createUserId] Step 6: ✓ Encryption public key exported in', Date.now() - exportEncryptionPublicStart, 'ms');
95
117
  // Export encryption private key
118
+ console.log('[createUserId] Step 7: Exporting encryption private key...');
119
+ const exportEncryptionPrivateStart = Date.now();
96
120
  const encryptionPrivateKeyBuffer = await subtle.exportKey("pkcs8", encryptionKeyPair.privateKey);
97
121
  const encryptionPrivateKeyBytes = new Uint8Array(encryptionPrivateKeyBuffer);
122
+ console.log('[createUserId] Step 7: ✓ Encryption private key exported in', Date.now() - exportEncryptionPrivateStart, 'ms');
98
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();
99
126
  const encryptedEncryptionKey = await this.encryptPrivateKey(encryptionPrivateKeyBytes, password, "encryption");
127
+ console.log('[createUserId] Step 8: ✓ Encryption private key encrypted in', Date.now() - encryptEncryptionStart, 'ms');
100
128
  // Create PrivateUserId
129
+ console.log('[createUserId] Step 9: Creating PrivateUserId object...');
101
130
  const privateUserId = {
102
131
  username,
103
- administrationSignature: "", // Will be set when user is registered by an admin
104
132
  userSigningKeyPair: {
105
133
  publicKey: signingPublicKey,
106
134
  privateKey: encryptedSigningKey,
@@ -110,7 +138,9 @@ class BaseMindooTenantFactory {
110
138
  privateKey: encryptedEncryptionKey,
111
139
  },
112
140
  };
113
- console.log(`[BaseTenantFactory] Created user ID: ${username}`);
141
+ const totalTime = Date.now() - startTime;
142
+ console.log('[createUserId] ✓ User ID created successfully in', totalTime, 'ms total');
143
+ this.logger.debug(`Created user ID: ${username}`);
114
144
  return privateUserId;
115
145
  }
116
146
  /**
@@ -119,7 +149,6 @@ class BaseMindooTenantFactory {
119
149
  toPublicUserId(privateUserId) {
120
150
  return {
121
151
  username: privateUserId.username,
122
- administrationSignature: privateUserId.administrationSignature,
123
152
  userSigningPublicKey: privateUserId.userSigningKeyPair.publicKey,
124
153
  userEncryptionPublicKey: privateUserId.userEncryptionKeyPair.publicKey,
125
154
  };
@@ -130,7 +159,7 @@ class BaseMindooTenantFactory {
130
159
  * for signature verification by other users.
131
160
  */
132
161
  async createSigningKeyPair(password) {
133
- console.log(`[BaseTenantFactory] Creating signing key pair`);
162
+ this.logger.debug(`Creating signing key pair`);
134
163
  const subtle = this.cryptoAdapter.getSubtle();
135
164
  // Generate a new Ed25519 signing key pair
136
165
  const keyPair = await subtle.generateKey({
@@ -145,35 +174,12 @@ class BaseMindooTenantFactory {
145
174
  const keyBytes = new Uint8Array(privateKeyBuffer);
146
175
  // Encrypt the key material using the shared helper
147
176
  const encryptedKey = await this.encryptPrivateKey(keyBytes, password, "signing");
148
- console.log(`[BaseTenantFactory] Created signing key pair`);
177
+ this.logger.debug(`Created signing key pair`);
149
178
  return {
150
179
  publicKey,
151
180
  privateKey: encryptedKey,
152
181
  };
153
182
  }
154
- /**
155
- * Creates a new encrypted symmetric key (AES-256) for document encryption.
156
- * Symmetric keys are shared secrets - anyone with the key can both encrypt and decrypt.
157
- * For user-to-user encryption where only the recipient can decrypt, use createEncryptionKeyPair() instead.
158
- */
159
- async createSymmetricEncryptedPrivateKey(password) {
160
- console.log(`[BaseTenantFactory] Creating encrypted symmetric key`);
161
- const subtle = this.cryptoAdapter.getSubtle();
162
- // Generate a new AES-256 key
163
- const key = await subtle.generateKey({
164
- name: "AES-GCM",
165
- length: 256,
166
- }, true, // extractable
167
- ["encrypt", "decrypt"]);
168
- // Export the key material
169
- const keyMaterial = await subtle.exportKey("raw", key);
170
- const keyBytes = new Uint8Array(keyMaterial);
171
- // Encrypt the key material using the shared helper
172
- // Use "default" as the salt string to match how tenant encryption keys are decrypted
173
- const encryptedKey = await this.encryptPrivateKey(keyBytes, password, "default");
174
- console.log(`[BaseTenantFactory] Created encrypted symmetric key`);
175
- return encryptedKey;
176
- }
177
183
  /**
178
184
  * Creates a new asymmetric encryption key pair (RSA-OAEP) for user-to-user encryption.
179
185
  * Returns both the public and encrypted private key.
@@ -182,7 +188,7 @@ class BaseMindooTenantFactory {
182
188
  * and only User B (with the private key) can decrypt it.
183
189
  */
184
190
  async createEncryptionKeyPair(password) {
185
- console.log(`[BaseTenantFactory] Creating encryption key pair`);
191
+ this.logger.debug(`Creating encryption key pair`);
186
192
  const subtle = this.cryptoAdapter.getSubtle();
187
193
  // Generate a new RSA-OAEP encryption key pair (3072 bits for state-of-the-art security)
188
194
  // NIST recommends 3072-bit RSA for new applications (security through 2030+)
@@ -202,12 +208,81 @@ class BaseMindooTenantFactory {
202
208
  // Encrypt the private key material using the shared helper
203
209
  // Use "encryption" as the salt string (same as user encryption keys)
204
210
  const encryptedKey = await this.encryptPrivateKey(privateKeyBytes, password, "encryption");
205
- console.log(`[BaseTenantFactory] Created encryption key pair`);
211
+ this.logger.debug(`Created encryption key pair`);
206
212
  return {
207
213
  publicKey,
208
214
  privateKey: encryptedKey,
209
215
  };
210
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
+ }
211
286
  /**
212
287
  * Internal method to encrypt a private key using password-based key derivation.
213
288
  * This is the reverse of BaseMindooTenant.decryptPrivateKey().
@@ -218,24 +293,33 @@ class BaseMindooTenantFactory {
218
293
  * @returns The encrypted private key
219
294
  */
220
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();
221
298
  const subtle = this.cryptoAdapter.getSubtle();
222
299
  // Bind getRandomValues to maintain 'this' context
223
300
  const randomValues = this.cryptoAdapter.getRandomValues.bind(this.cryptoAdapter);
224
301
  // Generate random salt and IV
302
+ console.log('[encryptPrivateKey] Generating random salt and IV...');
225
303
  const saltArray = new Uint8Array(16); // 16 bytes salt
226
304
  randomValues(saltArray);
227
305
  const salt = new Uint8Array(saltArray);
228
306
  const ivArray = new Uint8Array(12); // 12 bytes for AES-GCM
229
307
  randomValues(ivArray);
230
308
  const iv = new Uint8Array(ivArray);
309
+ console.log('[encryptPrivateKey] ✓ Salt and IV generated');
231
310
  // Combine salt with saltString for key derivation (same as decryption)
232
311
  const saltStringBytes = new TextEncoder().encode(saltString);
233
312
  const combinedSalt = new Uint8Array(salt.length + saltStringBytes.length);
234
313
  combinedSalt.set(salt);
235
314
  combinedSalt.set(saltStringBytes, salt.length);
236
315
  // Derive encryption key from password using PBKDF2
316
+ console.log('[encryptPrivateKey] Importing password key...');
317
+ const importKeyStart = Date.now();
237
318
  const passwordKey = await subtle.importKey("raw", new TextEncoder().encode(password), "PBKDF2", false, ["deriveBits", "deriveKey"]);
238
- const iterations = 310000; // OWASP-recommended PBKDF2 iterations for PBKDF2-SHA256
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();
239
323
  const derivedKey = await subtle.deriveKey({
240
324
  name: "PBKDF2",
241
325
  salt: combinedSalt,
@@ -245,12 +329,16 @@ class BaseMindooTenantFactory {
245
329
  name: "AES-GCM",
246
330
  length: 256,
247
331
  }, false, ["encrypt"]);
332
+ console.log('[encryptPrivateKey] ✓ Key derived in', Date.now() - deriveKeyStart, 'ms');
248
333
  // Encrypt the private key
334
+ console.log('[encryptPrivateKey] Encrypting private key data...');
335
+ const encryptStart = Date.now();
249
336
  const encrypted = await subtle.encrypt({
250
337
  name: "AES-GCM",
251
338
  iv: iv,
252
339
  tagLength: 128,
253
340
  }, derivedKey, privateKeyBytes.buffer);
341
+ console.log('[encryptPrivateKey] ✓ Private key encrypted in', Date.now() - encryptStart, 'ms');
254
342
  // Extract ciphertext and tag from encrypted data
255
343
  // AES-GCM appends the tag at the end
256
344
  const encryptedArray = new Uint8Array(encrypted);
@@ -265,8 +353,22 @@ class BaseMindooTenantFactory {
265
353
  salt: this.uint8ArrayToBase64(salt),
266
354
  iterations: iterations,
267
355
  };
356
+ const totalTime = Date.now() - startTime;
357
+ console.log(`[encryptPrivateKey] ✓ Encryption completed in ${totalTime}ms total`);
268
358
  return encryptedKey;
269
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
+ }
270
372
  /**
271
373
  * Convert ArrayBuffer to PEM format
272
374
  */
@@ -1 +1 @@
1
- {"version":3,"file":"BaseMindooTenantFactory.js","sourceRoot":"","sources":["../../src/core/BaseMindooTenantFactory.ts"],"names":[],"mappings":";;;AASA,yDAAsD;AAItD;;;;;;GAMG;AACH,MAAa,uBAAuB;IAIlC,YAAY,YAA0C,EAAE,aAA4B;QAClF,IAAI,CA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;QACpE,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACb,6DAA6D,2BAAmB,MAAM;gBACpF,oDAAoD,2BAAmB,4CAA4C,2BAAmB,wCAAwC,CACjL,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACK,gBAAgB,CAAC,MAAmB,EAAE,IAAY;QACxD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACK,eAAe,CAAC,KAAiB,EAAE,IAAY;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,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