@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
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Exception classes for the Barndoor SDK.
3
+ *
4
+ * This module provides a complete hierarchy of error classes that mirror
5
+ * the Python SDK exceptions exactly, ensuring API compatibility.
6
+ */
7
+ /**
8
+ * Base exception for all Barndoor SDK errors.
9
+ */
10
+ export declare class BarndoorError extends Error {
11
+ /**
12
+ * Create a new BarndoorError.
13
+ * @param message - Error message
14
+ */
15
+ constructor(message: string);
16
+ }
17
+ /**
18
+ * Raised when authentication fails.
19
+ */
20
+ export declare class AuthenticationError extends BarndoorError {
21
+ /** Optional error code for specific authentication failures */
22
+ readonly errorCode: string | null;
23
+ /**
24
+ * Create a new AuthenticationError.
25
+ * @param message - Error message
26
+ * @param errorCode - Optional error code
27
+ */
28
+ constructor(message: string, errorCode?: string | null);
29
+ }
30
+ /**
31
+ * Raised when token operations fail.
32
+ */
33
+ export declare class TokenError extends AuthenticationError {
34
+ /** Optional help text for resolving the error */
35
+ readonly helpText: string | null;
36
+ /**
37
+ * Create a new TokenError.
38
+ * @param message - Error message
39
+ * @param helpText - Optional help text
40
+ */
41
+ constructor(message: string, helpText?: string | null);
42
+ }
43
+ /**
44
+ * Raised when a token has expired.
45
+ */
46
+ export declare class TokenExpiredError extends TokenError {
47
+ }
48
+ /**
49
+ * Raised when token validation fails.
50
+ */
51
+ export declare class TokenValidationError extends TokenError {
52
+ }
53
+ /**
54
+ * Raised when unable to connect to the Barndoor API.
55
+ */
56
+ export declare class ConnectionError extends BarndoorError {
57
+ /** The URL that failed to connect */
58
+ readonly url: string;
59
+ /** The original error that caused the connection failure */
60
+ readonly originalError: Error;
61
+ /**
62
+ * Create a new ConnectionError.
63
+ * @param url - The URL that failed to connect
64
+ * @param originalError - The original error that caused the failure
65
+ */
66
+ constructor(url: string, originalError: Error);
67
+ }
68
+ /**
69
+ * Raised for HTTP error responses.
70
+ */
71
+ export declare class HTTPError extends BarndoorError {
72
+ /** HTTP status code */
73
+ readonly statusCode: number;
74
+ /** Raw response body */
75
+ readonly responseBody: string | null;
76
+ /**
77
+ * Create a new HTTPError.
78
+ * @param statusCode - HTTP status code
79
+ * @param message - Error message
80
+ * @param responseBody - Raw response body
81
+ */
82
+ constructor(statusCode: number, message: string, responseBody?: string | null);
83
+ /**
84
+ * Create a user-friendly error message based on HTTP status code.
85
+ * @private
86
+ */
87
+ private static _createUserFriendlyMessage;
88
+ }
89
+ /**
90
+ * Raised when a requested server is not found.
91
+ */
92
+ export declare class ServerNotFoundError extends BarndoorError {
93
+ /** The server identifier that was not found */
94
+ readonly serverIdentifier: string;
95
+ /** List of available servers, if provided */
96
+ readonly availableServers: string[] | null;
97
+ /**
98
+ * Create a new ServerNotFoundError.
99
+ * @param serverIdentifier - The server identifier that was not found
100
+ * @param availableServers - Optional list of available servers
101
+ */
102
+ constructor(serverIdentifier: string, availableServers?: string[] | null);
103
+ }
104
+ /**
105
+ * Raised when OAuth authentication fails.
106
+ */
107
+ export declare class OAuthError extends AuthenticationError {
108
+ }
109
+ /**
110
+ * Raised when there's an issue with SDK configuration.
111
+ */
112
+ export declare class ConfigurationError extends BarndoorError {
113
+ }
114
+ /**
115
+ * Raised when an operation times out.
116
+ */
117
+ export declare class TimeoutError extends BarndoorError {
118
+ }
119
+ //# sourceMappingURL=index.d.ts.map
@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AuB1C;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,+CAA+C;IAC/C,SAAgB,gBAAgB,EAAE,MAAM,CAAC;IACzC,6CAA6C;IAC7C,SAAgB,gBAAgB,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAElD;;;;OAIG;gBACS,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,GAAE,MAAM,EAAE,GAAG,IAAW;CAY/E;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,mBAAmB;CAAG;AAEtD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,aAAa;CAAG;AAExD;;GAEG;AACH,qBAAa,YAAa,SAAQ,aAAa;CAAG"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * HTTP client with retry logic and error handling.
3
+ *
4
+ * This module provides a robust HTTP client that mirrors the Python SDK's
5
+ * HTTP client functionality, including automatic retries, timeout handling,
6
+ * and proper error conversion.
7
+ */
8
+ /**
9
+ * HTTP request options interface.
10
+ */
11
+ export interface HTTPRequestOptions {
12
+ /** Request headers */
13
+ headers?: Record<string, string>;
14
+ /** JSON body to send */
15
+ json?: unknown;
16
+ /** Query parameters */
17
+ params?: Record<string, string | number | boolean>;
18
+ /** Additional fetch options */
19
+ [key: string]: unknown;
20
+ }
21
+ /**
22
+ * Timeout configuration for HTTP requests.
23
+ */
24
+ export declare class TimeoutConfig {
25
+ /** Read timeout in milliseconds */
26
+ readonly read: number;
27
+ /** Connect timeout in milliseconds */
28
+ readonly connect: number;
29
+ /**
30
+ * Create a new TimeoutConfig.
31
+ * @param read - Read timeout in seconds
32
+ * @param connect - Connect timeout in seconds
33
+ */
34
+ constructor(read?: number, connect?: number);
35
+ }
36
+ /**
37
+ * HTTP client with automatic retries and error handling.
38
+ *
39
+ * Provides a consistent interface for making HTTP requests with proper
40
+ * error handling, timeout management, and retry logic.
41
+ */
42
+ export declare class HTTPClient {
43
+ /** Timeout configuration */
44
+ private readonly timeoutConfig;
45
+ /** Maximum number of retries */
46
+ private readonly maxRetries;
47
+ /** Whether the client has been closed */
48
+ closed: boolean;
49
+ /**
50
+ * Create a new HTTPClient.
51
+ * @param timeoutConfig - Timeout configuration
52
+ * @param maxRetries - Maximum number of retries
53
+ */
54
+ constructor(timeoutConfig?: TimeoutConfig, maxRetries?: number);
55
+ /**
56
+ * Make an HTTP request with retry logic.
57
+ * @param method - HTTP method
58
+ * @param url - Request URL
59
+ * @param options - Request options
60
+ * @returns Response data
61
+ */
62
+ request(method: string, url: string, options?: HTTPRequestOptions): Promise<unknown>;
63
+ /**
64
+ * Build URL with query parameters.
65
+ * @private
66
+ */
67
+ private _buildUrl;
68
+ /**
69
+ * Sleep for the specified number of milliseconds.
70
+ * @private
71
+ */
72
+ private _sleep;
73
+ /**
74
+ * Close the HTTP client and clean up resources.
75
+ */
76
+ close(): Promise<void>;
77
+ /**
78
+ * Alias for close() to match Python SDK naming.
79
+ */
80
+ aclose(): Promise<void>;
81
+ }
82
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/http/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,wBAAwB;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACnD,+BAA+B;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,mCAAmC;IACnC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,sCAAsC;IACtC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAEhC;;;;OAIG;gBACS,IAAI,SAAK,EAAE,OAAO,SAAK;CAIpC;AAED;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,4BAA4B;IAC5B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,gCAAgC;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,yCAAyC;IAClC,MAAM,EAAE,OAAO,CAAC;IAEvB;;;;OAIG;gBACS,aAAa,gBAAsB,EAAE,UAAU,SAAI;IAM/D;;;;;;OAMG;IACU,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,OAAO,CAAC;IAuJnB;;;OAGG;IACH,OAAO,CAAC,SAAS;IAejB;;;OAGG;IACH,OAAO,CAAC,MAAM;IAId;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC;;OAEG;IACU,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAGrC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Barndoor SDK - JavaScript client for the Barndoor Platform API.
3
+ *
4
+ * The Barndoor SDK provides a simple, async interface for interacting with
5
+ * the Barndoor platform, including:
6
+ *
7
+ * - User authentication and token management
8
+ * - MCP server discovery and connection
9
+ * - OAuth flow handling for third-party integrations
10
+ * - Agent credential exchange
11
+ *
12
+ * Quick Start
13
+ * -----------
14
+ * ```javascript
15
+ * import { BarndoorSDK } from '@barndoor-ai/sdk';
16
+ *
17
+ * const sdk = new BarndoorSDK('https://api.barndoor.host', {
18
+ * token: 'your_token'
19
+ * });
20
+ * const servers = await sdk.listServers();
21
+ * ```
22
+ *
23
+ * For interactive login:
24
+ * ```javascript
25
+ * import { loginInteractive } from '@barndoor-ai/sdk';
26
+ *
27
+ * const sdk = await loginInteractive();
28
+ * ```
29
+ */
30
+ export { BarndoorSDK } from './client';
31
+ export { BarndoorError, AuthenticationError, TokenError, TokenExpiredError, TokenValidationError, ConnectionError, HTTPError, ServerNotFoundError, OAuthError, ConfigurationError, TimeoutError, } from './exceptions';
32
+ export { ServerSummary, ServerDetail, AgentToken } from './models';
33
+ export { loginInteractive, ensureServerConnected, makeMcpConnectionParams, makeMcpClient, } from './quickstart';
34
+ export { PKCEManager, startLocalCallbackServer, loadUserToken, saveUserToken, clearCachedToken, verifyJWTLocal, JWTVerificationResult, isTokenActive, isTokenActiveWithRefresh, validateToken, TokenManager, setTokenLogger, } from './auth';
35
+ export { BarndoorConfig, getStaticConfig, getDynamicConfig, checkTokenOrganization, hasOrganizationInfo, isBrowser, isNode, } from './config';
36
+ export { setLogger, getLogger, createScopedLogger, debug, info, warn, error } from './logging';
37
+ export type { Logger } from './logging';
38
+ export { version } from './version';
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGnE,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,aAAa,GACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,wBAAwB,EACxB,aAAa,EACb,YAAY,EACZ,cAAc,GACf,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,SAAS,EACT,MAAM,GACP,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC/F,YAAY,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}