mindcache 3.5.2 → 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/index.d.mts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +44 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -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
|
@@ -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
|
@@ -2688,9 +2688,8 @@ init_CloudAdapter();
|
|
|
2688
2688
|
init_CloudAdapter();
|
|
2689
2689
|
|
|
2690
2690
|
// src/cloud/OAuthClient.ts
|
|
2691
|
-
var
|
|
2692
|
-
var
|
|
2693
|
-
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";
|
|
2694
2693
|
var TOKEN_REFRESH_BUFFER = 5 * 60 * 1e3;
|
|
2695
2694
|
function generateRandomString(length2) {
|
|
2696
2695
|
const array = new Uint8Array(length2);
|
|
@@ -2726,19 +2725,58 @@ var OAuthClient = class {
|
|
|
2726
2725
|
url.hash = "";
|
|
2727
2726
|
redirectUri = url.toString();
|
|
2728
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;
|
|
2729
2732
|
this.config = {
|
|
2730
2733
|
clientId: config.clientId,
|
|
2731
2734
|
redirectUri: redirectUri || "",
|
|
2732
2735
|
scopes: config.scopes || ["read", "write"],
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
+
baseUrl,
|
|
2737
|
+
authUrl,
|
|
2738
|
+
tokenUrl,
|
|
2739
|
+
apiUrl,
|
|
2736
2740
|
usePKCE: config.usePKCE !== false,
|
|
2737
2741
|
// Default true
|
|
2738
2742
|
storagePrefix: config.storagePrefix || "mindcache_oauth"
|
|
2739
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();
|
|
2740
2752
|
this.loadTokens();
|
|
2741
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
|
+
}
|
|
2742
2780
|
/**
|
|
2743
2781
|
* Check if user is authenticated
|
|
2744
2782
|
*/
|