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.d.mts
CHANGED
|
@@ -20,6 +20,8 @@ interface OAuthConfig {
|
|
|
20
20
|
authUrl?: string;
|
|
21
21
|
/** MindCache token URL (default: production) */
|
|
22
22
|
tokenUrl?: string;
|
|
23
|
+
/** MindCache API URL for WebSocket token exchange (default: production) */
|
|
24
|
+
apiUrl?: string;
|
|
23
25
|
/** Use PKCE for security (default: true) */
|
|
24
26
|
usePKCE?: boolean;
|
|
25
27
|
/** Storage key prefix (default: 'mindcache_oauth') */
|
|
@@ -109,10 +111,16 @@ declare class OAuthClient {
|
|
|
109
111
|
*/
|
|
110
112
|
private clearAuth;
|
|
111
113
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
* Token provider for MindCache cloud config
|
|
115
|
+
* This fetches a WebSocket token (short-lived) using the OAuth access token
|
|
116
|
+
* Use this with MindCacheCloudOptions.tokenProvider
|
|
117
|
+
*/
|
|
115
118
|
tokenProvider: () => Promise<string>;
|
|
119
|
+
/**
|
|
120
|
+
* Get raw OAuth access token (for API calls, not WebSocket)
|
|
121
|
+
* Use getAccessToken() for most cases
|
|
122
|
+
*/
|
|
123
|
+
accessTokenProvider: () => Promise<string>;
|
|
116
124
|
private getStorage;
|
|
117
125
|
private setStorage;
|
|
118
126
|
private removeStorage;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ interface OAuthConfig {
|
|
|
20
20
|
authUrl?: string;
|
|
21
21
|
/** MindCache token URL (default: production) */
|
|
22
22
|
tokenUrl?: string;
|
|
23
|
+
/** MindCache API URL for WebSocket token exchange (default: production) */
|
|
24
|
+
apiUrl?: string;
|
|
23
25
|
/** Use PKCE for security (default: true) */
|
|
24
26
|
usePKCE?: boolean;
|
|
25
27
|
/** Storage key prefix (default: 'mindcache_oauth') */
|
|
@@ -109,10 +111,16 @@ declare class OAuthClient {
|
|
|
109
111
|
*/
|
|
110
112
|
private clearAuth;
|
|
111
113
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
* Token provider for MindCache cloud config
|
|
115
|
+
* This fetches a WebSocket token (short-lived) using the OAuth access token
|
|
116
|
+
* Use this with MindCacheCloudOptions.tokenProvider
|
|
117
|
+
*/
|
|
115
118
|
tokenProvider: () => Promise<string>;
|
|
119
|
+
/**
|
|
120
|
+
* Get raw OAuth access token (for API calls, not WebSocket)
|
|
121
|
+
* Use getAccessToken() for most cases
|
|
122
|
+
*/
|
|
123
|
+
accessTokenProvider: () => Promise<string>;
|
|
116
124
|
private getStorage;
|
|
117
125
|
private setStorage;
|
|
118
126
|
private removeStorage;
|
package/dist/index.js
CHANGED
|
@@ -395,10 +395,12 @@ var init_CloudAdapter = __esm({
|
|
|
395
395
|
try {
|
|
396
396
|
if (typeof event.data === "string") {
|
|
397
397
|
const msg = JSON.parse(event.data);
|
|
398
|
+
console.log("\u2601\uFE0F CloudAdapter: Received JSON message:", msg.type, msg);
|
|
398
399
|
if (msg.type === "auth_success") {
|
|
399
400
|
this._state = "connected";
|
|
400
401
|
this.reconnectAttempts = 0;
|
|
401
402
|
this.emit("connected");
|
|
403
|
+
console.log("\u2601\uFE0F Connected to MindCache cloud");
|
|
402
404
|
} else if (msg.type === "auth_error" || msg.type === "error") {
|
|
403
405
|
this._state = "error";
|
|
404
406
|
this.emit("error", new Error(msg.error));
|
|
@@ -406,6 +408,7 @@ var init_CloudAdapter = __esm({
|
|
|
406
408
|
console.debug("MindCache Cloud: Received message type:", msg.type, msg);
|
|
407
409
|
}
|
|
408
410
|
} else {
|
|
411
|
+
console.log("\u2601\uFE0F CloudAdapter: Received binary message, length:", event.data.byteLength);
|
|
409
412
|
const encoder = encoding__namespace.createEncoder();
|
|
410
413
|
const decoder = decoding__namespace.createDecoder(new Uint8Array(event.data));
|
|
411
414
|
if (this.mindcache) {
|
|
@@ -416,6 +419,7 @@ var init_CloudAdapter = __esm({
|
|
|
416
419
|
if (!this._synced && (messageType === 1 || messageType === 2)) {
|
|
417
420
|
this._synced = true;
|
|
418
421
|
this.emit("synced");
|
|
422
|
+
console.log("\u2601\uFE0F Synced with cloud");
|
|
419
423
|
}
|
|
420
424
|
}
|
|
421
425
|
}
|
|
@@ -2690,6 +2694,7 @@ var OAuthClient = class {
|
|
|
2690
2694
|
scopes: config.scopes || ["read", "write"],
|
|
2691
2695
|
authUrl: config.authUrl || DEFAULT_AUTH_URL,
|
|
2692
2696
|
tokenUrl: config.tokenUrl || DEFAULT_TOKEN_URL,
|
|
2697
|
+
apiUrl: config.apiUrl || (config.tokenUrl || DEFAULT_TOKEN_URL).replace("/oauth/token", ""),
|
|
2693
2698
|
usePKCE: config.usePKCE !== false,
|
|
2694
2699
|
// Default true
|
|
2695
2700
|
storagePrefix: config.storagePrefix || "mindcache_oauth"
|
|
@@ -2914,10 +2919,39 @@ var OAuthClient = class {
|
|
|
2914
2919
|
this.removeStorage("tokens");
|
|
2915
2920
|
}
|
|
2916
2921
|
/**
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2922
|
+
* Token provider for MindCache cloud config
|
|
2923
|
+
* This fetches a WebSocket token (short-lived) using the OAuth access token
|
|
2924
|
+
* Use this with MindCacheCloudOptions.tokenProvider
|
|
2925
|
+
*/
|
|
2920
2926
|
tokenProvider = async () => {
|
|
2927
|
+
const accessToken = await this.getAccessToken();
|
|
2928
|
+
const instanceId = this.getInstanceId();
|
|
2929
|
+
if (!instanceId) {
|
|
2930
|
+
throw new Error("No instance ID available. Complete OAuth flow first.");
|
|
2931
|
+
}
|
|
2932
|
+
const response = await fetch(`${this.config.apiUrl}/api/ws-token`, {
|
|
2933
|
+
method: "POST",
|
|
2934
|
+
headers: {
|
|
2935
|
+
"Content-Type": "application/json",
|
|
2936
|
+
"Authorization": `Bearer ${accessToken}`
|
|
2937
|
+
},
|
|
2938
|
+
body: JSON.stringify({
|
|
2939
|
+
instanceId,
|
|
2940
|
+
permission: "write"
|
|
2941
|
+
})
|
|
2942
|
+
});
|
|
2943
|
+
if (!response.ok) {
|
|
2944
|
+
const data2 = await response.json().catch(() => ({}));
|
|
2945
|
+
throw new Error(data2.error || "Failed to get WebSocket token");
|
|
2946
|
+
}
|
|
2947
|
+
const data = await response.json();
|
|
2948
|
+
return data.token;
|
|
2949
|
+
};
|
|
2950
|
+
/**
|
|
2951
|
+
* Get raw OAuth access token (for API calls, not WebSocket)
|
|
2952
|
+
* Use getAccessToken() for most cases
|
|
2953
|
+
*/
|
|
2954
|
+
accessTokenProvider = async () => {
|
|
2921
2955
|
return this.getAccessToken();
|
|
2922
2956
|
};
|
|
2923
2957
|
// Storage helpers
|