@bodhiapp/bodhi-js-core 0.0.37 → 0.0.39
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/bodhi-core.cjs.js +7 -7
- package/dist/bodhi-core.esm.js +292 -245
- package/dist/cli/setup-modal.js +1 -1
- package/dist/direct-client-base.d.ts +27 -2
- package/dist/storage.d.ts +24 -7
- package/package.json +5 -5
|
@@ -55,6 +55,17 @@ export declare abstract class DirectClientBase implements IDirectClient {
|
|
|
55
55
|
protected authServerUrl: string;
|
|
56
56
|
protected authEndpoints: OAuthEndpoints;
|
|
57
57
|
protected storage: IStorage | null;
|
|
58
|
+
/**
|
|
59
|
+
* Base prefix for OAuth storage keys (pre-serverUrl scope).
|
|
60
|
+
* Captured from config; combined with current serverUrl to build `storageKeys`.
|
|
61
|
+
*/
|
|
62
|
+
private basePrefix;
|
|
63
|
+
/**
|
|
64
|
+
* OAuth storage keys scoped by (basePrefix, serverUrl). Rebuilt in `init()` whenever
|
|
65
|
+
* serverUrl is committed — tokens are namespaced per server to avoid presenting
|
|
66
|
+
* tokens issued by server A as though they were valid for server B.
|
|
67
|
+
* Undefined until `serverUrl` is set; guard auth-path access with `this.serverUrl`.
|
|
68
|
+
*/
|
|
58
69
|
protected storageKeys: StorageKeys;
|
|
59
70
|
protected state: DirectState;
|
|
60
71
|
private onStateChange;
|
|
@@ -137,8 +148,22 @@ export declare abstract class DirectClientBase implements IDirectClient {
|
|
|
137
148
|
*/
|
|
138
149
|
protected _storeRefreshedTokens(tokens: RefreshTokenResponse): Promise<void>;
|
|
139
150
|
protected exchangeCodeForTokens(code: string): Promise<void>;
|
|
140
|
-
protected revokeRefreshToken(): Promise<void>;
|
|
141
|
-
protected clearAuthStorage(): Promise<void>;
|
|
151
|
+
protected revokeRefreshToken(keys?: StorageKeys): Promise<void>;
|
|
152
|
+
protected clearAuthStorage(keys?: StorageKeys): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Rebuild OAuth storage keys using the current serverUrl.
|
|
155
|
+
* Called after serverUrl is committed in `init()`. No-op if serverUrl is null.
|
|
156
|
+
*/
|
|
157
|
+
protected rebuildStorageKeys(): void;
|
|
158
|
+
/**
|
|
159
|
+
* Revoke + purge OAuth tokens from a previous server URL's namespace. Called
|
|
160
|
+
* when the user switches servers: the new server would not recognize the old
|
|
161
|
+
* tokens anyway, and leaving them in storage is a security risk.
|
|
162
|
+
*
|
|
163
|
+
* Best-effort — if the old server is unreachable the revoke call fails silently
|
|
164
|
+
* (see `revokeRefreshToken`); storage is cleared regardless.
|
|
165
|
+
*/
|
|
166
|
+
private clearPreviousServerTokens;
|
|
142
167
|
private _bootstrapInitialTokens;
|
|
143
168
|
protected _storageGet(key: string): Promise<string | null>;
|
|
144
169
|
protected _storageSet(items: Record<string, string | number>): Promise<void>;
|
package/dist/storage.d.ts
CHANGED
|
@@ -31,17 +31,34 @@ export declare const STORAGE_PREFIXES: {
|
|
|
31
31
|
readonly WEB_EXT: "bodhi-js-sdk:web:ext:";
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Compose a storage prefix by joining a scope with an inner namespace segment.
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* Generic namespace composer — used for any namespace dimension (basePath, serverUrl,
|
|
37
|
+
* tenant, etc.). The first segment is appended with ':' and then the inner namespace
|
|
38
|
+
* segment is appended as-is. Callers are responsible for ensuring the inner segment
|
|
39
|
+
* ends with ':' if it is intended to be consumed as a `createStorageKeys` prefix.
|
|
39
40
|
*
|
|
40
41
|
* Examples:
|
|
41
|
-
* -
|
|
42
|
-
* -
|
|
42
|
+
* - createStoragePrefixWithNamespace('/', 'bodhi:web:') => '/:bodhi:web:'
|
|
43
|
+
* - createStoragePrefixWithNamespace('/app1/', 'bodhi:web:') => '/app1/:bodhi:web:'
|
|
43
44
|
*/
|
|
44
|
-
export declare function
|
|
45
|
+
export declare function createStoragePrefixWithNamespace(scope: string, namespace: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Extend a storage prefix with an encoded server URL segment for per-server isolation.
|
|
48
|
+
*
|
|
49
|
+
* Uses '::' as a unique boundary marker between the base namespace and the server URL
|
|
50
|
+
* segment, so the URL segment is unambiguously parseable even when other segments contain
|
|
51
|
+
* ':'. The URL is normalized (trailing slashes stripped, percent-encoded) so that ':' /
|
|
52
|
+
* '/' inside the URL do not collide with the prefix separators.
|
|
53
|
+
*
|
|
54
|
+
* Example:
|
|
55
|
+
* - createStoragePrefixWithServerUrl('/:bodhi-js-sdk:web:direct:', 'http://localhost:1135')
|
|
56
|
+
* => '/:bodhi-js-sdk:web:direct::http%3A%2F%2Flocalhost%3A1135:'
|
|
57
|
+
*
|
|
58
|
+
* @param basePrefix - Base prefix built with createStoragePrefixWithNamespace (ends with ':')
|
|
59
|
+
* @param serverUrl - Raw backend server URL (e.g., 'http://localhost:1135')
|
|
60
|
+
*/
|
|
61
|
+
export declare function createStoragePrefixWithServerUrl(basePrefix: string, serverUrl: string): string;
|
|
45
62
|
/**
|
|
46
63
|
* User Preferences Storage Manager
|
|
47
64
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bodhiapp/bodhi-js-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"description": "Core types and interfaces for Bodhi Browser SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/bodhi-core.cjs.js",
|
|
@@ -85,10 +85,10 @@
|
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@bodhiapp/bodhi-browser-types": "0.0.
|
|
89
|
-
"@bodhiapp/setup-modal-types": "0.0.
|
|
90
|
-
"@bodhiapp/setup-modal-v2-types": "0.0.
|
|
91
|
-
"@bodhiapp/ts-client": "0.1.
|
|
88
|
+
"@bodhiapp/bodhi-browser-types": "0.0.39",
|
|
89
|
+
"@bodhiapp/setup-modal-types": "0.0.39",
|
|
90
|
+
"@bodhiapp/setup-modal-v2-types": "0.0.39",
|
|
91
|
+
"@bodhiapp/ts-client": "0.1.32",
|
|
92
92
|
"ua-parser-js": "^1.0.40"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|