@barndoor-ai/sdk 0.2.1 → 0.2.2

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.
Files changed (62) hide show
  1. package/README.md +6 -6
  2. package/{src/auth/index.ts → dist/auth/index.d.ts} +2 -17
  3. package/dist/auth/index.d.ts.map +1 -0
  4. package/dist/auth/pkce.d.ts +92 -0
  5. package/dist/auth/pkce.d.ts.map +1 -0
  6. package/dist/auth/store.d.ts +145 -0
  7. package/dist/auth/store.d.ts.map +1 -0
  8. package/dist/client.d.ts +164 -0
  9. package/dist/client.d.ts.map +1 -0
  10. package/dist/config.d.ts +144 -0
  11. package/dist/config.d.ts.map +1 -0
  12. package/dist/exceptions/index.d.ts +119 -0
  13. package/dist/exceptions/index.d.ts.map +1 -0
  14. package/dist/http/client.d.ts +82 -0
  15. package/dist/http/client.d.ts.map +1 -0
  16. package/dist/index.d.ts +39 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.esm.js +2 -0
  19. package/dist/index.js +2 -0
  20. package/dist/logging.d.ts +48 -0
  21. package/dist/logging.d.ts.map +1 -0
  22. package/dist/models/index.d.ts +116 -0
  23. package/dist/models/index.d.ts.map +1 -0
  24. package/dist/quickstart.d.ts +91 -0
  25. package/dist/quickstart.d.ts.map +1 -0
  26. package/dist/version.d.ts +17 -0
  27. package/dist/version.d.ts.map +1 -0
  28. package/package.json +8 -2
  29. package/.eslintignore +0 -8
  30. package/.eslintrc.cjs +0 -102
  31. package/.github/CODEOWNERS +0 -4
  32. package/.github/workflows/ci.yml +0 -57
  33. package/.prettierignore +0 -6
  34. package/.prettierrc +0 -13
  35. package/RELEASE.md +0 -203
  36. package/examples/README.md +0 -92
  37. package/examples/basic-mcp-client.js +0 -134
  38. package/examples/openai-integration.js +0 -137
  39. package/jest.config.js +0 -16
  40. package/openapi.yaml +0 -681
  41. package/rollup.config.js +0 -63
  42. package/scripts/dump-core-files.js +0 -161
  43. package/scripts/dump-typescript-only.js +0 -150
  44. package/src/auth/pkce.ts +0 -346
  45. package/src/auth/store.ts +0 -809
  46. package/src/client.ts +0 -512
  47. package/src/config.ts +0 -402
  48. package/src/exceptions/index.ts +0 -205
  49. package/src/http/client.ts +0 -272
  50. package/src/index.ts +0 -92
  51. package/src/logging.ts +0 -111
  52. package/src/models/index.ts +0 -156
  53. package/src/quickstart.ts +0 -358
  54. package/src/version.ts +0 -41
  55. package/test/client.test.js +0 -381
  56. package/test/config.test.js +0 -202
  57. package/test/exceptions.test.js +0 -142
  58. package/test/integration.test.js +0 -147
  59. package/test/models.test.js +0 -177
  60. package/test/token-management.test.js +0 -81
  61. package/test/token-validation.test.js +0 -104
  62. package/tsconfig.json +0 -61
package/README.md CHANGED
@@ -21,7 +21,7 @@ npm install @barndoor-ai/sdk
21
21
  ### Basic Usage
22
22
 
23
23
  ```typescript
24
- import { BarndoorSDK } from '@barndoor/sdk';
24
+ import { BarndoorSDK } from '@barndoor-ai/sdk';
25
25
 
26
26
  // ① token known at construction time (unchanged)
27
27
  const sdk = new BarndoorSDK('https://your-org.mcp.barndoor.ai', {
@@ -53,7 +53,7 @@ For development and prototyping, use the interactive login helper:
53
53
  `loginInteractive()` builds an SDK *without* requiring `token` in the ctor—it internally calls `sdk.authenticate()` for you.
54
54
 
55
55
  ```typescript
56
- import { loginInteractive } from '@barndoor/sdk';
56
+ import { loginInteractive } from '@barndoor-ai/sdk';
57
57
 
58
58
  // Automatically handles OAuth flow and token caching
59
59
  const sdk = await loginInteractive();
@@ -67,7 +67,7 @@ import {
67
67
  loginInteractive,
68
68
  ensureServerConnected,
69
69
  makeMcpConnectionParams
70
- } from '@barndoor/sdk';
70
+ } from '@barndoor-ai/sdk';
71
71
 
72
72
  async function main() {
73
73
  // 1. Login (handles OAuth + caching)
@@ -242,7 +242,7 @@ import {
242
242
  ConnectionError,
243
243
  TokenError,
244
244
  ConfigurationError
245
- } from '@barndoor/sdk';
245
+ } from '@barndoor-ai/sdk';
246
246
 
247
247
  try {
248
248
  await sdk.listServers();
@@ -265,7 +265,7 @@ The SDK works in both Node.js and browser environments:
265
265
 
266
266
  ```typescript
267
267
  // Browser usage
268
- import { BarndoorSDK } from '@barndoor/sdk';
268
+ import { BarndoorSDK } from '@barndoor-ai/sdk';
269
269
 
270
270
  // Token storage uses localStorage in browsers
271
271
  const sdk = new BarndoorSDK('https://api.barndoor.ai', {
@@ -289,7 +289,7 @@ See the `examples/` directory for complete working examples:
289
289
  The SDK is written in TypeScript and includes full type definitions:
290
290
 
291
291
  ```typescript
292
- import { BarndoorSDK, ServerSummary } from '@barndoor/sdk';
292
+ import { BarndoorSDK, ServerSummary } from '@barndoor-ai/sdk';
293
293
 
294
294
  const sdk = new BarndoorSDK('https://api.barndoor.ai', {
295
295
  token: 'your-token'
@@ -4,23 +4,8 @@
4
4
  * This module provides a unified interface for authentication functionality,
5
5
  * including PKCE OAuth flows, token storage, and interactive login.
6
6
  */
7
-
8
7
  export { PKCEManager, startLocalCallbackServer } from './pkce';
9
-
10
- export {
11
- getTokenStorage,
12
- TokenManager,
13
- loadUserToken,
14
- saveUserToken,
15
- clearCachedToken,
16
- verifyJWTLocal,
17
- JWTVerificationResult,
18
- isTokenActive,
19
- isTokenActiveWithRefresh,
20
- validateToken,
21
- setTokenLogger,
22
- } from './store';
23
-
24
- // Re-export types
8
+ export { getTokenStorage, TokenManager, loadUserToken, saveUserToken, clearCachedToken, verifyJWTLocal, JWTVerificationResult, isTokenActive, isTokenActiveWithRefresh, validateToken, setTokenLogger, } from './store';
25
9
  export type { AuthorizationUrlParams, TokenExchangeParams, PKCEState } from './pkce';
26
10
  export type { TokenData } from './store';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAE/D,OAAO,EACL,eAAe,EACf,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,wBAAwB,EACxB,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrF,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * PKCE (Proof Key for Code Exchange) implementation for OAuth 2.0.
3
+ *
4
+ * This module provides PKCE functionality that mirrors the Python SDK's
5
+ * auth.py implementation, supporting secure OAuth flows in both browser
6
+ * and Node.js environments.
7
+ */
8
+ /**
9
+ * PKCE state data structure.
10
+ */
11
+ export interface PKCEState {
12
+ /** Code verifier for PKCE flow */
13
+ codeVerifier: string;
14
+ /** Code challenge derived from verifier */
15
+ codeChallenge: string;
16
+ /** OAuth state parameter */
17
+ state: string;
18
+ /** Timestamp when state was created */
19
+ timestamp: number;
20
+ }
21
+ /**
22
+ * PKCE Manager class to handle state per instance instead of globally.
23
+ * This prevents race conditions in browser environments with multiple parallel login flows.
24
+ */
25
+ export declare class PKCEManager {
26
+ private _codeVerifier;
27
+ private _currentState;
28
+ private readonly _logger;
29
+ /**
30
+ * Generate PKCE parameters and build authorization URL.
31
+ * @param params - Authorization parameters
32
+ * @returns Authorization URL
33
+ */
34
+ buildAuthorizationUrl({ domain, clientId, redirectUri, audience, scope, }: AuthorizationUrlParams): Promise<string>;
35
+ /**
36
+ * Exchange authorization code for tokens using stored PKCE state.
37
+ * @param params - Token exchange parameters
38
+ * @returns Token response
39
+ */
40
+ exchangeCodeForToken({ domain, clientId, code, redirectUri, clientSecret, }: TokenExchangeParams): Promise<unknown>;
41
+ /**
42
+ * Validate state parameter to prevent CSRF attacks.
43
+ * @param receivedState - State received from OAuth callback
44
+ * @returns True if state is valid
45
+ */
46
+ validateState(receivedState: string): boolean;
47
+ /**
48
+ * Clear PKCE state (for cleanup or error handling).
49
+ */
50
+ clearState(): void;
51
+ /**
52
+ * Get current PKCE state (for debugging/testing).
53
+ */
54
+ getState(): PKCEState | null;
55
+ }
56
+ /**
57
+ * Authorization URL parameters.
58
+ */
59
+ export interface AuthorizationUrlParams {
60
+ /** Auth0 domain */
61
+ domain: string;
62
+ /** OAuth client ID */
63
+ clientId: string;
64
+ /** Redirect URI */
65
+ redirectUri: string;
66
+ /** API audience */
67
+ audience: string;
68
+ /** OAuth scopes */
69
+ scope?: string;
70
+ }
71
+ /**
72
+ * Token exchange parameters.
73
+ */
74
+ export interface TokenExchangeParams {
75
+ /** Auth0 domain */
76
+ domain: string;
77
+ /** OAuth client ID */
78
+ clientId: string;
79
+ /** Authorization code */
80
+ code: string;
81
+ /** Redirect URI */
82
+ redirectUri: string;
83
+ /** Client secret (for backend flows) */
84
+ clientSecret?: string;
85
+ }
86
+ /**
87
+ * Start a local callback server for OAuth redirect (Node.js only).
88
+ * @param port - Port to listen on
89
+ * @returns [redirectUri, waiter] tuple
90
+ */
91
+ export declare function startLocalCallbackServer(port?: number): [string, Promise<[string, string]>];
92
+ //# sourceMappingURL=pkce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pkce.d.ts","sourceRoot":"","sources":["../../src/auth/pkce.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IAEtD;;;;OAIG;IACU,qBAAqB,CAAC,EACjC,MAAM,EACN,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,KAA8B,GAC/B,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAsB3C;;;;OAIG;IACU,oBAAoB,CAAC,EAChC,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,YAAY,GACb,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IA0DzC;;;;OAIG;IACI,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;IAIpD;;OAEG;IACI,UAAU,IAAI,IAAI;IAKzB;;OAEG;IACI,QAAQ,IAAI,SAAS,GAAG,IAAI;CAWpC;AAmED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,SAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAsE1F"}
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Token storage and management.
3
+ *
4
+ * This module provides token storage that works in both browser and Node.js
5
+ * environments, mirroring the Python SDK's auth_store functionality.
6
+ */
7
+ import { Logger } from '../logging';
8
+ /**
9
+ * Set a custom logger for the token management module.
10
+ * @deprecated Use setLogger from the main logging module instead
11
+ */
12
+ export declare function setTokenLogger(_logger: Logger): void;
13
+ /**
14
+ * Token data structure for storage.
15
+ */
16
+ export interface TokenData {
17
+ /** Access token for API requests */
18
+ access_token: string;
19
+ /** Optional refresh token */
20
+ refresh_token?: string;
21
+ /** Token type (usually 'Bearer') */
22
+ token_type?: string;
23
+ /** Token expiration time in seconds */
24
+ expires_in?: number;
25
+ /** Token scope */
26
+ scope?: string;
27
+ /** Additional token properties */
28
+ [key: string]: unknown;
29
+ }
30
+ /**
31
+ * JWT verification result.
32
+ */
33
+ export declare enum JWTVerificationResult {
34
+ VALID = "valid",
35
+ EXPIRED = "expired",
36
+ INVALID = "invalid"
37
+ }
38
+ /**
39
+ * Abstract base class for token storage.
40
+ */
41
+ declare abstract class TokenStorage {
42
+ /**
43
+ * Load token data from storage.
44
+ * @returns Token data or null if not found
45
+ */
46
+ abstract loadToken(): Promise<TokenData | null>;
47
+ /**
48
+ * Save token data to storage.
49
+ * @param tokenData - Token data to save
50
+ */
51
+ abstract saveToken(tokenData: TokenData): Promise<void>;
52
+ /**
53
+ * Clear token data from storage.
54
+ */
55
+ abstract clearToken(): Promise<void>;
56
+ }
57
+ /**
58
+ * Get the appropriate token storage for the current environment.
59
+ * @returns Token storage instance
60
+ */
61
+ export declare function getTokenStorage(): TokenStorage;
62
+ /**
63
+ * Verify JWT locally using JWKS.
64
+ * @param token - JWT token to verify
65
+ * @param authDomain - Auth0 domain
66
+ * @param audience - Expected audience
67
+ * @returns Verification result
68
+ */
69
+ export declare function verifyJWTLocal(token: string, authDomain: string, audience: string): Promise<JWTVerificationResult>;
70
+ /**
71
+ * Token manager that handles storage, validation, and refresh.
72
+ */
73
+ export declare class TokenManager {
74
+ /** Token storage instance */
75
+ private readonly storage;
76
+ /** Mutex to prevent concurrent refresh operations */
77
+ private readonly _refreshMutex;
78
+ /**
79
+ * Create a new TokenManager.
80
+ * @param _apiBaseUrl - Base URL for the API (currently unused)
81
+ */
82
+ constructor(_apiBaseUrl: string);
83
+ /**
84
+ * Get a valid token, refreshing if necessary.
85
+ * @returns Valid access token
86
+ */
87
+ getValidToken(): Promise<string>;
88
+ /**
89
+ * Check if token should be refreshed proactively.
90
+ * @private
91
+ */
92
+ private _shouldRefreshToken;
93
+ /**
94
+ * Validate token using fast-path local verification with remote fallback.
95
+ * @private
96
+ */
97
+ private _validateOrRefresh;
98
+ /**
99
+ * Validate token remotely using Auth0's userinfo endpoint.
100
+ * @private
101
+ */
102
+ private _isTokenValidRemote;
103
+ /**
104
+ * Refresh the access token using the refresh token.
105
+ * @private
106
+ */
107
+ private _refreshToken;
108
+ }
109
+ /**
110
+ * Load user token from storage.
111
+ * @returns User access token or null if not found
112
+ */
113
+ export declare function loadUserToken(): Promise<string | null>;
114
+ /**
115
+ * Save user token to storage.
116
+ * @param token - Token string or token data object
117
+ */
118
+ export declare function saveUserToken(token: string | TokenData): Promise<void>;
119
+ /**
120
+ * Clear cached token.
121
+ */
122
+ export declare function clearCachedToken(): Promise<void>;
123
+ /**
124
+ * Check if cached token is active without attempting refresh.
125
+ * @param apiBaseUrl - Base URL of the API (for compatibility, not used)
126
+ * @returns True if token is active
127
+ */
128
+ export declare function isTokenActive(_apiBaseUrl?: string): Promise<boolean>;
129
+ /**
130
+ * Check if cached token is active, attempting refresh if needed.
131
+ * @param apiBaseUrl - Base URL of the API (for compatibility, not used)
132
+ * @returns True if token is active or was successfully refreshed
133
+ */
134
+ export declare function isTokenActiveWithRefresh(apiBaseUrl?: string): Promise<boolean>;
135
+ /**
136
+ * Validate a token using fast-path local verification with remote fallback.
137
+ * @param token - The JWT token to validate
138
+ * @param apiBaseUrl - Base URL of the API (for compatibility, not used)
139
+ * @returns Dictionary with 'valid' key indicating if token is valid
140
+ */
141
+ export declare function validateToken(token: string, _apiBaseUrl?: string): Promise<{
142
+ valid: boolean;
143
+ }>;
144
+ export {};
145
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/auth/store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAsB,MAAM,EAAE,MAAM,YAAY,CAAC;AASxD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAGpD;AAqDD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,oCAAoC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,oBAAY,qBAAqB;IAC/B,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AA4GD;;GAEG;AACH,uBAAe,YAAY;IACzB;;;OAGG;IACH,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAE/C;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAEvD;;OAEG;IACH,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CACrC;AA+HD;;;GAGG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAQ9C;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,qBAAqB,CAAC,CAqBhC;AAyCD;;GAEG;AACH,qBAAa,YAAY;IACvB,6BAA6B;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,qDAAqD;IACrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAE7C;;;OAGG;gBACS,WAAW,EAAE,MAAM;IAI/B;;;OAGG;IACU,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IA8B7C;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAW3B;;;OAGG;YACW,kBAAkB;IAgChC;;;OAGG;YACW,mBAAmB;IAoBjC;;;OAGG;YACW,aAAa;CA8F5B;AAID;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQ5D;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAW5E;AAED;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAGtD;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA2B1E;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CASpF;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAqC7B"}
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Main Barndoor SDK client.
3
+ *
4
+ * This module provides the primary BarndoorSDK class that mirrors the Python
5
+ * SDK's client.py functionality with 100% API compatibility.
6
+ */
7
+ import { ServerSummary, ServerDetail } from './models';
8
+ /**
9
+ * Configuration options for BarndoorSDK constructor.
10
+ */
11
+ export interface BarndoorSDKOptions {
12
+ /** User JWT token (optional - can be set later via authenticate()) */
13
+ token?: string;
14
+ /** Whether to validate token on initialization */
15
+ validateTokenOnInit?: boolean;
16
+ /** Request timeout in seconds */
17
+ timeout?: number;
18
+ /** Maximum number of retries */
19
+ maxRetries?: number;
20
+ }
21
+ /**
22
+ * Options for ensureServerConnected method.
23
+ */
24
+ export interface EnsureServerConnectedOptions {
25
+ /** Maximum seconds to wait for connection */
26
+ pollSeconds?: number;
27
+ }
28
+ /**
29
+ * Response from server connection initiation.
30
+ */
31
+ export interface ConnectionInitiationResponse {
32
+ /** OAuth authorization URL */
33
+ auth_url?: string;
34
+ [key: string]: unknown;
35
+ }
36
+ /**
37
+ * Response from connection status check.
38
+ */
39
+ export interface ConnectionStatusResponse {
40
+ /** Current connection status */
41
+ status: string;
42
+ }
43
+ /**
44
+ * Async client for interacting with the Barndoor Platform API.
45
+ *
46
+ * This SDK provides methods to:
47
+ * - Manage server connections and OAuth flows
48
+ * - List available MCP servers
49
+ * - Validate user tokens
50
+ *
51
+ * The client handles authentication automatically by including the user's
52
+ * JWT token in all requests.
53
+ */
54
+ export declare class BarndoorSDK {
55
+ /** Base URL of the Barndoor API */
56
+ readonly base: string;
57
+ /** User JWT token */
58
+ private _token;
59
+ /** HTTP client instance */
60
+ private readonly _http;
61
+ /** Whether token has been validated */
62
+ private _tokenValidated;
63
+ /** Whether the SDK has been closed */
64
+ private _closed;
65
+ /** Scoped logger for this SDK instance */
66
+ private readonly _logger;
67
+ /**
68
+ * Create a new BarndoorSDK instance.
69
+ * @param apiBaseUrl - Base URL of the Barndoor API
70
+ * @param options - Configuration options (token is optional)
71
+ */
72
+ constructor(apiBaseUrl: string, options?: BarndoorSDKOptions);
73
+ /**
74
+ * Get the current token.
75
+ */
76
+ get token(): string;
77
+ /**
78
+ * Set authentication token for the SDK.
79
+ * @param token - JWT token to use for authentication
80
+ */
81
+ authenticate(token: string): Promise<void>;
82
+ /**
83
+ * Validate URL format.
84
+ * @private
85
+ */
86
+ private _validateUrl;
87
+ /**
88
+ * Validate token format.
89
+ * @private
90
+ */
91
+ private _validateToken;
92
+ /**
93
+ * Ensure the SDK hasn't been closed.
94
+ * @private
95
+ */
96
+ private _ensureNotClosed;
97
+ /**
98
+ * Make authenticated request with automatic token validation.
99
+ * @private
100
+ */
101
+ private _req;
102
+ /**
103
+ * Validate the cached token by making a test API call.
104
+ * @returns True if the token is valid
105
+ */
106
+ validateCachedToken(): Promise<boolean>;
107
+ /**
108
+ * Ensure token is valid, validating if necessary.
109
+ */
110
+ ensureValidToken(): Promise<void>;
111
+ /**
112
+ * List all MCP servers available to the caller's organization.
113
+ * @returns Array of server summaries
114
+ */
115
+ listServers(): Promise<ServerSummary[]>;
116
+ /**
117
+ * Get detailed information about a specific server.
118
+ * @param serverId - Server ID
119
+ * @returns Server details
120
+ */
121
+ getServer(serverId: string): Promise<ServerDetail>;
122
+ /**
123
+ * Initiate OAuth connection flow for a server.
124
+ * @param serverId - Server ID
125
+ * @param returnUrl - Optional return URL
126
+ * @returns Connection initiation response
127
+ */
128
+ initiateConnection(serverId: string, returnUrl?: string): Promise<ConnectionInitiationResponse>;
129
+ /**
130
+ * Get the user's connection status for a specific server.
131
+ * @param serverId - Server ID
132
+ * @returns Connection status
133
+ */
134
+ getConnectionStatus(serverId: string): Promise<string>;
135
+ /**
136
+ * Disconnect from a specific MCP server.
137
+ *
138
+ * This will remove the connection record and clean up any stored OAuth credentials.
139
+ * The user will need to reconnect to use this server again.
140
+ *
141
+ * @param serverId - Server ID or slug to disconnect from
142
+ */
143
+ disconnectServer(serverId: string): Promise<void>;
144
+ /**
145
+ * Validate server ID format.
146
+ * @private
147
+ */
148
+ private _validateServerId;
149
+ /**
150
+ * Close the SDK and clean up resources.
151
+ */
152
+ close(): Promise<void>;
153
+ /**
154
+ * Alias for close() to match Python SDK naming.
155
+ */
156
+ aclose(): Promise<void>;
157
+ /**
158
+ * Ensure a server is connected, initiating OAuth if needed.
159
+ * @param serverIdentifier - Server slug or provider name
160
+ * @param options - Options
161
+ */
162
+ ensureServerConnected(serverIdentifier: string, options?: EnsureServerConnectedOptions): Promise<void>;
163
+ }
164
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAOvD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAsBD;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,WAAW;IACtB,mCAAmC;IACnC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,qBAAqB;IACrB,OAAO,CAAC,MAAM,CAAgB;IAC9B,2BAA2B;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,uCAAuC;IACvC,OAAO,CAAC,eAAe,CAAU;IACjC,sCAAsC;IACtC,OAAO,CAAC,OAAO,CAAU;IACzB,0CAA0C;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;IAExD;;;;OAIG;gBACS,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB;IA2BhE;;OAEG;IACH,IAAW,KAAK,IAAI,MAAM,CAOzB;IAED;;;OAGG;IACU,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUvD;;;OAGG;IACH,OAAO,CAAC,YAAY;IAapB;;;OAGG;IACH,OAAO,CAAC,cAAc;IActB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;;OAGG;YACW,IAAI;IAelB;;;OAGG;IACU,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC;IAyBpD;;OAEG;IACU,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB9C;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAapD;;;;OAIG;IACU,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAQ/D;;;;;OAKG;IACU,kBAAkB,CAC7B,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,4BAA4B,CAAC;IAiCxC;;;;OAIG;IACU,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAWnE;;;;;;;OAOG;IACU,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB9D;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAkBzB;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAOnC;;OAEG;IACU,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC;;;;OAIG;IACU,qBAAqB,CAChC,gBAAgB,EAAE,MAAM,EACxB,OAAO,GAAE,4BAAiC,GACzC,OAAO,CAAC,IAAI,CAAC;CA4EjB"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Configuration management for the Barndoor SDK.
3
+ *
4
+ * This module provides unified configuration that mirrors the Python SDK's
5
+ * configuration system, supporting environment-specific defaults and
6
+ * dynamic organization ID substitution.
7
+ */
8
+ /**
9
+ * Environment detection utilities
10
+ *
11
+ * Improved detection that works correctly under bundlers where process gets shimmed.
12
+ * We check for window first since that's the most reliable browser indicator.
13
+ */
14
+ export declare const isBrowser: boolean;
15
+ export declare const isNode: boolean;
16
+ /**
17
+ * Browser window with optional ENV object for environment variables.
18
+ */
19
+ declare global {
20
+ interface Window {
21
+ ENV?: Record<string, string>;
22
+ }
23
+ }
24
+ /**
25
+ * Configuration options for BarndoorConfig constructor.
26
+ */
27
+ export interface BarndoorConfigOptions {
28
+ /** Auth0 domain */
29
+ authDomain?: string;
30
+ /** OAuth client ID */
31
+ clientId?: string;
32
+ /** OAuth client secret */
33
+ clientSecret?: string;
34
+ /** API audience identifier */
35
+ apiAudience?: string;
36
+ /** API base URL template */
37
+ apiBaseUrl?: string;
38
+ /** MCP base URL template */
39
+ mcpBaseUrl?: string;
40
+ /** Environment name */
41
+ environment?: string;
42
+ /** Whether to prompt for login */
43
+ promptForLogin?: boolean;
44
+ /** Whether to skip login in local environment */
45
+ skipLoginLocal?: boolean;
46
+ }
47
+ /**
48
+ * Unified configuration for the Barndoor SDK.
49
+ *
50
+ * Mirrors the Python SDK's BarndoorConfig class with environment-specific
51
+ * defaults and support for organization ID templating.
52
+ */
53
+ export declare class BarndoorConfig {
54
+ /** Auth0 domain */
55
+ authDomain: string;
56
+ /** OAuth client ID */
57
+ clientId: string;
58
+ /** OAuth client secret */
59
+ clientSecret: string;
60
+ /** API audience identifier */
61
+ apiAudience: string;
62
+ /** API base URL template */
63
+ apiBaseUrl: string;
64
+ /** MCP base URL template */
65
+ mcpBaseUrl: string;
66
+ /** Environment name */
67
+ environment: string;
68
+ /** Whether to prompt for login */
69
+ promptForLogin: boolean;
70
+ /** Whether to skip login in local environment */
71
+ skipLoginLocal: boolean;
72
+ /**
73
+ * Create a new BarndoorConfig instance.
74
+ * @param options - Configuration options
75
+ */
76
+ constructor(options?: BarndoorConfigOptions);
77
+ /**
78
+ * Set environment-specific default URLs.
79
+ * @private
80
+ */
81
+ private _setEnvironmentDefaults;
82
+ /**
83
+ * Get static configuration (without organization ID substitution).
84
+ * @returns Static configuration instance
85
+ */
86
+ static getStaticConfig(): BarndoorConfig;
87
+ /**
88
+ * Get dynamic configuration with organization ID substituted.
89
+ * @param jwtToken - JWT token to extract organization ID from
90
+ * @param options - Configuration options
91
+ * @returns Dynamic configuration instance
92
+ */
93
+ static getDynamicConfig(jwtToken: string, options?: {
94
+ /** Whether to throw error for tokens without organization info */
95
+ requireOrganization?: boolean;
96
+ /** Fallback organization ID to use if none found in token */
97
+ fallbackOrganizationId?: string;
98
+ }): BarndoorConfig;
99
+ /**
100
+ * Validate the configuration.
101
+ * @throws ConfigurationError if configuration is invalid
102
+ */
103
+ validate(): void;
104
+ }
105
+ /**
106
+ * Result of organization ID extraction from JWT token.
107
+ */
108
+ interface OrganizationExtractionResult {
109
+ /** Organization ID if found */
110
+ organizationId?: string;
111
+ /** Whether organization ID was found */
112
+ hasOrganization: boolean;
113
+ /** Error message if extraction failed */
114
+ error?: string;
115
+ }
116
+ /**
117
+ * Get static configuration instance.
118
+ * @returns Static configuration instance
119
+ */
120
+ export declare function getStaticConfig(): BarndoorConfig;
121
+ /**
122
+ * Get dynamic configuration with organization ID substituted.
123
+ * @param jwtToken - JWT token
124
+ * @param options - Configuration options
125
+ * @returns Dynamic configuration instance
126
+ */
127
+ export declare function getDynamicConfig(jwtToken: string, options?: {
128
+ requireOrganization?: boolean;
129
+ fallbackOrganizationId?: string;
130
+ }): BarndoorConfig;
131
+ /**
132
+ * Check if a JWT token contains organization information.
133
+ * @param jwtToken - JWT token to check
134
+ * @returns Object with organization info and any error details
135
+ */
136
+ export declare function checkTokenOrganization(jwtToken: string): OrganizationExtractionResult;
137
+ /**
138
+ * Check if a JWT token has organization information (simple boolean check).
139
+ * @param jwtToken - JWT token to check
140
+ * @returns True if token contains organization information
141
+ */
142
+ export declare function hasOrganizationInfo(jwtToken: string): boolean;
143
+ export {};
144
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