mindcache 3.5.1 → 3.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CloudAdapter-CM7nyJaG.d.mts → CloudAdapter-DK4YecbV.d.mts} +4 -0
- package/dist/{CloudAdapter-CM7nyJaG.d.ts → CloudAdapter-DK4YecbV.d.ts} +4 -0
- package/dist/cloud/index.d.mts +2 -2
- package/dist/cloud/index.d.ts +2 -2
- package/dist/cloud/index.js +38 -0
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/index.mjs +38 -0
- package/dist/cloud/index.mjs.map +1 -1
- package/dist/index.d.mts +16 -5
- package/dist/index.d.ts +16 -5
- package/dist/index.js +82 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -6
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +38 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +38 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as MindCacheOptions, M as MindCache } from './CloudAdapter-
|
|
2
|
-
export { A as AccessLevel, a as CloudAdapter, c as CloudAdapterEvents, C as CloudConfig, b as ConnectionState, h as ContextRules, n as DEFAULT_KEY_ATTRIBUTES, G as GlobalListener, H as HistoryEntry, k as HistoryOptions, K as KeyAttributes, j as KeyEntry, f as KeyType, L as Listener, l as MindCacheCloudOptions, m as MindCacheIndexedDBOptions, i as STM, j as STMEntry, g as SystemTag, o as SystemTagHelpers } from './CloudAdapter-
|
|
1
|
+
import { e as MindCacheOptions, M as MindCache } from './CloudAdapter-DK4YecbV.mjs';
|
|
2
|
+
export { A as AccessLevel, a as CloudAdapter, c as CloudAdapterEvents, C as CloudConfig, b as ConnectionState, h as ContextRules, n as DEFAULT_KEY_ATTRIBUTES, G as GlobalListener, H as HistoryEntry, k as HistoryOptions, K as KeyAttributes, j as KeyEntry, f as KeyType, L as Listener, l as MindCacheCloudOptions, m as MindCacheIndexedDBOptions, i as STM, j as STMEntry, g as SystemTag, o as SystemTagHelpers } from './CloudAdapter-DK4YecbV.mjs';
|
|
3
3
|
export { IndexedDBAdapter, IndexedDBConfig } from './server.mjs';
|
|
4
4
|
import 'yjs';
|
|
5
5
|
|
|
@@ -16,11 +16,18 @@ interface OAuthConfig {
|
|
|
16
16
|
redirectUri?: string;
|
|
17
17
|
/** Scopes to request (default: ['read', 'write']) */
|
|
18
18
|
scopes?: string[];
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* MindCache API base URL (default: 'https://api.mindcache.dev')
|
|
21
|
+
* This is the ONLY URL you need to set! All OAuth endpoints are derived from this.
|
|
22
|
+
* - authUrl = baseUrl + '/oauth/authorize'
|
|
23
|
+
* - tokenUrl = baseUrl + '/oauth/token'
|
|
24
|
+
*/
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
/** @deprecated Use baseUrl instead. MindCache authorize URL */
|
|
20
27
|
authUrl?: string;
|
|
21
|
-
/** MindCache token URL
|
|
28
|
+
/** @deprecated Use baseUrl instead. MindCache token URL */
|
|
22
29
|
tokenUrl?: string;
|
|
23
|
-
/**
|
|
30
|
+
/** @deprecated Use baseUrl instead. MindCache API URL */
|
|
24
31
|
apiUrl?: string;
|
|
25
32
|
/** Use PKCE for security (default: true) */
|
|
26
33
|
usePKCE?: boolean;
|
|
@@ -62,6 +69,10 @@ declare class OAuthClient {
|
|
|
62
69
|
private tokens;
|
|
63
70
|
private refreshPromise;
|
|
64
71
|
constructor(config: OAuthConfig);
|
|
72
|
+
/**
|
|
73
|
+
* Validate the API is reachable and warn about common misconfigurations
|
|
74
|
+
*/
|
|
75
|
+
private validateApi;
|
|
65
76
|
/**
|
|
66
77
|
* Check if user is authenticated
|
|
67
78
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as MindCacheOptions, M as MindCache } from './CloudAdapter-
|
|
2
|
-
export { A as AccessLevel, a as CloudAdapter, c as CloudAdapterEvents, C as CloudConfig, b as ConnectionState, h as ContextRules, n as DEFAULT_KEY_ATTRIBUTES, G as GlobalListener, H as HistoryEntry, k as HistoryOptions, K as KeyAttributes, j as KeyEntry, f as KeyType, L as Listener, l as MindCacheCloudOptions, m as MindCacheIndexedDBOptions, i as STM, j as STMEntry, g as SystemTag, o as SystemTagHelpers } from './CloudAdapter-
|
|
1
|
+
import { e as MindCacheOptions, M as MindCache } from './CloudAdapter-DK4YecbV.js';
|
|
2
|
+
export { A as AccessLevel, a as CloudAdapter, c as CloudAdapterEvents, C as CloudConfig, b as ConnectionState, h as ContextRules, n as DEFAULT_KEY_ATTRIBUTES, G as GlobalListener, H as HistoryEntry, k as HistoryOptions, K as KeyAttributes, j as KeyEntry, f as KeyType, L as Listener, l as MindCacheCloudOptions, m as MindCacheIndexedDBOptions, i as STM, j as STMEntry, g as SystemTag, o as SystemTagHelpers } from './CloudAdapter-DK4YecbV.js';
|
|
3
3
|
export { IndexedDBAdapter, IndexedDBConfig } from './server.js';
|
|
4
4
|
import 'yjs';
|
|
5
5
|
|
|
@@ -16,11 +16,18 @@ interface OAuthConfig {
|
|
|
16
16
|
redirectUri?: string;
|
|
17
17
|
/** Scopes to request (default: ['read', 'write']) */
|
|
18
18
|
scopes?: string[];
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* MindCache API base URL (default: 'https://api.mindcache.dev')
|
|
21
|
+
* This is the ONLY URL you need to set! All OAuth endpoints are derived from this.
|
|
22
|
+
* - authUrl = baseUrl + '/oauth/authorize'
|
|
23
|
+
* - tokenUrl = baseUrl + '/oauth/token'
|
|
24
|
+
*/
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
/** @deprecated Use baseUrl instead. MindCache authorize URL */
|
|
20
27
|
authUrl?: string;
|
|
21
|
-
/** MindCache token URL
|
|
28
|
+
/** @deprecated Use baseUrl instead. MindCache token URL */
|
|
22
29
|
tokenUrl?: string;
|
|
23
|
-
/**
|
|
30
|
+
/** @deprecated Use baseUrl instead. MindCache API URL */
|
|
24
31
|
apiUrl?: string;
|
|
25
32
|
/** Use PKCE for security (default: true) */
|
|
26
33
|
usePKCE?: boolean;
|
|
@@ -62,6 +69,10 @@ declare class OAuthClient {
|
|
|
62
69
|
private tokens;
|
|
63
70
|
private refreshPromise;
|
|
64
71
|
constructor(config: OAuthConfig);
|
|
72
|
+
/**
|
|
73
|
+
* Validate the API is reachable and warn about common misconfigurations
|
|
74
|
+
*/
|
|
75
|
+
private validateApi;
|
|
65
76
|
/**
|
|
66
77
|
* Check if user is authenticated
|
|
67
78
|
*/
|
package/dist/index.js
CHANGED
|
@@ -212,6 +212,7 @@ var init_CloudAdapter = __esm({
|
|
|
212
212
|
if (!config.baseUrl) {
|
|
213
213
|
throw new Error("MindCache Cloud: baseUrl is required. Please provide the cloud API URL in your configuration.");
|
|
214
214
|
}
|
|
215
|
+
this.validateConfig(config);
|
|
215
216
|
this.setupNetworkDetection();
|
|
216
217
|
}
|
|
217
218
|
ws = null;
|
|
@@ -227,6 +228,43 @@ var init_CloudAdapter = __esm({
|
|
|
227
228
|
handleOnline = null;
|
|
228
229
|
handleOffline = null;
|
|
229
230
|
_synced = false;
|
|
231
|
+
/**
|
|
232
|
+
* Validate configuration and warn about common mistakes
|
|
233
|
+
*/
|
|
234
|
+
validateConfig(config) {
|
|
235
|
+
const baseUrl = config.baseUrl;
|
|
236
|
+
if (!baseUrl) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
console.log("\u2601\uFE0F MindCache Cloud Config:", {
|
|
240
|
+
baseUrl,
|
|
241
|
+
instanceId: config.instanceId,
|
|
242
|
+
hasTokenProvider: !!config.tokenProvider,
|
|
243
|
+
hasApiKey: !!config.apiKey
|
|
244
|
+
});
|
|
245
|
+
try {
|
|
246
|
+
const url = new URL(baseUrl);
|
|
247
|
+
if (url.hostname === "mindcache.dev") {
|
|
248
|
+
console.error(
|
|
249
|
+
'\u26A0\uFE0F MindCache Cloud WARNING: baseUrl is set to "mindcache.dev" but the API is at "api.mindcache.dev".\n Current: ' + baseUrl + "\n Expected: https://api.mindcache.dev\n This will cause WebSocket connection failures (404 errors)."
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
if (url.protocol === "ws:" || url.protocol === "wss:") {
|
|
253
|
+
console.warn(
|
|
254
|
+
"\u26A0\uFE0F MindCache Cloud: baseUrl uses WebSocket protocol (" + url.protocol + "). Consider using http:// or https:// - CloudAdapter will handle the WebSocket upgrade automatically."
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
if (url.hostname === "localhost" && url.port !== "8787" && url.port !== "3000") {
|
|
258
|
+
console.warn(
|
|
259
|
+
"\u26A0\uFE0F MindCache Cloud: localhost URL detected with non-standard port " + url.port + ". Default MindCache dev server runs on port 8787."
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
const wsUrl = baseUrl.replace("https://", "wss://").replace("http://", "ws://");
|
|
263
|
+
console.log("\u2601\uFE0F WebSocket will connect to:", wsUrl + "/sync/" + config.instanceId);
|
|
264
|
+
} catch (e) {
|
|
265
|
+
console.error("\u26A0\uFE0F MindCache Cloud: Invalid baseUrl format:", baseUrl);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
230
268
|
/** Browser network status - instantly updated via navigator.onLine */
|
|
231
269
|
get isOnline() {
|
|
232
270
|
return this._isOnline;
|
|
@@ -2650,9 +2688,8 @@ init_CloudAdapter();
|
|
|
2650
2688
|
init_CloudAdapter();
|
|
2651
2689
|
|
|
2652
2690
|
// src/cloud/OAuthClient.ts
|
|
2653
|
-
var
|
|
2654
|
-
var
|
|
2655
|
-
var DEFAULT_USERINFO_URL = "https://api.mindcache.dev/oauth/userinfo";
|
|
2691
|
+
var DEFAULT_API_URL = "https://api.mindcache.dev";
|
|
2692
|
+
var DEFAULT_USERINFO_URL = DEFAULT_API_URL + "/oauth/userinfo";
|
|
2656
2693
|
var TOKEN_REFRESH_BUFFER = 5 * 60 * 1e3;
|
|
2657
2694
|
function generateRandomString(length2) {
|
|
2658
2695
|
const array = new Uint8Array(length2);
|
|
@@ -2688,19 +2725,58 @@ var OAuthClient = class {
|
|
|
2688
2725
|
url.hash = "";
|
|
2689
2726
|
redirectUri = url.toString();
|
|
2690
2727
|
}
|
|
2728
|
+
const baseUrl = config.baseUrl || config.apiUrl || DEFAULT_API_URL;
|
|
2729
|
+
const authUrl = config.authUrl || baseUrl + "/oauth/authorize";
|
|
2730
|
+
const tokenUrl = config.tokenUrl || baseUrl + "/oauth/token";
|
|
2731
|
+
const apiUrl = config.apiUrl || baseUrl;
|
|
2691
2732
|
this.config = {
|
|
2692
2733
|
clientId: config.clientId,
|
|
2693
2734
|
redirectUri: redirectUri || "",
|
|
2694
2735
|
scopes: config.scopes || ["read", "write"],
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2736
|
+
baseUrl,
|
|
2737
|
+
authUrl,
|
|
2738
|
+
tokenUrl,
|
|
2739
|
+
apiUrl,
|
|
2698
2740
|
usePKCE: config.usePKCE !== false,
|
|
2699
2741
|
// Default true
|
|
2700
2742
|
storagePrefix: config.storagePrefix || "mindcache_oauth"
|
|
2701
2743
|
};
|
|
2744
|
+
console.log("\u{1F510} MindCache OAuth Config:", {
|
|
2745
|
+
baseUrl: this.config.baseUrl,
|
|
2746
|
+
authUrl: this.config.authUrl,
|
|
2747
|
+
tokenUrl: this.config.tokenUrl,
|
|
2748
|
+
apiUrl: this.config.apiUrl,
|
|
2749
|
+
clientId: this.config.clientId.substring(0, 20) + "..."
|
|
2750
|
+
});
|
|
2751
|
+
this.validateApi();
|
|
2702
2752
|
this.loadTokens();
|
|
2703
2753
|
}
|
|
2754
|
+
/**
|
|
2755
|
+
* Validate the API is reachable and warn about common misconfigurations
|
|
2756
|
+
*/
|
|
2757
|
+
async validateApi() {
|
|
2758
|
+
try {
|
|
2759
|
+
const response = await fetch(`${this.config.apiUrl}/oauth/apps/info`, {
|
|
2760
|
+
method: "GET",
|
|
2761
|
+
headers: { "Accept": "application/json" }
|
|
2762
|
+
});
|
|
2763
|
+
if (response.status === 404) {
|
|
2764
|
+
console.error(
|
|
2765
|
+
"\u274C MindCache OAuth ERROR: API not found at " + this.config.apiUrl + '\n The server returned 404. Common causes:\n - Wrong domain: Use "api.mindcache.dev" not "mindcache.dev"\n - Wrong port: Local dev server is usually on port 8787\n - Server not running: Make sure the MindCache server is started'
|
|
2766
|
+
);
|
|
2767
|
+
} else if (!response.ok) {
|
|
2768
|
+
console.warn(
|
|
2769
|
+
"\u26A0\uFE0F MindCache OAuth: API responded with status " + response.status + "\n URL: " + this.config.apiUrl
|
|
2770
|
+
);
|
|
2771
|
+
} else {
|
|
2772
|
+
console.log("\u2705 MindCache OAuth: API is reachable at " + this.config.apiUrl);
|
|
2773
|
+
}
|
|
2774
|
+
} catch (error) {
|
|
2775
|
+
console.error(
|
|
2776
|
+
"\u274C MindCache OAuth ERROR: Cannot reach API at " + this.config.apiUrl + "\n Error: " + (error instanceof Error ? error.message : String(error)) + "\n Check your network connection and baseUrl configuration."
|
|
2777
|
+
);
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2704
2780
|
/**
|
|
2705
2781
|
* Check if user is authenticated
|
|
2706
2782
|
*/
|