mindcache 3.4.3 → 3.5.0
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.md +22 -0
- package/dist/{CloudAdapter-CJS3Sh4f.d.mts → CloudAdapter-CM7nyJaG.d.mts} +85 -25
- package/dist/{CloudAdapter-CJS3Sh4f.d.ts → CloudAdapter-CM7nyJaG.d.ts} +85 -25
- package/dist/cloud/index.d.mts +2 -2
- package/dist/cloud/index.d.ts +2 -2
- package/dist/cloud/index.js +1105 -729
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/index.mjs +1105 -729
- package/dist/cloud/index.mjs.map +1 -1
- package/dist/index.d.mts +125 -3
- package/dist/index.d.ts +125 -3
- package/dist/index.js +1527 -832
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1526 -833
- 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 +1105 -731
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +1105 -731
- package/dist/server.mjs.map +1 -1
- package/docs/mindcache-api.md +148 -0
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,130 @@
|
|
|
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,
|
|
1
|
+
import { e as MindCacheOptions, M as MindCache } from './CloudAdapter-CM7nyJaG.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-CM7nyJaG.mjs';
|
|
3
3
|
export { IndexedDBAdapter, IndexedDBConfig } from './server.mjs';
|
|
4
4
|
import 'yjs';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* MindCache OAuth Client
|
|
8
|
+
*
|
|
9
|
+
* Browser-compatible OAuth 2.0 client for "Sign in with MindCache"
|
|
10
|
+
* Supports PKCE for secure authorization
|
|
11
|
+
*/
|
|
12
|
+
interface OAuthConfig {
|
|
13
|
+
/** Client ID from developer portal */
|
|
14
|
+
clientId: string;
|
|
15
|
+
/** Redirect URI (defaults to current URL) */
|
|
16
|
+
redirectUri?: string;
|
|
17
|
+
/** Scopes to request (default: ['read', 'write']) */
|
|
18
|
+
scopes?: string[];
|
|
19
|
+
/** MindCache authorize URL (default: production) */
|
|
20
|
+
authUrl?: string;
|
|
21
|
+
/** MindCache token URL (default: production) */
|
|
22
|
+
tokenUrl?: string;
|
|
23
|
+
/** Use PKCE for security (default: true) */
|
|
24
|
+
usePKCE?: boolean;
|
|
25
|
+
/** Storage key prefix (default: 'mindcache_oauth') */
|
|
26
|
+
storagePrefix?: string;
|
|
27
|
+
}
|
|
28
|
+
interface OAuthTokens {
|
|
29
|
+
accessToken: string;
|
|
30
|
+
refreshToken?: string;
|
|
31
|
+
expiresAt: number;
|
|
32
|
+
scopes: string[];
|
|
33
|
+
instanceId?: string;
|
|
34
|
+
}
|
|
35
|
+
interface MindCacheUser {
|
|
36
|
+
id: string;
|
|
37
|
+
email?: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
instanceId?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* OAuth client for browser applications
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const oauth = new OAuthClient({ clientId: 'mc_app_abc123' });
|
|
47
|
+
*
|
|
48
|
+
* // Start OAuth flow
|
|
49
|
+
* await oauth.authorize();
|
|
50
|
+
*
|
|
51
|
+
* // Handle callback (on redirect page)
|
|
52
|
+
* const tokens = await oauth.handleCallback();
|
|
53
|
+
*
|
|
54
|
+
* // Get access token for API calls
|
|
55
|
+
* const token = await oauth.getAccessToken();
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
declare class OAuthClient {
|
|
59
|
+
private config;
|
|
60
|
+
private tokens;
|
|
61
|
+
private refreshPromise;
|
|
62
|
+
constructor(config: OAuthConfig);
|
|
63
|
+
/**
|
|
64
|
+
* Check if user is authenticated
|
|
65
|
+
*/
|
|
66
|
+
isAuthenticated(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Get stored tokens (if any)
|
|
69
|
+
*/
|
|
70
|
+
getTokens(): OAuthTokens | null;
|
|
71
|
+
/**
|
|
72
|
+
* Get instance ID for this user+app
|
|
73
|
+
*/
|
|
74
|
+
getInstanceId(): string | null;
|
|
75
|
+
/**
|
|
76
|
+
* Start OAuth authorization flow
|
|
77
|
+
* Redirects to MindCache authorization page
|
|
78
|
+
*/
|
|
79
|
+
authorize(options?: {
|
|
80
|
+
popup?: boolean;
|
|
81
|
+
state?: string;
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Handle OAuth callback
|
|
85
|
+
* Call this on your redirect URI page
|
|
86
|
+
*
|
|
87
|
+
* @returns Tokens if successful
|
|
88
|
+
*/
|
|
89
|
+
handleCallback(): Promise<OAuthTokens>;
|
|
90
|
+
/**
|
|
91
|
+
* Get a valid access token
|
|
92
|
+
* Automatically refreshes if needed
|
|
93
|
+
*/
|
|
94
|
+
getAccessToken(): Promise<string>;
|
|
95
|
+
/**
|
|
96
|
+
* Refresh access token
|
|
97
|
+
*/
|
|
98
|
+
private refreshTokens;
|
|
99
|
+
/**
|
|
100
|
+
* Get user info from MindCache
|
|
101
|
+
*/
|
|
102
|
+
getUserInfo(): Promise<MindCacheUser>;
|
|
103
|
+
/**
|
|
104
|
+
* Logout - revoke tokens and clear storage
|
|
105
|
+
*/
|
|
106
|
+
logout(): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Clear authentication state
|
|
109
|
+
*/
|
|
110
|
+
private clearAuth;
|
|
111
|
+
/**
|
|
112
|
+
* Token provider function for MindCache cloud config
|
|
113
|
+
* Use this with MindCacheCloudOptions.tokenProvider
|
|
114
|
+
*/
|
|
115
|
+
tokenProvider: () => Promise<string>;
|
|
116
|
+
private getStorage;
|
|
117
|
+
private setStorage;
|
|
118
|
+
private removeStorage;
|
|
119
|
+
private clearStorage;
|
|
120
|
+
private loadTokens;
|
|
121
|
+
private saveTokens;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Create OAuth client with environment-appropriate defaults
|
|
125
|
+
*/
|
|
126
|
+
declare function createOAuthClient(config: OAuthConfig): OAuthClient;
|
|
127
|
+
|
|
6
128
|
interface UseMindCacheResult {
|
|
7
129
|
/** The MindCache instance, null until loaded */
|
|
8
130
|
mindcache: MindCache | null;
|
|
@@ -34,4 +156,4 @@ declare function useMindCache(options?: MindCacheOptions): UseMindCacheResult;
|
|
|
34
156
|
|
|
35
157
|
declare const mindcache: MindCache;
|
|
36
158
|
|
|
37
|
-
export { MindCache, MindCacheOptions, type UseMindCacheResult, mindcache, useMindCache };
|
|
159
|
+
export { MindCache, MindCacheOptions, type MindCacheUser, OAuthClient, type OAuthConfig, type OAuthTokens, type UseMindCacheResult, createOAuthClient, mindcache, useMindCache };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,130 @@
|
|
|
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,
|
|
1
|
+
import { e as MindCacheOptions, M as MindCache } from './CloudAdapter-CM7nyJaG.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-CM7nyJaG.js';
|
|
3
3
|
export { IndexedDBAdapter, IndexedDBConfig } from './server.js';
|
|
4
4
|
import 'yjs';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* MindCache OAuth Client
|
|
8
|
+
*
|
|
9
|
+
* Browser-compatible OAuth 2.0 client for "Sign in with MindCache"
|
|
10
|
+
* Supports PKCE for secure authorization
|
|
11
|
+
*/
|
|
12
|
+
interface OAuthConfig {
|
|
13
|
+
/** Client ID from developer portal */
|
|
14
|
+
clientId: string;
|
|
15
|
+
/** Redirect URI (defaults to current URL) */
|
|
16
|
+
redirectUri?: string;
|
|
17
|
+
/** Scopes to request (default: ['read', 'write']) */
|
|
18
|
+
scopes?: string[];
|
|
19
|
+
/** MindCache authorize URL (default: production) */
|
|
20
|
+
authUrl?: string;
|
|
21
|
+
/** MindCache token URL (default: production) */
|
|
22
|
+
tokenUrl?: string;
|
|
23
|
+
/** Use PKCE for security (default: true) */
|
|
24
|
+
usePKCE?: boolean;
|
|
25
|
+
/** Storage key prefix (default: 'mindcache_oauth') */
|
|
26
|
+
storagePrefix?: string;
|
|
27
|
+
}
|
|
28
|
+
interface OAuthTokens {
|
|
29
|
+
accessToken: string;
|
|
30
|
+
refreshToken?: string;
|
|
31
|
+
expiresAt: number;
|
|
32
|
+
scopes: string[];
|
|
33
|
+
instanceId?: string;
|
|
34
|
+
}
|
|
35
|
+
interface MindCacheUser {
|
|
36
|
+
id: string;
|
|
37
|
+
email?: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
instanceId?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* OAuth client for browser applications
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const oauth = new OAuthClient({ clientId: 'mc_app_abc123' });
|
|
47
|
+
*
|
|
48
|
+
* // Start OAuth flow
|
|
49
|
+
* await oauth.authorize();
|
|
50
|
+
*
|
|
51
|
+
* // Handle callback (on redirect page)
|
|
52
|
+
* const tokens = await oauth.handleCallback();
|
|
53
|
+
*
|
|
54
|
+
* // Get access token for API calls
|
|
55
|
+
* const token = await oauth.getAccessToken();
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
declare class OAuthClient {
|
|
59
|
+
private config;
|
|
60
|
+
private tokens;
|
|
61
|
+
private refreshPromise;
|
|
62
|
+
constructor(config: OAuthConfig);
|
|
63
|
+
/**
|
|
64
|
+
* Check if user is authenticated
|
|
65
|
+
*/
|
|
66
|
+
isAuthenticated(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Get stored tokens (if any)
|
|
69
|
+
*/
|
|
70
|
+
getTokens(): OAuthTokens | null;
|
|
71
|
+
/**
|
|
72
|
+
* Get instance ID for this user+app
|
|
73
|
+
*/
|
|
74
|
+
getInstanceId(): string | null;
|
|
75
|
+
/**
|
|
76
|
+
* Start OAuth authorization flow
|
|
77
|
+
* Redirects to MindCache authorization page
|
|
78
|
+
*/
|
|
79
|
+
authorize(options?: {
|
|
80
|
+
popup?: boolean;
|
|
81
|
+
state?: string;
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Handle OAuth callback
|
|
85
|
+
* Call this on your redirect URI page
|
|
86
|
+
*
|
|
87
|
+
* @returns Tokens if successful
|
|
88
|
+
*/
|
|
89
|
+
handleCallback(): Promise<OAuthTokens>;
|
|
90
|
+
/**
|
|
91
|
+
* Get a valid access token
|
|
92
|
+
* Automatically refreshes if needed
|
|
93
|
+
*/
|
|
94
|
+
getAccessToken(): Promise<string>;
|
|
95
|
+
/**
|
|
96
|
+
* Refresh access token
|
|
97
|
+
*/
|
|
98
|
+
private refreshTokens;
|
|
99
|
+
/**
|
|
100
|
+
* Get user info from MindCache
|
|
101
|
+
*/
|
|
102
|
+
getUserInfo(): Promise<MindCacheUser>;
|
|
103
|
+
/**
|
|
104
|
+
* Logout - revoke tokens and clear storage
|
|
105
|
+
*/
|
|
106
|
+
logout(): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Clear authentication state
|
|
109
|
+
*/
|
|
110
|
+
private clearAuth;
|
|
111
|
+
/**
|
|
112
|
+
* Token provider function for MindCache cloud config
|
|
113
|
+
* Use this with MindCacheCloudOptions.tokenProvider
|
|
114
|
+
*/
|
|
115
|
+
tokenProvider: () => Promise<string>;
|
|
116
|
+
private getStorage;
|
|
117
|
+
private setStorage;
|
|
118
|
+
private removeStorage;
|
|
119
|
+
private clearStorage;
|
|
120
|
+
private loadTokens;
|
|
121
|
+
private saveTokens;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Create OAuth client with environment-appropriate defaults
|
|
125
|
+
*/
|
|
126
|
+
declare function createOAuthClient(config: OAuthConfig): OAuthClient;
|
|
127
|
+
|
|
6
128
|
interface UseMindCacheResult {
|
|
7
129
|
/** The MindCache instance, null until loaded */
|
|
8
130
|
mindcache: MindCache | null;
|
|
@@ -34,4 +156,4 @@ declare function useMindCache(options?: MindCacheOptions): UseMindCacheResult;
|
|
|
34
156
|
|
|
35
157
|
declare const mindcache: MindCache;
|
|
36
158
|
|
|
37
|
-
export { MindCache, MindCacheOptions, type UseMindCacheResult, mindcache, useMindCache };
|
|
159
|
+
export { MindCache, MindCacheOptions, type MindCacheUser, OAuthClient, type OAuthConfig, type OAuthTokens, type UseMindCacheResult, createOAuthClient, mindcache, useMindCache };
|