mindoodb 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-server.md +1001 -0
- package/README.md +89 -28
- 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 +30 -1
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.d.ts.map +1 -1
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js +152 -5
- package/dist/appendonlystores/network/ClientNetworkContentAddressedStore.js.map +1 -1
- package/dist/appendonlystores/network/HttpTransport.d.ts +17 -2
- package/dist/appendonlystores/network/HttpTransport.d.ts.map +1 -1
- package/dist/appendonlystores/network/HttpTransport.js +129 -0
- package/dist/appendonlystores/network/HttpTransport.js.map +1 -1
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts +22 -2
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.d.ts.map +1 -1
- package/dist/appendonlystores/network/ServerNetworkContentAddressedStore.js +110 -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 +65 -0
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.d.ts.map +1 -0
- package/dist/browser/appendonlystores/IndexedDBContentAddressedStore.js +741 -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/cache/IndexedDBLocalCacheStore.d.ts +21 -0
- package/dist/browser/cache/IndexedDBLocalCacheStore.d.ts.map +1 -0
- package/dist/browser/cache/IndexedDBLocalCacheStore.js +106 -0
- package/dist/browser/cache/IndexedDBLocalCacheStore.js.map +1 -0
- package/dist/browser/index.d.ts +8 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +21 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/core/BaseMindooDB.d.ts +115 -13
- package/dist/core/BaseMindooDB.d.ts.map +1 -1
- package/dist/core/BaseMindooDB.js +1232 -269
- package/dist/core/BaseMindooDB.js.map +1 -1
- package/dist/core/BaseMindooTenant.d.ts +69 -6
- package/dist/core/BaseMindooTenant.d.ts.map +1 -1
- package/dist/core/BaseMindooTenant.js +302 -109
- package/dist/core/BaseMindooTenant.js.map +1 -1
- package/dist/core/BaseMindooTenantDirectory.d.ts +13 -10
- package/dist/core/BaseMindooTenantDirectory.d.ts.map +1 -1
- package/dist/core/BaseMindooTenantDirectory.js +144 -27
- package/dist/core/BaseMindooTenantDirectory.js.map +1 -1
- package/dist/core/BaseMindooTenantFactory.d.ts +27 -29
- package/dist/core/BaseMindooTenantFactory.d.ts.map +1 -1
- package/dist/core/BaseMindooTenantFactory.js +185 -112
- package/dist/core/BaseMindooTenantFactory.js.map +1 -1
- package/dist/core/MindooDBServerAdmin.d.ts +238 -0
- package/dist/core/MindooDBServerAdmin.d.ts.map +1 -0
- package/dist/core/MindooDBServerAdmin.js +345 -0
- package/dist/core/MindooDBServerAdmin.js.map +1 -0
- 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 +45 -3
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.d.ts.map +1 -1
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.js +184 -23
- package/dist/core/appendonlystores/InMemoryContentAddressedStore.js.map +1 -1
- package/dist/core/appendonlystores/MaterializationPlanner.d.ts +49 -0
- package/dist/core/appendonlystores/MaterializationPlanner.d.ts.map +1 -0
- package/dist/core/appendonlystores/MaterializationPlanner.js +325 -0
- package/dist/core/appendonlystores/MaterializationPlanner.js.map +1 -0
- 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 +37 -2
- package/dist/core/appendonlystores/network/NetworkTransport.d.ts.map +1 -1
- package/dist/core/appendonlystores/network/types.d.ts +12 -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 +206 -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/cache/CacheManager.d.ts +75 -0
- package/dist/core/cache/CacheManager.d.ts.map +1 -0
- package/dist/core/cache/CacheManager.js +101 -0
- package/dist/core/cache/CacheManager.js.map +1 -0
- package/dist/core/cache/EncryptedLocalCacheStore.d.ts +41 -0
- package/dist/core/cache/EncryptedLocalCacheStore.d.ts.map +1 -0
- package/dist/core/cache/EncryptedLocalCacheStore.js +120 -0
- package/dist/core/cache/EncryptedLocalCacheStore.js.map +1 -0
- package/dist/core/cache/LocalCacheStore.d.ts +50 -0
- package/dist/core/cache/LocalCacheStore.d.ts.map +1 -0
- package/dist/core/cache/LocalCacheStore.js +39 -0
- package/dist/core/cache/LocalCacheStore.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/crypto/privateKeyEncryption.d.ts +5 -0
- package/dist/core/crypto/privateKeyEncryption.d.ts.map +1 -0
- package/dist/core/crypto/privateKeyEncryption.js +87 -0
- package/dist/core/crypto/privateKeyEncryption.js.map +1 -0
- package/dist/core/index.d.ts +18 -6
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +42 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.d.ts +4 -1
- package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.js +39 -11
- package/dist/core/indexing/virtualviews/MindooDBVirtualViewDataProvider.js.map +1 -1
- package/dist/core/indexing/virtualviews/ViewEntrySortKeyComparator.d.ts +1 -0
- package/dist/core/indexing/virtualviews/ViewEntrySortKeyComparator.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/ViewEntrySortKeyComparator.js +3 -0
- package/dist/core/indexing/virtualviews/ViewEntrySortKeyComparator.js.map +1 -1
- package/dist/core/indexing/virtualviews/VirtualView.d.ts +43 -0
- package/dist/core/indexing/virtualviews/VirtualView.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/VirtualView.js +173 -0
- package/dist/core/indexing/virtualviews/VirtualView.js.map +1 -1
- package/dist/core/indexing/virtualviews/VirtualViewEntryData.d.ts +7 -0
- package/dist/core/indexing/virtualviews/VirtualViewEntryData.d.ts.map +1 -1
- package/dist/core/indexing/virtualviews/VirtualViewEntryData.js +28 -0
- package/dist/core/indexing/virtualviews/VirtualViewEntryData.js.map +1 -1
- package/dist/core/keys/KeyBag.d.ts +56 -12
- package/dist/core/keys/KeyBag.d.ts.map +1 -1
- package/dist/core/keys/KeyBag.js +156 -70
- 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 +17 -0
- package/dist/core/keys/KeyContext.js.map +1 -0
- package/dist/core/types.d.ts +512 -60
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +9 -1
- 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/core/utils/idGeneration.d.ts.map +1 -1
- package/dist/core/utils/idGeneration.js +37 -3
- package/dist/core/utils/idGeneration.js.map +1 -1
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts +544 -0
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.d.ts.map +1 -0
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js +1358 -0
- package/dist/node/appendonlystores/BasicOnDiskContentAddressedStore.js.map +1 -0
- package/dist/node/attachments/writeAttachmentToFile.d.ts +15 -0
- package/dist/node/attachments/writeAttachmentToFile.d.ts.map +1 -0
- package/dist/node/attachments/writeAttachmentToFile.js +73 -0
- package/dist/node/attachments/writeAttachmentToFile.js.map +1 -0
- package/dist/node/cache/FileSystemLocalCacheStore.d.ts +17 -0
- package/dist/node/cache/FileSystemLocalCacheStore.d.ts.map +1 -0
- package/dist/node/cache/FileSystemLocalCacheStore.js +128 -0
- package/dist/node/cache/FileSystemLocalCacheStore.js.map +1 -0
- package/dist/node/cli/change-identity-password.d.ts +7 -0
- package/dist/node/cli/change-identity-password.d.ts.map +1 -0
- package/dist/node/cli/change-identity-password.js +67 -0
- package/dist/node/cli/change-identity-password.js.map +1 -0
- package/dist/node/cli/cli-utils.d.ts +16 -0
- package/dist/node/cli/cli-utils.d.ts.map +1 -0
- package/dist/node/cli/cli-utils.js +113 -0
- package/dist/node/cli/cli-utils.js.map +1 -0
- package/dist/node/cli/identity-export-public.d.ts +4 -0
- package/dist/node/cli/identity-export-public.d.ts.map +1 -0
- package/dist/node/cli/identity-export-public.js +55 -0
- package/dist/node/cli/identity-export-public.js.map +1 -0
- package/dist/node/cli/identity-info.d.ts +4 -0
- package/dist/node/cli/identity-info.d.ts.map +1 -0
- package/dist/node/cli/identity-info.js +57 -0
- package/dist/node/cli/identity-info.js.map +1 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +8 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/server/CapabilityMatcher.d.ts +45 -0
- package/dist/node/server/CapabilityMatcher.d.ts.map +1 -0
- package/dist/node/server/CapabilityMatcher.js +117 -0
- package/dist/node/server/CapabilityMatcher.js.map +1 -0
- package/dist/node/server/MindooDBServer.d.ts +87 -0
- package/dist/node/server/MindooDBServer.d.ts.map +1 -0
- package/dist/node/server/MindooDBServer.js +1040 -0
- package/dist/node/server/MindooDBServer.js.map +1 -0
- package/dist/node/server/ServerSync.d.ts +41 -0
- package/dist/node/server/ServerSync.d.ts.map +1 -0
- package/dist/node/server/ServerSync.js +187 -0
- package/dist/node/server/ServerSync.js.map +1 -0
- package/dist/node/server/StoreFactory.d.ts +45 -0
- package/dist/node/server/StoreFactory.d.ts.map +1 -0
- package/dist/node/server/StoreFactory.js +89 -0
- package/dist/node/server/StoreFactory.js.map +1 -0
- package/dist/node/server/SystemAdminAuth.d.ts +65 -0
- package/dist/node/server/SystemAdminAuth.d.ts.map +1 -0
- package/dist/node/server/SystemAdminAuth.js +200 -0
- package/dist/node/server/SystemAdminAuth.js.map +1 -0
- package/dist/node/server/SystemIpAllowlist.d.ts +21 -0
- package/dist/node/server/SystemIpAllowlist.d.ts.map +1 -0
- package/dist/node/server/SystemIpAllowlist.js +210 -0
- package/dist/node/server/SystemIpAllowlist.js.map +1 -0
- package/dist/node/server/TenantManager.d.ts +85 -0
- package/dist/node/server/TenantManager.d.ts.map +1 -0
- package/dist/node/server/TenantManager.js +493 -0
- package/dist/node/server/TenantManager.js.map +1 -0
- package/dist/node/server/add-to-network.d.ts +20 -0
- package/dist/node/server/add-to-network.d.ts.map +1 -0
- package/dist/node/server/add-to-network.js +275 -0
- package/dist/node/server/add-to-network.js.map +1 -0
- package/dist/node/server/config.d.ts +51 -0
- package/dist/node/server/config.d.ts.map +1 -0
- package/dist/node/server/config.js +218 -0
- package/dist/node/server/config.js.map +1 -0
- package/dist/node/server/resolveServerPassword.d.ts +7 -0
- package/dist/node/server/resolveServerPassword.d.ts.map +1 -0
- package/dist/node/server/resolveServerPassword.js +25 -0
- package/dist/node/server/resolveServerPassword.js.map +1 -0
- package/dist/node/server/server.d.ts +22 -0
- package/dist/node/server/server.d.ts.map +1 -0
- package/dist/node/server/server.js +225 -0
- package/dist/node/server/server.js.map +1 -0
- package/dist/node/server/serverinit.d.ts +21 -0
- package/dist/node/server/serverinit.d.ts.map +1 -0
- package/dist/node/server/serverinit.js +317 -0
- package/dist/node/server/serverinit.js.map +1 -0
- package/dist/node/server/types.d.ts +162 -0
- package/dist/node/server/types.d.ts.map +1 -0
- package/dist/node/server/types.js +24 -0
- package/dist/node/server/types.js.map +1 -0
- package/dist/node/server/validation.d.ts +47 -0
- package/dist/node/server/validation.d.ts.map +1 -0
- package/dist/node/server/validation.js +114 -0
- package/dist/node/server/validation.js.map +1 -0
- package/dist/reactnative/cache/MMKVLocalCacheStore.d.ts +48 -0
- package/dist/reactnative/cache/MMKVLocalCacheStore.d.ts.map +1 -0
- package/dist/reactnative/cache/MMKVLocalCacheStore.js +113 -0
- package/dist/reactnative/cache/MMKVLocalCacheStore.js.map +1 -0
- 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 +9 -0
- package/dist/reactnative/index.d.ts.map +1 -0
- package/dist/reactnative/index.js +41 -0
- package/dist/reactnative/index.js.map +1 -0
- package/package.json +63 -7
- 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
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { MindooDBServerInfo } from "../../core/types";
|
|
2
|
+
/**
|
|
3
|
+
* Types for the MindooDB Example Server
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Store type for content-addressed stores.
|
|
7
|
+
*/
|
|
8
|
+
export type StoreType = "inmemory" | "file";
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for a user registered in the tenant.
|
|
11
|
+
* Users can be human clients or other servers (for server-to-server sync).
|
|
12
|
+
*/
|
|
13
|
+
export interface UserConfig {
|
|
14
|
+
/** Username identifier (e.g., "alice" or "server-eu-west") */
|
|
15
|
+
username: string;
|
|
16
|
+
/** Ed25519 public key in PEM format for signature verification */
|
|
17
|
+
signingPublicKey: string;
|
|
18
|
+
/** RSA-OAEP public key in PEM format for encryption */
|
|
19
|
+
encryptionPublicKey: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A remote server trusted for server-to-server sync.
|
|
23
|
+
* Stored globally in <dataDir>/trusted-servers.json.
|
|
24
|
+
*/
|
|
25
|
+
export interface TrustedServer extends MindooDBServerInfo {
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Configuration for a remote server to sync with (per-tenant).
|
|
29
|
+
* The server authenticates using its global identity (from server.identity.json).
|
|
30
|
+
* The remote server's public keys are looked up from trusted-servers.json.
|
|
31
|
+
*/
|
|
32
|
+
export interface RemoteServerConfig {
|
|
33
|
+
/** Base URL of the remote server (e.g., "https://eu-west.example.com") */
|
|
34
|
+
url: string;
|
|
35
|
+
/** Optional: automatic sync interval in milliseconds */
|
|
36
|
+
syncIntervalMs?: number;
|
|
37
|
+
/** Optional: specific databases to sync (default: all) */
|
|
38
|
+
databases?: string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* RemoteServerConfig with a required name, used when managing sync servers
|
|
42
|
+
* via the admin API. The name identifies the server for updates and deletes.
|
|
43
|
+
*/
|
|
44
|
+
export interface NamedRemoteServerConfig extends RemoteServerConfig {
|
|
45
|
+
/** Server name matching the trusted-servers identity (e.g., "CN=server2") */
|
|
46
|
+
name: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Per-database store configuration.
|
|
50
|
+
*/
|
|
51
|
+
export interface DatabaseStoreConfig {
|
|
52
|
+
storeType: StoreType;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Tenant configuration stored in <dataDir>/<tenantId>/config.json
|
|
56
|
+
*
|
|
57
|
+
* The tenantId is NOT stored here - it's derived from the directory name.
|
|
58
|
+
*/
|
|
59
|
+
export interface TenantConfig {
|
|
60
|
+
/** Admin username used for bootstrap authentication (e.g., "cn=admin/o=acme") */
|
|
61
|
+
adminUsername?: string;
|
|
62
|
+
/** Ed25519 public key in PEM format for verifying admin signatures */
|
|
63
|
+
adminSigningPublicKey: string;
|
|
64
|
+
/** RSA-OAEP public key in PEM format for encrypting admin-only data */
|
|
65
|
+
adminEncryptionPublicKey: string;
|
|
66
|
+
/** Base64-encoded $publicinfos AES-256 symmetric key for reading the directory DB */
|
|
67
|
+
publicInfosKey?: string;
|
|
68
|
+
/** Default store type for new databases (default: "file") */
|
|
69
|
+
defaultStoreType?: StoreType;
|
|
70
|
+
/** Per-database store configuration overrides */
|
|
71
|
+
databaseStores?: Record<string, DatabaseStoreConfig>;
|
|
72
|
+
/** Registered users (clients and other servers) — bootstrap/test fallback, ignored when publicInfosKey is present */
|
|
73
|
+
users?: UserConfig[];
|
|
74
|
+
/** Remote servers to sync with (for server-to-server sync) */
|
|
75
|
+
remoteServers?: RemoteServerConfig[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Request body for POST /admin/register-tenant
|
|
79
|
+
*/
|
|
80
|
+
export interface RegisterTenantRequest {
|
|
81
|
+
/** Tenant identifier (lowercase, becomes directory name) */
|
|
82
|
+
tenantId: string;
|
|
83
|
+
/** Admin username used for bootstrap authentication */
|
|
84
|
+
adminUsername?: string;
|
|
85
|
+
/** Ed25519 public key in PEM format */
|
|
86
|
+
adminSigningPublicKey: string;
|
|
87
|
+
/** RSA-OAEP public key in PEM format */
|
|
88
|
+
adminEncryptionPublicKey: string;
|
|
89
|
+
/** Base64-encoded $publicinfos AES-256 symmetric key for reading the directory DB */
|
|
90
|
+
publicInfosKey?: string;
|
|
91
|
+
/** Default store type (default: "file") */
|
|
92
|
+
defaultStoreType?: StoreType;
|
|
93
|
+
/** Initial users to register (for testing/bootstrapping only, ignored when publicInfosKey is present) */
|
|
94
|
+
users?: UserConfig[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Response body for POST /admin/register-tenant
|
|
98
|
+
*/
|
|
99
|
+
export interface RegisterTenantResponse {
|
|
100
|
+
success: boolean;
|
|
101
|
+
tenantId: string;
|
|
102
|
+
message?: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Response body for GET /admin/tenants
|
|
106
|
+
*/
|
|
107
|
+
export interface ListTenantsResponse {
|
|
108
|
+
tenants: string[];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Loaded tenant context used internally by the server.
|
|
112
|
+
*/
|
|
113
|
+
export interface TenantContext {
|
|
114
|
+
/** Tenant identifier (lowercase) */
|
|
115
|
+
tenantId: string;
|
|
116
|
+
/** Loaded tenant configuration */
|
|
117
|
+
config: TenantConfig;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A principal entry in a capability rule.
|
|
121
|
+
* Identifies a system admin by both username and public signing key.
|
|
122
|
+
*
|
|
123
|
+
* The special wildcard principal `{ username: "*", publicsignkey: "*" }`
|
|
124
|
+
* is reserved for demo tenant-creation rules and is rejected for all other
|
|
125
|
+
* system endpoints.
|
|
126
|
+
*/
|
|
127
|
+
export interface SystemAdminPrincipal {
|
|
128
|
+
username: string;
|
|
129
|
+
publicsignkey: string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Server-level configuration loaded from config.json.
|
|
133
|
+
*
|
|
134
|
+
* The `capabilities` map controls which system admins can call which
|
|
135
|
+
* endpoints. Keys are `METHOD:PATHPATTERN` rules (e.g. `ALL:/system/*`,
|
|
136
|
+
* `POST:/system/tenants/company-*`). Values are arrays of principals
|
|
137
|
+
* allowed to call matching routes.
|
|
138
|
+
*/
|
|
139
|
+
export interface ServerConfig {
|
|
140
|
+
capabilities: Record<string, SystemAdminPrincipal[]>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Environment variables used by the server.
|
|
144
|
+
*/
|
|
145
|
+
export declare const ENV_VARS: {
|
|
146
|
+
/** Password to decrypt server identity private keys and per-tenant keybags */
|
|
147
|
+
readonly SERVER_PASSWORD: "MINDOODB_SERVER_PASSWORD";
|
|
148
|
+
/**
|
|
149
|
+
* Path to a file whose contents are the server password (trimmed). If set, used
|
|
150
|
+
* instead of {@link ENV_VARS.SERVER_PASSWORD}. Prefer in Docker so the secret is
|
|
151
|
+
* not stored in the container environment block.
|
|
152
|
+
*/
|
|
153
|
+
readonly SERVER_PASSWORD_FILE: "MINDOODB_SERVER_PASSWORD_FILE";
|
|
154
|
+
/**
|
|
155
|
+
* Optional comma-separated allowlist for /system/* (system admin HTTP surface).
|
|
156
|
+
* If unset or `*`, any client IP may call /system/* (JWT + capabilities still required).
|
|
157
|
+
* Supports exact IPv4/IPv6 addresses plus IPv4/IPv6 CIDRs.
|
|
158
|
+
* Example: `127.0.0.1,::1,10.0.0.0/8,2001:db8::/32`
|
|
159
|
+
*/
|
|
160
|
+
readonly ADMIN_ALLOWED_IPS: "MINDOODB_ADMIN_ALLOWED_IPS";
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/node/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,gBAAgB,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,kBAAkB;CAAG;AAE5D;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,qBAAqB,EAAE,MAAM,CAAC;IAC9B,uEAAuE;IACvE,wBAAwB,EAAE,MAAM,CAAC;IAEjC,qFAAqF;IACrF,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,6DAA6D;IAC7D,gBAAgB,CAAC,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,QAAQ;IACnB,8EAA8E;;IAE9E;;;;OAIG;;IAEH;;;;;OAKG;;CAEK,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ENV_VARS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Environment variables used by the server.
|
|
6
|
+
*/
|
|
7
|
+
exports.ENV_VARS = {
|
|
8
|
+
/** Password to decrypt server identity private keys and per-tenant keybags */
|
|
9
|
+
SERVER_PASSWORD: "MINDOODB_SERVER_PASSWORD",
|
|
10
|
+
/**
|
|
11
|
+
* Path to a file whose contents are the server password (trimmed). If set, used
|
|
12
|
+
* instead of {@link ENV_VARS.SERVER_PASSWORD}. Prefer in Docker so the secret is
|
|
13
|
+
* not stored in the container environment block.
|
|
14
|
+
*/
|
|
15
|
+
SERVER_PASSWORD_FILE: "MINDOODB_SERVER_PASSWORD_FILE",
|
|
16
|
+
/**
|
|
17
|
+
* Optional comma-separated allowlist for /system/* (system admin HTTP surface).
|
|
18
|
+
* If unset or `*`, any client IP may call /system/* (JWT + capabilities still required).
|
|
19
|
+
* Supports exact IPv4/IPv6 addresses plus IPv4/IPv6 CIDRs.
|
|
20
|
+
* Example: `127.0.0.1,::1,10.0.0.0/8,2001:db8::/32`
|
|
21
|
+
*/
|
|
22
|
+
ADMIN_ALLOWED_IPS: "MINDOODB_ADMIN_ALLOWED_IPS",
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/node/server/types.ts"],"names":[],"mappings":";;;AAmKA;;GAEG;AACU,QAAA,QAAQ,GAAG;IACtB,8EAA8E;IAC9E,eAAe,EAAE,0BAA0B;IAC3C;;;;OAIG;IACH,oBAAoB,EAAE,+BAA+B;IACrD;;;;;OAKG;IACH,iBAAiB,EAAE,4BAA4B;CACvC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input validation utilities for the MindooDB Example Server.
|
|
3
|
+
*
|
|
4
|
+
* Prevents path traversal, injection, and resource exhaustion attacks
|
|
5
|
+
* by enforcing strict rules on all user-supplied identifiers and arrays.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Validates an identifier (tenantId, dbId, serverName, etc.).
|
|
9
|
+
* Must be 1-64 chars, lowercase alphanumeric + hyphens, start with alphanumeric.
|
|
10
|
+
* Rejects path separators, "..", leading dots, and special characters.
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateIdentifier(value: unknown, fieldName: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Validates a username (more permissive than identifier -- allows "CN=xxx/O=yyy" format).
|
|
15
|
+
* Max 256 chars, printable ASCII, no path separators or null bytes.
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateUsername(value: unknown): string;
|
|
18
|
+
/**
|
|
19
|
+
* Validates that an array does not exceed a maximum number of elements.
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateArraySize(value: unknown, maxSize: number, fieldName: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Validates that a string does not exceed a maximum length.
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateStringLength(value: unknown, maxLength: number, fieldName: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Tenant IDs that are reserved because they collide with server route prefixes.
|
|
28
|
+
*/
|
|
29
|
+
export declare const RESERVED_TENANT_NAMES: Set<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Validates tenant ID syntax without checking reserved route names.
|
|
32
|
+
*/
|
|
33
|
+
export declare function validateTenantIdFormat(value: unknown): string;
|
|
34
|
+
/**
|
|
35
|
+
* Validates a tenant ID: must pass tenant ID syntax rules and must not be reserved.
|
|
36
|
+
*/
|
|
37
|
+
export declare function validateTenantId(value: unknown): string;
|
|
38
|
+
export declare class ValidationError extends Error {
|
|
39
|
+
constructor(message: string);
|
|
40
|
+
}
|
|
41
|
+
export declare const MAX_HAVE_IDS = 100000;
|
|
42
|
+
export declare const MAX_ENTRY_IDS = 100000;
|
|
43
|
+
export declare const MAX_PUT_ENTRIES = 10000;
|
|
44
|
+
export declare const MAX_PEM_KEY_LENGTH = 8192;
|
|
45
|
+
export declare const MAX_SIGNATURE_LENGTH = 4096;
|
|
46
|
+
export declare const MAX_CHALLENGE_LENGTH = 4096;
|
|
47
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/node/server/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAgB5E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAcvD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAU1F;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAU/F;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,aAAoD,CAAC;AAEvF;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgB7D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQvD;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAGD,eAAO,MAAM,YAAY,SAAU,CAAC;AACpC,eAAO,MAAM,aAAa,SAAU,CAAC;AACrC,eAAO,MAAM,eAAe,QAAS,CAAC;AACtC,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AACxC,eAAO,MAAM,oBAAoB,OAAQ,CAAC;AAC1C,eAAO,MAAM,oBAAoB,OAAQ,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Input validation utilities for the MindooDB Example Server.
|
|
4
|
+
*
|
|
5
|
+
* Prevents path traversal, injection, and resource exhaustion attacks
|
|
6
|
+
* by enforcing strict rules on all user-supplied identifiers and arrays.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MAX_CHALLENGE_LENGTH = exports.MAX_SIGNATURE_LENGTH = exports.MAX_PEM_KEY_LENGTH = exports.MAX_PUT_ENTRIES = exports.MAX_ENTRY_IDS = exports.MAX_HAVE_IDS = exports.ValidationError = exports.RESERVED_TENANT_NAMES = void 0;
|
|
10
|
+
exports.validateIdentifier = validateIdentifier;
|
|
11
|
+
exports.validateUsername = validateUsername;
|
|
12
|
+
exports.validateArraySize = validateArraySize;
|
|
13
|
+
exports.validateStringLength = validateStringLength;
|
|
14
|
+
exports.validateTenantIdFormat = validateTenantIdFormat;
|
|
15
|
+
exports.validateTenantId = validateTenantId;
|
|
16
|
+
/**
|
|
17
|
+
* Validates an identifier (tenantId, dbId, serverName, etc.).
|
|
18
|
+
* Must be 1-64 chars, lowercase alphanumeric + hyphens, start with alphanumeric.
|
|
19
|
+
* Rejects path separators, "..", leading dots, and special characters.
|
|
20
|
+
*/
|
|
21
|
+
function validateIdentifier(value, fieldName) {
|
|
22
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
23
|
+
throw new ValidationError(`${fieldName} is required and must be a non-empty string`);
|
|
24
|
+
}
|
|
25
|
+
if (value.length > 64) {
|
|
26
|
+
throw new ValidationError(`${fieldName} must be at most 64 characters`);
|
|
27
|
+
}
|
|
28
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(value)) {
|
|
29
|
+
throw new ValidationError(`${fieldName} must start with a letter or digit and contain only lowercase letters, digits, and hyphens`);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Validates a username (more permissive than identifier -- allows "CN=xxx/O=yyy" format).
|
|
35
|
+
* Max 256 chars, printable ASCII, no path separators or null bytes.
|
|
36
|
+
*/
|
|
37
|
+
function validateUsername(value) {
|
|
38
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
39
|
+
throw new ValidationError("username is required and must be a non-empty string");
|
|
40
|
+
}
|
|
41
|
+
if (value.length > 256) {
|
|
42
|
+
throw new ValidationError("username must be at most 256 characters");
|
|
43
|
+
}
|
|
44
|
+
if (/[\x00-\x1f\x7f]/.test(value)) {
|
|
45
|
+
throw new ValidationError("username must not contain control characters");
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Validates that an array does not exceed a maximum number of elements.
|
|
51
|
+
*/
|
|
52
|
+
function validateArraySize(value, maxSize, fieldName) {
|
|
53
|
+
if (!Array.isArray(value)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (value.length > maxSize) {
|
|
57
|
+
throw new ValidationError(`${fieldName} must contain at most ${maxSize} elements (received ${value.length})`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Validates that a string does not exceed a maximum length.
|
|
62
|
+
*/
|
|
63
|
+
function validateStringLength(value, maxLength, fieldName) {
|
|
64
|
+
if (typeof value !== "string") {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (value.length > maxLength) {
|
|
68
|
+
throw new ValidationError(`${fieldName} must be at most ${maxLength} characters`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Tenant IDs that are reserved because they collide with server route prefixes.
|
|
73
|
+
*/
|
|
74
|
+
exports.RESERVED_TENANT_NAMES = new Set(["admin", "system", "health", "statics"]);
|
|
75
|
+
/**
|
|
76
|
+
* Validates tenant ID syntax without checking reserved route names.
|
|
77
|
+
*/
|
|
78
|
+
function validateTenantIdFormat(value) {
|
|
79
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
80
|
+
throw new ValidationError("tenantId is required and must be a non-empty string");
|
|
81
|
+
}
|
|
82
|
+
if (value.length > 64) {
|
|
83
|
+
throw new ValidationError("tenantId must be at most 64 characters");
|
|
84
|
+
}
|
|
85
|
+
if (!/^[a-z0-9][a-z0-9_-]*$/.test(value)) {
|
|
86
|
+
throw new ValidationError("tenantId must start with a letter or digit and contain only lowercase letters, digits, hyphens, and underscores");
|
|
87
|
+
}
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Validates a tenant ID: must pass tenant ID syntax rules and must not be reserved.
|
|
92
|
+
*/
|
|
93
|
+
function validateTenantId(value) {
|
|
94
|
+
const id = validateTenantIdFormat(value);
|
|
95
|
+
if (exports.RESERVED_TENANT_NAMES.has(id)) {
|
|
96
|
+
throw new ValidationError(`tenantId "${id}" is reserved and cannot be used`);
|
|
97
|
+
}
|
|
98
|
+
return id;
|
|
99
|
+
}
|
|
100
|
+
class ValidationError extends Error {
|
|
101
|
+
constructor(message) {
|
|
102
|
+
super(message);
|
|
103
|
+
this.name = "ValidationError";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.ValidationError = ValidationError;
|
|
107
|
+
// Limits
|
|
108
|
+
exports.MAX_HAVE_IDS = 100000;
|
|
109
|
+
exports.MAX_ENTRY_IDS = 100000;
|
|
110
|
+
exports.MAX_PUT_ENTRIES = 10000;
|
|
111
|
+
exports.MAX_PEM_KEY_LENGTH = 8192;
|
|
112
|
+
exports.MAX_SIGNATURE_LENGTH = 4096;
|
|
113
|
+
exports.MAX_CHALLENGE_LENGTH = 4096;
|
|
114
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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AG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACzC,IAAI,6BAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,eAAe,CACvB,aAAa,EAAE,kCAAkC,CAClD,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAED,SAAS;AACI,QAAA,YAAY,GAAG,MAAO,CAAC;AACvB,QAAA,aAAa,GAAG,MAAO,CAAC;AACxB,QAAA,eAAe,GAAG,KAAM,CAAC;AACzB,QAAA,kBAAkB,GAAG,IAAK,CAAC;AAC3B,QAAA,oBAAoB,GAAG,IAAK,CAAC;AAC7B,QAAA,oBAAoB,GAAG,IAAK,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { LocalCacheStore } from "../../core/cache/LocalCacheStore";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal MMKV interface (subset of react-native-mmkv).
|
|
4
|
+
* Allows consumers to pass their own MMKV instance without
|
|
5
|
+
* us importing the native module at the library level.
|
|
6
|
+
*/
|
|
7
|
+
export interface MMKVInterface {
|
|
8
|
+
set(key: string, value: ArrayBuffer | boolean | string | number): void;
|
|
9
|
+
getBuffer(key: string): ArrayBuffer | undefined;
|
|
10
|
+
delete(key: string): void;
|
|
11
|
+
getAllKeys(): string[];
|
|
12
|
+
clearAll(): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Minimal AsyncStorage interface (subset of @react-native-async-storage/async-storage).
|
|
16
|
+
*/
|
|
17
|
+
export interface AsyncStorageInterface {
|
|
18
|
+
getItem(key: string): Promise<string | null>;
|
|
19
|
+
setItem(key: string, value: string): Promise<void>;
|
|
20
|
+
removeItem(key: string): Promise<void>;
|
|
21
|
+
getAllKeys(): Promise<readonly string[]>;
|
|
22
|
+
clear(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* React Native {@link LocalCacheStore} backed by MMKV (synchronous, fast, binary-safe)
|
|
26
|
+
* with an AsyncStorage fallback for environments where MMKV is unavailable.
|
|
27
|
+
*/
|
|
28
|
+
export declare class MMKVLocalCacheStore implements LocalCacheStore {
|
|
29
|
+
private mmkv;
|
|
30
|
+
private asyncStorage;
|
|
31
|
+
private readonly keyPrefix;
|
|
32
|
+
/**
|
|
33
|
+
* @param mmkv An MMKV instance (from react-native-mmkv)
|
|
34
|
+
* @param asyncStorage Fallback AsyncStorage instance (used when mmkv is null)
|
|
35
|
+
* @param keyPrefix Optional prefix to namespace all keys (default: "mindoodb-cache:")
|
|
36
|
+
*/
|
|
37
|
+
constructor(mmkv: MMKVInterface | null, asyncStorage?: AsyncStorageInterface | null, keyPrefix?: string);
|
|
38
|
+
private toKey;
|
|
39
|
+
private fromKey;
|
|
40
|
+
private static toBase64;
|
|
41
|
+
private static fromBase64;
|
|
42
|
+
get(type: string, id: string): Promise<Uint8Array | null>;
|
|
43
|
+
put(type: string, id: string, value: Uint8Array): Promise<void>;
|
|
44
|
+
delete(type: string, id: string): Promise<void>;
|
|
45
|
+
list(type: string): Promise<string[]>;
|
|
46
|
+
clear(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=MMKVLocalCacheStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MMKVLocalCacheStore.d.ts","sourceRoot":"","sources":["../../../src/reactnative/cache/MMKVLocalCacheStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAExE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,GAAG,MAAM,G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AC,IAAI,CAAC;IAY/D,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW/C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAgBrC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB7B"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MMKVLocalCacheStore = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* React Native {@link LocalCacheStore} backed by MMKV (synchronous, fast, binary-safe)
|
|
6
|
+
* with an AsyncStorage fallback for environments where MMKV is unavailable.
|
|
7
|
+
*/
|
|
8
|
+
class MMKVLocalCacheStore {
|
|
9
|
+
/**
|
|
10
|
+
* @param mmkv An MMKV instance (from react-native-mmkv)
|
|
11
|
+
* @param asyncStorage Fallback AsyncStorage instance (used when mmkv is null)
|
|
12
|
+
* @param keyPrefix Optional prefix to namespace all keys (default: "mindoodb-cache:")
|
|
13
|
+
*/
|
|
14
|
+
constructor(mmkv, asyncStorage, keyPrefix = "mindoodb-cache:") {
|
|
15
|
+
this.mmkv = mmkv;
|
|
16
|
+
this.asyncStorage = asyncStorage ?? null;
|
|
17
|
+
this.keyPrefix = keyPrefix;
|
|
18
|
+
if (!this.mmkv && !this.asyncStorage) {
|
|
19
|
+
throw new Error("MMKVLocalCacheStore requires either an MMKV instance or AsyncStorage fallback");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
toKey(type, id) {
|
|
23
|
+
return `${this.keyPrefix}${type}\0${id}`;
|
|
24
|
+
}
|
|
25
|
+
fromKey(raw) {
|
|
26
|
+
if (!raw.startsWith(this.keyPrefix))
|
|
27
|
+
return null;
|
|
28
|
+
const rest = raw.slice(this.keyPrefix.length);
|
|
29
|
+
const sep = rest.indexOf("\0");
|
|
30
|
+
if (sep === -1)
|
|
31
|
+
return null;
|
|
32
|
+
return { type: rest.slice(0, sep), id: rest.slice(sep + 1) };
|
|
33
|
+
}
|
|
34
|
+
// ---- Uint8Array <-> base64 for AsyncStorage (which only stores strings) ----
|
|
35
|
+
static toBase64(data) {
|
|
36
|
+
let binary = "";
|
|
37
|
+
for (let i = 0; i < data.length; i++) {
|
|
38
|
+
binary += String.fromCharCode(data[i]);
|
|
39
|
+
}
|
|
40
|
+
return btoa(binary);
|
|
41
|
+
}
|
|
42
|
+
static fromBase64(b64) {
|
|
43
|
+
const binary = atob(b64);
|
|
44
|
+
const bytes = new Uint8Array(binary.length);
|
|
45
|
+
for (let i = 0; i < binary.length; i++) {
|
|
46
|
+
bytes[i] = binary.charCodeAt(i);
|
|
47
|
+
}
|
|
48
|
+
return bytes;
|
|
49
|
+
}
|
|
50
|
+
// ---- LocalCacheStore ----
|
|
51
|
+
async get(type, id) {
|
|
52
|
+
const key = this.toKey(type, id);
|
|
53
|
+
if (this.mmkv) {
|
|
54
|
+
const buf = this.mmkv.getBuffer(key);
|
|
55
|
+
if (buf === undefined)
|
|
56
|
+
return null;
|
|
57
|
+
return new Uint8Array(buf);
|
|
58
|
+
}
|
|
59
|
+
const str = await this.asyncStorage.getItem(key);
|
|
60
|
+
if (str === null)
|
|
61
|
+
return null;
|
|
62
|
+
return MMKVLocalCacheStore.fromBase64(str);
|
|
63
|
+
}
|
|
64
|
+
async put(type, id, value) {
|
|
65
|
+
const key = this.toKey(type, id);
|
|
66
|
+
if (this.mmkv) {
|
|
67
|
+
const buf = value.buffer.slice(value.byteOffset, value.byteOffset + value.byteLength);
|
|
68
|
+
this.mmkv.set(key, buf);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
await this.asyncStorage.setItem(key, MMKVLocalCacheStore.toBase64(value));
|
|
72
|
+
}
|
|
73
|
+
async delete(type, id) {
|
|
74
|
+
const key = this.toKey(type, id);
|
|
75
|
+
if (this.mmkv) {
|
|
76
|
+
this.mmkv.delete(key);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
await this.asyncStorage.removeItem(key);
|
|
80
|
+
}
|
|
81
|
+
async list(type) {
|
|
82
|
+
const prefix = `${this.keyPrefix}${type}\0`;
|
|
83
|
+
if (this.mmkv) {
|
|
84
|
+
return this.mmkv
|
|
85
|
+
.getAllKeys()
|
|
86
|
+
.filter(k => k.startsWith(prefix))
|
|
87
|
+
.map(k => k.slice(prefix.length));
|
|
88
|
+
}
|
|
89
|
+
const allKeys = await this.asyncStorage.getAllKeys();
|
|
90
|
+
return Array.from(allKeys)
|
|
91
|
+
.filter(k => k.startsWith(prefix))
|
|
92
|
+
.map(k => k.slice(prefix.length));
|
|
93
|
+
}
|
|
94
|
+
async clear() {
|
|
95
|
+
if (this.mmkv) {
|
|
96
|
+
const allKeys = this.mmkv.getAllKeys();
|
|
97
|
+
for (const key of allKeys) {
|
|
98
|
+
if (key.startsWith(this.keyPrefix)) {
|
|
99
|
+
this.mmkv.delete(key);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const allKeys = await this.asyncStorage.getAllKeys();
|
|
105
|
+
for (const key of allKeys) {
|
|
106
|
+
if (key.startsWith(this.keyPrefix)) {
|
|
107
|
+
await this.asyncStorage.removeItem(key);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.MMKVLocalCacheStore = MMKVLocalCacheStore;
|
|
113
|
+
//# sourceMappingURL=MMKVLocalCacheStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MMKVLocalCacheStore.js","sourceRoot":"","sources":["../../../src/reactnative/cache/MMKVLocalCacheStore.ts"],"names":[],"mappings":";;;AA0BA;;;GAGG;AACH,MAAa,mBAAmB;IAK9B;;;;OAIG;IACH,YACE,IAA0B,EAC1B,YAA2C,EAC3C,YAAoB,iBAAiB;QAErC,IAAI,CAAC,IAAI,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CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACvC,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;gBAC1B,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;oBACnC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC;YACD,OAAO;QACT,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAa,CAAC,UAAU,EAAE,CAAC;QACtD,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,CAAC,YAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAhID,kDAgIC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AES-GCM Adapter
|
|
3
|
+
* Implements AES-GCM encryption/decryption using node-forge
|
|
4
|
+
*/
|
|
5
|
+
export interface AESGCMParams {
|
|
6
|
+
name: "AES-GCM";
|
|
7
|
+
iv: BufferSource;
|
|
8
|
+
tagLength?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Encrypt data with AES-GCM
|
|
12
|
+
*/
|
|
13
|
+
export declare function aesGcmEncrypt(params: AESGCMParams, key: CryptoKey | ArrayBuffer, data: ArrayBuffer | Uint8Array): Promise<ArrayBuffer>;
|
|
14
|
+
/**
|
|
15
|
+
* Decrypt data with AES-GCM
|
|
16
|
+
*/
|
|
17
|
+
export declare function aesGcmDecrypt(params: AESGCMParams, key: CryptoKey | ArrayBuffer, data: ArrayBuffer | Uint8Array): Promise<ArrayBuffer>;
|
|
18
|
+
//# sourceMappingURL=AESAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AESAdapter.d.ts","sourceRoot":"","sources":["../../../src/reactnative/crypto/AESAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,YAAY,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,GAAG,WAAW,EAC5B,IAAI,EAAE,WAAW,GAAG,UAAU,GAC7B,OAAO,CAAC,WAAW,CAAC,CAqDtB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,GAAG,WAAW,EAC5B,IAAI,EAAE,WAAW,GAAG,UAAU,GAC7B,OAAO,CAAC,WAAW,CAAC,CA8CtB"}
|