mindcache 3.5.0 → 3.5.1
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/cloud/index.js +4 -0
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/index.mjs +4 -0
- package/dist/cloud/index.mjs.map +1 -1
- package/dist/index.d.mts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +37 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -3
- package/dist/index.mjs.map +1 -1
- package/dist/server.js +4 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +4 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -367,10 +367,12 @@ var init_CloudAdapter = __esm({
|
|
|
367
367
|
try {
|
|
368
368
|
if (typeof event.data === "string") {
|
|
369
369
|
const msg = JSON.parse(event.data);
|
|
370
|
+
console.log("\u2601\uFE0F CloudAdapter: Received JSON message:", msg.type, msg);
|
|
370
371
|
if (msg.type === "auth_success") {
|
|
371
372
|
this._state = "connected";
|
|
372
373
|
this.reconnectAttempts = 0;
|
|
373
374
|
this.emit("connected");
|
|
375
|
+
console.log("\u2601\uFE0F Connected to MindCache cloud");
|
|
374
376
|
} else if (msg.type === "auth_error" || msg.type === "error") {
|
|
375
377
|
this._state = "error";
|
|
376
378
|
this.emit("error", new Error(msg.error));
|
|
@@ -378,6 +380,7 @@ var init_CloudAdapter = __esm({
|
|
|
378
380
|
console.debug("MindCache Cloud: Received message type:", msg.type, msg);
|
|
379
381
|
}
|
|
380
382
|
} else {
|
|
383
|
+
console.log("\u2601\uFE0F CloudAdapter: Received binary message, length:", event.data.byteLength);
|
|
381
384
|
const encoder = encoding.createEncoder();
|
|
382
385
|
const decoder = decoding.createDecoder(new Uint8Array(event.data));
|
|
383
386
|
if (this.mindcache) {
|
|
@@ -388,6 +391,7 @@ var init_CloudAdapter = __esm({
|
|
|
388
391
|
if (!this._synced && (messageType === 1 || messageType === 2)) {
|
|
389
392
|
this._synced = true;
|
|
390
393
|
this.emit("synced");
|
|
394
|
+
console.log("\u2601\uFE0F Synced with cloud");
|
|
391
395
|
}
|
|
392
396
|
}
|
|
393
397
|
}
|
|
@@ -2662,6 +2666,7 @@ var OAuthClient = class {
|
|
|
2662
2666
|
scopes: config.scopes || ["read", "write"],
|
|
2663
2667
|
authUrl: config.authUrl || DEFAULT_AUTH_URL,
|
|
2664
2668
|
tokenUrl: config.tokenUrl || DEFAULT_TOKEN_URL,
|
|
2669
|
+
apiUrl: config.apiUrl || (config.tokenUrl || DEFAULT_TOKEN_URL).replace("/oauth/token", ""),
|
|
2665
2670
|
usePKCE: config.usePKCE !== false,
|
|
2666
2671
|
// Default true
|
|
2667
2672
|
storagePrefix: config.storagePrefix || "mindcache_oauth"
|
|
@@ -2886,10 +2891,39 @@ var OAuthClient = class {
|
|
|
2886
2891
|
this.removeStorage("tokens");
|
|
2887
2892
|
}
|
|
2888
2893
|
/**
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2894
|
+
* Token provider for MindCache cloud config
|
|
2895
|
+
* This fetches a WebSocket token (short-lived) using the OAuth access token
|
|
2896
|
+
* Use this with MindCacheCloudOptions.tokenProvider
|
|
2897
|
+
*/
|
|
2892
2898
|
tokenProvider = async () => {
|
|
2899
|
+
const accessToken = await this.getAccessToken();
|
|
2900
|
+
const instanceId = this.getInstanceId();
|
|
2901
|
+
if (!instanceId) {
|
|
2902
|
+
throw new Error("No instance ID available. Complete OAuth flow first.");
|
|
2903
|
+
}
|
|
2904
|
+
const response = await fetch(`${this.config.apiUrl}/api/ws-token`, {
|
|
2905
|
+
method: "POST",
|
|
2906
|
+
headers: {
|
|
2907
|
+
"Content-Type": "application/json",
|
|
2908
|
+
"Authorization": `Bearer ${accessToken}`
|
|
2909
|
+
},
|
|
2910
|
+
body: JSON.stringify({
|
|
2911
|
+
instanceId,
|
|
2912
|
+
permission: "write"
|
|
2913
|
+
})
|
|
2914
|
+
});
|
|
2915
|
+
if (!response.ok) {
|
|
2916
|
+
const data2 = await response.json().catch(() => ({}));
|
|
2917
|
+
throw new Error(data2.error || "Failed to get WebSocket token");
|
|
2918
|
+
}
|
|
2919
|
+
const data = await response.json();
|
|
2920
|
+
return data.token;
|
|
2921
|
+
};
|
|
2922
|
+
/**
|
|
2923
|
+
* Get raw OAuth access token (for API calls, not WebSocket)
|
|
2924
|
+
* Use getAccessToken() for most cases
|
|
2925
|
+
*/
|
|
2926
|
+
accessTokenProvider = async () => {
|
|
2893
2927
|
return this.getAccessToken();
|
|
2894
2928
|
};
|
|
2895
2929
|
// Storage helpers
|