@bodhiapp/bodhi-js-core 0.0.39 → 0.0.41

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.
@@ -1,4 +1,4 @@
1
- import { AccessRequestStatusResponse, CreateAccessRequest, CreateAccessRequestResponse, DeploymentMode, PingResponse } from '@bodhiapp/ts-client';
1
+ import { CreateAccessRequest, CreateAccessRequestResponse, DeploymentMode, PingResponse } from '@bodhiapp/ts-client';
2
2
  import { ApiResponse } from '@bodhiapp/bodhi-browser-types';
3
3
  import { IDirectClient, StreamTextResult } from './interface';
4
4
  import { Logger } from './logger';
@@ -124,13 +124,7 @@ export declare abstract class DirectClientBase implements IDirectClient {
124
124
  */
125
125
  debug(): Promise<Record<string, unknown>>;
126
126
  requestAccess(body: CreateAccessRequest): Promise<ApiResponse<CreateAccessRequestResponse>>;
127
- getAccessRequestStatus(requestId: string): Promise<ApiResponse<AccessRequestStatusResponse>>;
128
- pollAccessRequestStatus(requestId: string, options?: {
129
- intervalMs?: number;
130
- timeoutMs?: number;
131
- }): Promise<AccessRequestStatusResponse>;
132
127
  abstract login(): Promise<AuthState>;
133
- protected abstract performOAuthPkce(scope: string): Promise<AuthState>;
134
128
  getAuthState(): Promise<AuthState>;
135
129
  logout(): Promise<AuthState>;
136
130
  protected _getAccessTokenRaw(): Promise<string | null>;
@@ -0,0 +1,28 @@
1
+ import { DirectClientBase } from './direct-client-base';
2
+ import { McpTransportConfig } from './mcp-fetch';
3
+ import { AuthState, IStorage, InitialTokens, LogLevel, StateChangeCallback } from './types';
4
+ export interface DirectClientConfig {
5
+ authClientId: string;
6
+ authServerUrl: string;
7
+ /** Optional: pre-bind the server URL so MCP transport works before `init()`. */
8
+ serverUrl?: string;
9
+ /** Returned by `_getRedirectUri()`; unused in headless mode. Defaults to ''. */
10
+ redirectUri?: string;
11
+ storagePrefix?: string;
12
+ logLevel?: LogLevel;
13
+ apiTimeoutMs?: number;
14
+ /** Defaults to a fresh `InMemoryStorage`. */
15
+ storage?: IStorage;
16
+ initialTokens?: InitialTokens;
17
+ }
18
+ export declare class DirectClient extends DirectClientBase {
19
+ private _redirectUri;
20
+ constructor(config: DirectClientConfig, onStateChange?: StateChangeCallback);
21
+ /**
22
+ * Direct-mode MCP transport: standard fetch with Bearer-token injection
23
+ * (token pulled fresh from getAuthState() so auto-refresh applies).
24
+ */
25
+ createMcpTransportConfig(mcp_path: string): McpTransportConfig;
26
+ login(): Promise<AuthState>;
27
+ protected _getRedirectUri(): string;
28
+ }
@@ -1,4 +1,4 @@
1
- import { AccessRequestStatusResponse, CreateAccessRequest, CreateAccessRequestResponse, PingResponse } from '@bodhiapp/ts-client';
1
+ import { CreateAccessRequest, CreateAccessRequestResponse, PingResponse } from '@bodhiapp/ts-client';
2
2
  import { ApiResponse } from '@bodhiapp/bodhi-browser-types';
3
3
  import { IConnectionClient, IExtensionClient, StreamTextResult } from './interface';
4
4
  import { Logger } from './logger';
@@ -105,11 +105,6 @@ export declare abstract class BaseFacadeClient<TConfig, TExtClient extends IExte
105
105
  logout(): Promise<AuthState>;
106
106
  getAuthState(): Promise<AuthState>;
107
107
  requestAccess(body: CreateAccessRequest): Promise<ApiResponse<CreateAccessRequestResponse>>;
108
- getAccessRequestStatus(requestId: string): Promise<ApiResponse<AccessRequestStatusResponse>>;
109
- pollAccessRequestStatus(requestId: string, options?: {
110
- intervalMs?: number;
111
- timeoutMs?: number;
112
- }): Promise<AccessRequestStatusResponse>;
113
108
  pingApi(): Promise<ApiResponse<PingResponse>>;
114
109
  getServerState(): Promise<BackendServerState>;
115
110
  stream<TReq = unknown, TRes = unknown>(method: string, endpoint: string, body?: TReq, headers?: Record<string, string>, authenticated?: boolean): AsyncGenerator<TRes>;
package/dist/index.d.ts CHANGED
@@ -9,7 +9,6 @@
9
9
  */
10
10
  export * from './types';
11
11
  export * from './access-request';
12
- export * from './review-manager';
13
12
  export * from './constants';
14
13
  export * from './logger';
15
14
  export * from './interface';
@@ -18,6 +17,7 @@ export * from './storage';
18
17
  export * from './onboarding';
19
18
  export * from './oauth';
20
19
  export * from './direct-client-base';
20
+ export * from './direct-client';
21
21
  export * from './facade-client-base';
22
22
  export * from './openai-client-compat';
23
23
  export { createDirectMcpFetch, createExtensionMcpFetch } from './mcp-fetch';
@@ -1,4 +1,4 @@
1
- import { AccessRequestStatusResponse, CreateAccessRequest, CreateAccessRequestResponse, PingResponse } from '@bodhiapp/ts-client';
1
+ import { CreateAccessRequest, CreateAccessRequestResponse, PingResponse } from '@bodhiapp/ts-client';
2
2
  import { ApiResponse } from '@bodhiapp/bodhi-browser-types';
3
3
  import { AuthState, BackendServerState, ClientState, ConnectionMode, DirectState, ExtensionState, InitParams, LoginOptions, StateChangeCallback } from './types';
4
4
  import { Chat, Models, Embeddings, Mcps } from './openai-client-compat';
@@ -114,19 +114,6 @@ export interface IConnectionClient<IParams = unknown, SerialState = unknown> {
114
114
  * @throws BodhiError on operational errors
115
115
  */
116
116
  requestAccess(body: CreateAccessRequest): Promise<ApiResponse<CreateAccessRequestResponse>>;
117
- /**
118
- * Get status of an access request
119
- * GET /bodhi/v1/apps/access-requests/{id}?app_client_id=xxx
120
- * @throws BodhiError on operational errors
121
- */
122
- getAccessRequestStatus(requestId: string): Promise<ApiResponse<AccessRequestStatusResponse>>;
123
- /**
124
- * Poll access request until approved/denied/failed/expired
125
- */
126
- pollAccessRequestStatus(requestId: string, options?: {
127
- intervalMs?: number;
128
- timeoutMs?: number;
129
- }): Promise<AccessRequestStatusResponse>;
130
117
  /**
131
118
  * Set or update the state change callback
132
119
  * Allows setting callback after construction (for React dependency injection)
@@ -281,11 +268,6 @@ export interface IWebUIClient extends UIClient {
281
268
  * @returns AuthLoggedIn with login state and user info
282
269
  */
283
270
  handleOAuthCallback(code: string, state: string): Promise<AuthState>;
284
- /**
285
- * Handle access request callback after redirect review (web only)
286
- * Called when user returns from review_url redirect
287
- */
288
- handleAccessRequestCallback(requestId: string): Promise<AuthState>;
289
271
  }
290
272
  /**
291
273
  * Type guard to check if client has OAuth callback handling (web mode)
package/dist/oauth.d.ts CHANGED
@@ -28,6 +28,17 @@ export interface OAuthEndpoints {
28
28
  * Create OAuth endpoints from auth server URL
29
29
  */
30
30
  export declare function createOAuthEndpoints(authServerUrl: string): OAuthEndpoints;
31
+ export declare const BASE_OAUTH_SCOPE = "openid profile email roles";
32
+ export declare const ACCESS_REQUEST_ERROR_MARKER = "access_request_error";
33
+ export declare function buildAuthorizeUrl(endpoints: OAuthEndpoints, params: {
34
+ clientId: string;
35
+ redirectUri: string;
36
+ scope: string;
37
+ state: string;
38
+ codeChallenge: string;
39
+ }): string;
40
+ export declare function buildReviewUrl(reviewUrl: string, authUrl: string, errorUrl: string): string;
41
+ export declare function buildErrorUrl(redirectUri: string): string;
31
42
  export interface RefreshTokenResponse {
32
43
  access_token: string;
33
44
  refresh_token?: string;
@@ -1,4 +1,4 @@
1
- import { FlowType, RequestedResourcesV1, UserScope } from '@bodhiapp/ts-client';
1
+ import { RequestedResourcesV1, UserScope } from '@bodhiapp/ts-client';
2
2
  /**
3
3
  * Shared types used by both ext2ext and web2ext clients
4
4
  */
@@ -16,11 +16,7 @@ export type LoginProgressCallback = (stage: LoginProgressStage) => void;
16
16
  export interface LoginOptions {
17
17
  userRole?: UserScope;
18
18
  requested?: RequestedResourcesV1;
19
- flowType?: FlowType;
20
- redirectUrl?: string;
21
19
  onProgress?: LoginProgressCallback;
22
- pollIntervalMs?: number;
23
- pollTimeoutMs?: number;
24
20
  }
25
21
  export type { BrowserInfo, OSInfo } from './platform';
26
22
  export { InMemoryStorage } from './storage';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bodhiapp/bodhi-js-core",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
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.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",
88
+ "@bodhiapp/bodhi-browser-types": "0.0.41",
89
+ "@bodhiapp/setup-modal-types": "0.0.41",
90
+ "@bodhiapp/setup-modal-v2-types": "0.0.41",
91
+ "@bodhiapp/ts-client": "0.1.36",
92
92
  "ua-parser-js": "^1.0.40"
93
93
  },
94
94
  "devDependencies": {
@@ -1,10 +0,0 @@
1
- export interface ReviewResult {
2
- approved: boolean;
3
- accessRequestScope?: string;
4
- status?: string;
5
- }
6
- export interface PollOptions {
7
- intervalMs?: number;
8
- timeoutMs?: number;
9
- }
10
- export declare function openPopupReview(reviewUrl: string, pollFn: () => Promise<ReviewResult | null>, options?: PollOptions): Promise<ReviewResult>;