hornerosssp 0.1.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.
@@ -0,0 +1,161 @@
1
+ interface McpInfo {
2
+ slug: string;
3
+ name: string;
4
+ description: string | null;
5
+ requiredCredentials: string[];
6
+ toolCount: number;
7
+ activeConnections: number;
8
+ }
9
+ interface McpDetail extends McpInfo {
10
+ tools: {
11
+ name: string;
12
+ description: string;
13
+ }[];
14
+ }
15
+ interface ConnectionInfo {
16
+ id: string;
17
+ mcpSlug: string;
18
+ mcpName: string;
19
+ appName: string | null;
20
+ userId: string | null;
21
+ mcpUrl: string;
22
+ token: string;
23
+ status: "active" | "revoked";
24
+ lastUsedAt: string | null;
25
+ createdAt: string;
26
+ expiresAt: string | null;
27
+ }
28
+ interface ConnectionRequestData {
29
+ id: string;
30
+ mcpUrl: string | null;
31
+ token: string | null;
32
+ redirectUrl: string | null;
33
+ status: "active" | "pending";
34
+ }
35
+ interface InitiateConnectionParams {
36
+ mcpSlug: string;
37
+ appName?: string;
38
+ userId?: string;
39
+ credentials?: Record<string, string>;
40
+ authScheme?: ConnectionData;
41
+ }
42
+ interface ToolDefinition {
43
+ name: string;
44
+ description: string;
45
+ inputSchema: {
46
+ type: "object";
47
+ properties: Record<string, unknown>;
48
+ required?: string[];
49
+ };
50
+ }
51
+ interface ToolResult {
52
+ content: Array<{
53
+ type: "text";
54
+ text: string;
55
+ }>;
56
+ isError?: boolean;
57
+ }
58
+ interface ExecuteToolParams {
59
+ mcpSlug: string;
60
+ connectionId: string;
61
+ toolName: string;
62
+ arguments: Record<string, unknown>;
63
+ }
64
+ interface ConnectionData {
65
+ type: string;
66
+ data: Record<string, string>;
67
+ }
68
+ interface HornerosSSPConfig {
69
+ baseUrl: string;
70
+ }
71
+ interface ApiResponse<T> {
72
+ data: T;
73
+ }
74
+ interface ApiError {
75
+ error: string;
76
+ }
77
+
78
+ declare class Mcps {
79
+ private client;
80
+ constructor(client: HornerosSSP);
81
+ list(): Promise<McpInfo[]>;
82
+ get(slug: string): Promise<McpDetail>;
83
+ }
84
+
85
+ declare class ConnectionRequest {
86
+ private client;
87
+ readonly id: string;
88
+ readonly mcpUrl: string | null;
89
+ readonly token: string | null;
90
+ readonly redirectUrl: string | null;
91
+ readonly status: "active" | "pending";
92
+ constructor(client: HornerosSSP, data: ConnectionRequestData);
93
+ /**
94
+ * Polls the connection until it becomes active.
95
+ * Useful for OAuth/interactive flows where the user needs to
96
+ * complete authentication in a browser.
97
+ * @param timeout Max wait time in ms (default: 120000 = 2 min)
98
+ */
99
+ waitForConnection(timeout?: number): Promise<ConnectionInfo>;
100
+ }
101
+ declare class Connections {
102
+ private client;
103
+ constructor(client: HornerosSSP);
104
+ initiate(params: InitiateConnectionParams): Promise<ConnectionRequest>;
105
+ list(): Promise<ConnectionInfo[]>;
106
+ get(id: string): Promise<ConnectionInfo>;
107
+ revoke(id: string): Promise<void>;
108
+ }
109
+
110
+ declare class Tools {
111
+ private client;
112
+ constructor(client: HornerosSSP);
113
+ list(mcpSlug: string): Promise<ToolDefinition[]>;
114
+ execute(params: ExecuteToolParams): Promise<ToolResult>;
115
+ }
116
+
117
+ declare class HornerosSSP {
118
+ readonly mcps: Mcps;
119
+ readonly connections: Connections;
120
+ readonly tools: Tools;
121
+ private readonly baseUrl;
122
+ constructor(config: HornerosSSPConfig);
123
+ /** @internal */
124
+ fetch<T>(path: string, options?: RequestInit): Promise<T>;
125
+ }
126
+
127
+ declare class AuthScheme {
128
+ static APIKey(params: {
129
+ api_key: string;
130
+ [k: string]: string;
131
+ }): ConnectionData;
132
+ static Bearer(params: {
133
+ token: string;
134
+ }): ConnectionData;
135
+ static Basic(params: {
136
+ username: string;
137
+ password: string;
138
+ }): ConnectionData;
139
+ static OAuth2(params: {
140
+ access_token: string;
141
+ refresh_token?: string;
142
+ }): ConnectionData;
143
+ static GoogleLogin(): ConnectionData;
144
+ }
145
+
146
+ declare class HornerosError extends Error {
147
+ readonly statusCode: number;
148
+ readonly body: unknown;
149
+ constructor(message: string, statusCode: number, body?: unknown);
150
+ }
151
+ declare class NotFoundError extends HornerosError {
152
+ constructor(message: string, body?: unknown);
153
+ }
154
+ declare class ValidationError extends HornerosError {
155
+ constructor(message: string, body?: unknown);
156
+ }
157
+ declare class ConnectionTimeoutError extends HornerosError {
158
+ constructor(message?: string);
159
+ }
160
+
161
+ export { type ApiError, type ApiResponse, AuthScheme, type ConnectionData, type ConnectionInfo, ConnectionRequest, type ConnectionRequestData, ConnectionTimeoutError, Connections, type ExecuteToolParams, HornerosError, HornerosSSP, type HornerosSSPConfig, type InitiateConnectionParams, type McpDetail, type McpInfo, Mcps, NotFoundError, type ToolDefinition, type ToolResult, Tools, ValidationError };
@@ -0,0 +1,161 @@
1
+ interface McpInfo {
2
+ slug: string;
3
+ name: string;
4
+ description: string | null;
5
+ requiredCredentials: string[];
6
+ toolCount: number;
7
+ activeConnections: number;
8
+ }
9
+ interface McpDetail extends McpInfo {
10
+ tools: {
11
+ name: string;
12
+ description: string;
13
+ }[];
14
+ }
15
+ interface ConnectionInfo {
16
+ id: string;
17
+ mcpSlug: string;
18
+ mcpName: string;
19
+ appName: string | null;
20
+ userId: string | null;
21
+ mcpUrl: string;
22
+ token: string;
23
+ status: "active" | "revoked";
24
+ lastUsedAt: string | null;
25
+ createdAt: string;
26
+ expiresAt: string | null;
27
+ }
28
+ interface ConnectionRequestData {
29
+ id: string;
30
+ mcpUrl: string | null;
31
+ token: string | null;
32
+ redirectUrl: string | null;
33
+ status: "active" | "pending";
34
+ }
35
+ interface InitiateConnectionParams {
36
+ mcpSlug: string;
37
+ appName?: string;
38
+ userId?: string;
39
+ credentials?: Record<string, string>;
40
+ authScheme?: ConnectionData;
41
+ }
42
+ interface ToolDefinition {
43
+ name: string;
44
+ description: string;
45
+ inputSchema: {
46
+ type: "object";
47
+ properties: Record<string, unknown>;
48
+ required?: string[];
49
+ };
50
+ }
51
+ interface ToolResult {
52
+ content: Array<{
53
+ type: "text";
54
+ text: string;
55
+ }>;
56
+ isError?: boolean;
57
+ }
58
+ interface ExecuteToolParams {
59
+ mcpSlug: string;
60
+ connectionId: string;
61
+ toolName: string;
62
+ arguments: Record<string, unknown>;
63
+ }
64
+ interface ConnectionData {
65
+ type: string;
66
+ data: Record<string, string>;
67
+ }
68
+ interface HornerosSSPConfig {
69
+ baseUrl: string;
70
+ }
71
+ interface ApiResponse<T> {
72
+ data: T;
73
+ }
74
+ interface ApiError {
75
+ error: string;
76
+ }
77
+
78
+ declare class Mcps {
79
+ private client;
80
+ constructor(client: HornerosSSP);
81
+ list(): Promise<McpInfo[]>;
82
+ get(slug: string): Promise<McpDetail>;
83
+ }
84
+
85
+ declare class ConnectionRequest {
86
+ private client;
87
+ readonly id: string;
88
+ readonly mcpUrl: string | null;
89
+ readonly token: string | null;
90
+ readonly redirectUrl: string | null;
91
+ readonly status: "active" | "pending";
92
+ constructor(client: HornerosSSP, data: ConnectionRequestData);
93
+ /**
94
+ * Polls the connection until it becomes active.
95
+ * Useful for OAuth/interactive flows where the user needs to
96
+ * complete authentication in a browser.
97
+ * @param timeout Max wait time in ms (default: 120000 = 2 min)
98
+ */
99
+ waitForConnection(timeout?: number): Promise<ConnectionInfo>;
100
+ }
101
+ declare class Connections {
102
+ private client;
103
+ constructor(client: HornerosSSP);
104
+ initiate(params: InitiateConnectionParams): Promise<ConnectionRequest>;
105
+ list(): Promise<ConnectionInfo[]>;
106
+ get(id: string): Promise<ConnectionInfo>;
107
+ revoke(id: string): Promise<void>;
108
+ }
109
+
110
+ declare class Tools {
111
+ private client;
112
+ constructor(client: HornerosSSP);
113
+ list(mcpSlug: string): Promise<ToolDefinition[]>;
114
+ execute(params: ExecuteToolParams): Promise<ToolResult>;
115
+ }
116
+
117
+ declare class HornerosSSP {
118
+ readonly mcps: Mcps;
119
+ readonly connections: Connections;
120
+ readonly tools: Tools;
121
+ private readonly baseUrl;
122
+ constructor(config: HornerosSSPConfig);
123
+ /** @internal */
124
+ fetch<T>(path: string, options?: RequestInit): Promise<T>;
125
+ }
126
+
127
+ declare class AuthScheme {
128
+ static APIKey(params: {
129
+ api_key: string;
130
+ [k: string]: string;
131
+ }): ConnectionData;
132
+ static Bearer(params: {
133
+ token: string;
134
+ }): ConnectionData;
135
+ static Basic(params: {
136
+ username: string;
137
+ password: string;
138
+ }): ConnectionData;
139
+ static OAuth2(params: {
140
+ access_token: string;
141
+ refresh_token?: string;
142
+ }): ConnectionData;
143
+ static GoogleLogin(): ConnectionData;
144
+ }
145
+
146
+ declare class HornerosError extends Error {
147
+ readonly statusCode: number;
148
+ readonly body: unknown;
149
+ constructor(message: string, statusCode: number, body?: unknown);
150
+ }
151
+ declare class NotFoundError extends HornerosError {
152
+ constructor(message: string, body?: unknown);
153
+ }
154
+ declare class ValidationError extends HornerosError {
155
+ constructor(message: string, body?: unknown);
156
+ }
157
+ declare class ConnectionTimeoutError extends HornerosError {
158
+ constructor(message?: string);
159
+ }
160
+
161
+ export { type ApiError, type ApiResponse, AuthScheme, type ConnectionData, type ConnectionInfo, ConnectionRequest, type ConnectionRequestData, ConnectionTimeoutError, Connections, type ExecuteToolParams, HornerosError, HornerosSSP, type HornerosSSPConfig, type InitiateConnectionParams, type McpDetail, type McpInfo, Mcps, NotFoundError, type ToolDefinition, type ToolResult, Tools, ValidationError };
package/dist/index.js ADDED
@@ -0,0 +1,258 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AuthScheme: () => AuthScheme,
24
+ ConnectionRequest: () => ConnectionRequest,
25
+ ConnectionTimeoutError: () => ConnectionTimeoutError,
26
+ Connections: () => Connections,
27
+ HornerosError: () => HornerosError,
28
+ HornerosSSP: () => HornerosSSP,
29
+ Mcps: () => Mcps,
30
+ NotFoundError: () => NotFoundError,
31
+ Tools: () => Tools,
32
+ ValidationError: () => ValidationError
33
+ });
34
+ module.exports = __toCommonJS(index_exports);
35
+
36
+ // src/errors.ts
37
+ var HornerosError = class extends Error {
38
+ constructor(message, statusCode, body) {
39
+ super(message);
40
+ this.name = "HornerosError";
41
+ this.statusCode = statusCode;
42
+ this.body = body;
43
+ }
44
+ };
45
+ var NotFoundError = class extends HornerosError {
46
+ constructor(message, body) {
47
+ super(message, 404, body);
48
+ this.name = "NotFoundError";
49
+ }
50
+ };
51
+ var ValidationError = class extends HornerosError {
52
+ constructor(message, body) {
53
+ super(message, 400, body);
54
+ this.name = "ValidationError";
55
+ }
56
+ };
57
+ var ConnectionTimeoutError = class extends HornerosError {
58
+ constructor(message = "Connection timed out waiting for activation") {
59
+ super(message, 408);
60
+ this.name = "ConnectionTimeoutError";
61
+ }
62
+ };
63
+
64
+ // src/mcps.ts
65
+ var Mcps = class {
66
+ constructor(client) {
67
+ this.client = client;
68
+ }
69
+ async list() {
70
+ const res = await this.client.fetch("/mcps");
71
+ return res.data;
72
+ }
73
+ async get(slug) {
74
+ const res = await this.client.fetch(
75
+ `/mcps/${encodeURIComponent(slug)}`
76
+ );
77
+ return res.data;
78
+ }
79
+ };
80
+
81
+ // src/connections.ts
82
+ var ConnectionRequest = class {
83
+ constructor(client, data) {
84
+ this.client = client;
85
+ this.id = data.id;
86
+ this.mcpUrl = data.mcpUrl;
87
+ this.token = data.token;
88
+ this.redirectUrl = data.redirectUrl;
89
+ this.status = data.status;
90
+ }
91
+ /**
92
+ * Polls the connection until it becomes active.
93
+ * Useful for OAuth/interactive flows where the user needs to
94
+ * complete authentication in a browser.
95
+ * @param timeout Max wait time in ms (default: 120000 = 2 min)
96
+ */
97
+ async waitForConnection(timeout = 12e4) {
98
+ if (this.status === "active") {
99
+ const res = await this.client.fetch(
100
+ `/connections/${encodeURIComponent(this.id)}`
101
+ );
102
+ return res.data;
103
+ }
104
+ const start = Date.now();
105
+ const interval = 2e3;
106
+ while (Date.now() - start < timeout) {
107
+ await sleep(interval);
108
+ try {
109
+ const res = await this.client.fetch(
110
+ `/connections/${encodeURIComponent(this.id)}`
111
+ );
112
+ if (res.data.status === "active") {
113
+ return res.data;
114
+ }
115
+ } catch {
116
+ }
117
+ }
118
+ throw new ConnectionTimeoutError();
119
+ }
120
+ };
121
+ var Connections = class {
122
+ constructor(client) {
123
+ this.client = client;
124
+ }
125
+ async initiate(params) {
126
+ const body = {
127
+ mcp_slug: params.mcpSlug
128
+ };
129
+ if (params.appName) body.app_name = params.appName;
130
+ if (params.userId) body.user_id = params.userId;
131
+ if (params.credentials) body.credentials = params.credentials;
132
+ if (params.authScheme) body.auth_scheme = params.authScheme;
133
+ const res = await this.client.fetch(
134
+ "/connections",
135
+ { method: "POST", body: JSON.stringify(body) }
136
+ );
137
+ return new ConnectionRequest(this.client, res.data);
138
+ }
139
+ async list() {
140
+ const res = await this.client.fetch("/connections");
141
+ return res.data;
142
+ }
143
+ async get(id) {
144
+ const res = await this.client.fetch(
145
+ `/connections/${encodeURIComponent(id)}`
146
+ );
147
+ return res.data;
148
+ }
149
+ async revoke(id) {
150
+ await this.client.fetch(
151
+ `/connections/${encodeURIComponent(id)}`,
152
+ { method: "DELETE" }
153
+ );
154
+ }
155
+ };
156
+ function sleep(ms) {
157
+ return new Promise((resolve) => setTimeout(resolve, ms));
158
+ }
159
+
160
+ // src/tools.ts
161
+ var Tools = class {
162
+ constructor(client) {
163
+ this.client = client;
164
+ }
165
+ async list(mcpSlug) {
166
+ const res = await this.client.fetch(
167
+ `/mcps/${encodeURIComponent(mcpSlug)}/tools`
168
+ );
169
+ return res.data;
170
+ }
171
+ async execute(params) {
172
+ const res = await this.client.fetch(
173
+ "/tools/execute",
174
+ {
175
+ method: "POST",
176
+ body: JSON.stringify({
177
+ mcp_slug: params.mcpSlug,
178
+ connection_id: params.connectionId,
179
+ tool_name: params.toolName,
180
+ arguments: params.arguments
181
+ })
182
+ }
183
+ );
184
+ return res.data;
185
+ }
186
+ };
187
+
188
+ // src/client.ts
189
+ var HornerosSSP = class {
190
+ constructor(config) {
191
+ this.baseUrl = config.baseUrl.replace(/\/+$/, "");
192
+ this.mcps = new Mcps(this);
193
+ this.connections = new Connections(this);
194
+ this.tools = new Tools(this);
195
+ }
196
+ /** @internal */
197
+ async fetch(path, options = {}) {
198
+ const url = `${this.baseUrl}/api/v1${path}`;
199
+ const headers = {
200
+ "Content-Type": "application/json",
201
+ ...options.headers
202
+ };
203
+ const res = await globalThis.fetch(url, {
204
+ ...options,
205
+ headers
206
+ });
207
+ if (!res.ok) {
208
+ let body;
209
+ try {
210
+ body = await res.json();
211
+ } catch {
212
+ body = await res.text().catch(() => null);
213
+ }
214
+ const message = (body && typeof body === "object" && "error" in body ? body.error : null) || `HTTP ${res.status}`;
215
+ throw new HornerosError(message, res.status, body);
216
+ }
217
+ if (res.status === 204) {
218
+ return void 0;
219
+ }
220
+ return res.json();
221
+ }
222
+ };
223
+
224
+ // src/auth-scheme.ts
225
+ var AuthScheme = class {
226
+ static APIKey(params) {
227
+ return { type: "api_key", data: params };
228
+ }
229
+ static Bearer(params) {
230
+ return { type: "bearer", data: params };
231
+ }
232
+ static Basic(params) {
233
+ return { type: "basic", data: params };
234
+ }
235
+ static OAuth2(params) {
236
+ return {
237
+ type: "oauth2",
238
+ data: params
239
+ };
240
+ }
241
+ static GoogleLogin() {
242
+ return { type: "google_login", data: {} };
243
+ }
244
+ };
245
+ // Annotate the CommonJS export names for ESM import in node:
246
+ 0 && (module.exports = {
247
+ AuthScheme,
248
+ ConnectionRequest,
249
+ ConnectionTimeoutError,
250
+ Connections,
251
+ HornerosError,
252
+ HornerosSSP,
253
+ Mcps,
254
+ NotFoundError,
255
+ Tools,
256
+ ValidationError
257
+ });
258
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/mcps.ts","../src/connections.ts","../src/tools.ts","../src/client.ts","../src/auth-scheme.ts"],"sourcesContent":["export { HornerosSSP } from \"./client\";\nexport { AuthScheme } from \"./auth-scheme\";\nexport { Mcps } from \"./mcps\";\nexport { Connections, ConnectionRequest } from \"./connections\";\nexport { Tools } from \"./tools\";\n\n// Errors\nexport {\n HornerosError,\n NotFoundError,\n ValidationError,\n ConnectionTimeoutError,\n} from \"./errors\";\n\n// Types\nexport type {\n HornerosSSPConfig,\n McpInfo,\n McpDetail,\n ConnectionInfo,\n ConnectionRequestData,\n InitiateConnectionParams,\n ToolDefinition,\n ToolResult,\n ExecuteToolParams,\n ConnectionData,\n ApiResponse,\n ApiError,\n} from \"./types\";\n","export class HornerosError extends Error {\n public readonly statusCode: number;\n public readonly body: unknown;\n\n constructor(message: string, statusCode: number, body?: unknown) {\n super(message);\n this.name = \"HornerosError\";\n this.statusCode = statusCode;\n this.body = body;\n }\n}\n\nexport class NotFoundError extends HornerosError {\n constructor(message: string, body?: unknown) {\n super(message, 404, body);\n this.name = \"NotFoundError\";\n }\n}\n\nexport class ValidationError extends HornerosError {\n constructor(message: string, body?: unknown) {\n super(message, 400, body);\n this.name = \"ValidationError\";\n }\n}\n\nexport class ConnectionTimeoutError extends HornerosError {\n constructor(message = \"Connection timed out waiting for activation\") {\n super(message, 408);\n this.name = \"ConnectionTimeoutError\";\n }\n}\n","import type { HornerosSSP } from \"./client\";\nimport type { McpInfo, McpDetail, ApiResponse } from \"./types\";\n\nexport class Mcps {\n constructor(private client: HornerosSSP) {}\n\n async list(): Promise<McpInfo[]> {\n const res = await this.client.fetch<ApiResponse<McpInfo[]>>(\"/mcps\");\n return res.data;\n }\n\n async get(slug: string): Promise<McpDetail> {\n const res = await this.client.fetch<ApiResponse<McpDetail>>(\n `/mcps/${encodeURIComponent(slug)}`\n );\n return res.data;\n }\n}\n","import type { HornerosSSP } from \"./client\";\nimport type {\n ConnectionInfo,\n ConnectionRequestData,\n InitiateConnectionParams,\n ApiResponse,\n} from \"./types\";\nimport { ConnectionTimeoutError } from \"./errors\";\n\nexport class ConnectionRequest {\n public readonly id: string;\n public readonly mcpUrl: string | null;\n public readonly token: string | null;\n public readonly redirectUrl: string | null;\n public readonly status: \"active\" | \"pending\";\n\n constructor(\n private client: HornerosSSP,\n data: ConnectionRequestData\n ) {\n this.id = data.id;\n this.mcpUrl = data.mcpUrl;\n this.token = data.token;\n this.redirectUrl = data.redirectUrl;\n this.status = data.status;\n }\n\n /**\n * Polls the connection until it becomes active.\n * Useful for OAuth/interactive flows where the user needs to\n * complete authentication in a browser.\n * @param timeout Max wait time in ms (default: 120000 = 2 min)\n */\n async waitForConnection(timeout = 120_000): Promise<ConnectionInfo> {\n if (this.status === \"active\") {\n const res = await this.client.fetch<ApiResponse<ConnectionInfo>>(\n `/connections/${encodeURIComponent(this.id)}`\n );\n return res.data;\n }\n\n const start = Date.now();\n const interval = 2000;\n\n while (Date.now() - start < timeout) {\n await sleep(interval);\n try {\n const res = await this.client.fetch<ApiResponse<ConnectionInfo>>(\n `/connections/${encodeURIComponent(this.id)}`\n );\n if (res.data.status === \"active\") {\n return res.data;\n }\n } catch {\n // Connection not yet created, keep polling\n }\n }\n\n throw new ConnectionTimeoutError();\n }\n}\n\nexport class Connections {\n constructor(private client: HornerosSSP) {}\n\n async initiate(params: InitiateConnectionParams): Promise<ConnectionRequest> {\n const body: Record<string, unknown> = {\n mcp_slug: params.mcpSlug,\n };\n\n if (params.appName) body.app_name = params.appName;\n if (params.userId) body.user_id = params.userId;\n if (params.credentials) body.credentials = params.credentials;\n if (params.authScheme) body.auth_scheme = params.authScheme;\n\n const res = await this.client.fetch<ApiResponse<ConnectionRequestData>>(\n \"/connections\",\n { method: \"POST\", body: JSON.stringify(body) }\n );\n\n return new ConnectionRequest(this.client, res.data);\n }\n\n async list(): Promise<ConnectionInfo[]> {\n const res =\n await this.client.fetch<ApiResponse<ConnectionInfo[]>>(\"/connections\");\n return res.data;\n }\n\n async get(id: string): Promise<ConnectionInfo> {\n const res = await this.client.fetch<ApiResponse<ConnectionInfo>>(\n `/connections/${encodeURIComponent(id)}`\n );\n return res.data;\n }\n\n async revoke(id: string): Promise<void> {\n await this.client.fetch<void>(\n `/connections/${encodeURIComponent(id)}`,\n { method: \"DELETE\" }\n );\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { HornerosSSP } from \"./client\";\nimport type {\n ToolDefinition,\n ToolResult,\n ExecuteToolParams,\n ApiResponse,\n} from \"./types\";\n\nexport class Tools {\n constructor(private client: HornerosSSP) {}\n\n async list(mcpSlug: string): Promise<ToolDefinition[]> {\n const res = await this.client.fetch<ApiResponse<ToolDefinition[]>>(\n `/mcps/${encodeURIComponent(mcpSlug)}/tools`\n );\n return res.data;\n }\n\n async execute(params: ExecuteToolParams): Promise<ToolResult> {\n const res = await this.client.fetch<ApiResponse<ToolResult>>(\n \"/tools/execute\",\n {\n method: \"POST\",\n body: JSON.stringify({\n mcp_slug: params.mcpSlug,\n connection_id: params.connectionId,\n tool_name: params.toolName,\n arguments: params.arguments,\n }),\n }\n );\n return res.data;\n }\n}\n","import type { HornerosSSPConfig } from \"./types\";\nimport { HornerosError } from \"./errors\";\nimport { Mcps } from \"./mcps\";\nimport { Connections } from \"./connections\";\nimport { Tools } from \"./tools\";\n\nexport class HornerosSSP {\n public readonly mcps: Mcps;\n public readonly connections: Connections;\n public readonly tools: Tools;\n\n private readonly baseUrl: string;\n\n constructor(config: HornerosSSPConfig) {\n this.baseUrl = config.baseUrl.replace(/\\/+$/, \"\");\n\n this.mcps = new Mcps(this);\n this.connections = new Connections(this);\n this.tools = new Tools(this);\n }\n\n /** @internal */\n async fetch<T>(\n path: string,\n options: RequestInit = {}\n ): Promise<T> {\n const url = `${this.baseUrl}/api/v1${path}`;\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...(options.headers as Record<string, string>),\n };\n\n const res = await globalThis.fetch(url, {\n ...options,\n headers,\n });\n\n if (!res.ok) {\n let body: unknown;\n try {\n body = await res.json();\n } catch {\n body = await res.text().catch(() => null);\n }\n const message =\n (body && typeof body === \"object\" && \"error\" in body\n ? (body as { error: string }).error\n : null) || `HTTP ${res.status}`;\n throw new HornerosError(message, res.status, body);\n }\n\n if (res.status === 204) {\n return undefined as T;\n }\n\n return res.json() as Promise<T>;\n }\n}\n","import type { ConnectionData } from \"./types\";\n\nexport class AuthScheme {\n static APIKey(params: { api_key: string; [k: string]: string }): ConnectionData {\n return { type: \"api_key\", data: params };\n }\n\n static Bearer(params: { token: string }): ConnectionData {\n return { type: \"bearer\", data: params };\n }\n\n static Basic(params: { username: string; password: string }): ConnectionData {\n return { type: \"basic\", data: params };\n }\n\n static OAuth2(params: {\n access_token: string;\n refresh_token?: string;\n }): ConnectionData {\n return {\n type: \"oauth2\",\n data: params as Record<string, string>,\n };\n }\n\n static GoogleLogin(): ConnectionData {\n return { type: \"google_login\", data: {} };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAIvC,YAAY,SAAiB,YAAoB,MAAgB;AAC/D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,cAAc;AAAA,EAC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,YAAM,WACH,QAAQ,OAAO,SAAS,YAAY,WAAW,OAC3C,KAA2B,QAC5B,SAAS,QAAQ,IAAI,MAAM;AACjC,YAAM,IAAI,cAAc,SAAS,IAAI,QAAQ,IAAI;AAAA,IACnD;AAEA,QAAI,IAAI,WAAW,KAAK;AACtB,aAAO;AAAA,IACT;AAEA,WAAO,IAAI,KAAK;AAAA,EAClB;AACF;;;ACxDO,IAAM,aAAN,MAAiB;AAAA,EACtB,OAAO,OAAO,QAAkE;AAC9E,WAAO,EAAE,MAAM,WAAW,MAAM,OAAO;AAAA,EACzC;AAAA,EAEA,OAAO,OAAO,QAA2C;AACvD,WAAO,EAAE,MAAM,UAAU,MAAM,OAAO;AAAA,EACxC;AAAA,EAEA,OAAO,MAAM,QAAgE;AAC3E,WAAO,EAAE,MAAM,SAAS,MAAM,OAAO;AAAA,EACvC;AAAA,EAEA,OAAO,OAAO,QAGK;AACjB,WAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,OAAO,cAA8B;AACnC,WAAO,EAAE,MAAM,gBAAgB,MAAM,CAAC,EAAE;AAAA,EAC1C;AACF;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,222 @@
1
+ // src/errors.ts
2
+ var HornerosError = class extends Error {
3
+ constructor(message, statusCode, body) {
4
+ super(message);
5
+ this.name = "HornerosError";
6
+ this.statusCode = statusCode;
7
+ this.body = body;
8
+ }
9
+ };
10
+ var NotFoundError = class extends HornerosError {
11
+ constructor(message, body) {
12
+ super(message, 404, body);
13
+ this.name = "NotFoundError";
14
+ }
15
+ };
16
+ var ValidationError = class extends HornerosError {
17
+ constructor(message, body) {
18
+ super(message, 400, body);
19
+ this.name = "ValidationError";
20
+ }
21
+ };
22
+ var ConnectionTimeoutError = class extends HornerosError {
23
+ constructor(message = "Connection timed out waiting for activation") {
24
+ super(message, 408);
25
+ this.name = "ConnectionTimeoutError";
26
+ }
27
+ };
28
+
29
+ // src/mcps.ts
30
+ var Mcps = class {
31
+ constructor(client) {
32
+ this.client = client;
33
+ }
34
+ async list() {
35
+ const res = await this.client.fetch("/mcps");
36
+ return res.data;
37
+ }
38
+ async get(slug) {
39
+ const res = await this.client.fetch(
40
+ `/mcps/${encodeURIComponent(slug)}`
41
+ );
42
+ return res.data;
43
+ }
44
+ };
45
+
46
+ // src/connections.ts
47
+ var ConnectionRequest = class {
48
+ constructor(client, data) {
49
+ this.client = client;
50
+ this.id = data.id;
51
+ this.mcpUrl = data.mcpUrl;
52
+ this.token = data.token;
53
+ this.redirectUrl = data.redirectUrl;
54
+ this.status = data.status;
55
+ }
56
+ /**
57
+ * Polls the connection until it becomes active.
58
+ * Useful for OAuth/interactive flows where the user needs to
59
+ * complete authentication in a browser.
60
+ * @param timeout Max wait time in ms (default: 120000 = 2 min)
61
+ */
62
+ async waitForConnection(timeout = 12e4) {
63
+ if (this.status === "active") {
64
+ const res = await this.client.fetch(
65
+ `/connections/${encodeURIComponent(this.id)}`
66
+ );
67
+ return res.data;
68
+ }
69
+ const start = Date.now();
70
+ const interval = 2e3;
71
+ while (Date.now() - start < timeout) {
72
+ await sleep(interval);
73
+ try {
74
+ const res = await this.client.fetch(
75
+ `/connections/${encodeURIComponent(this.id)}`
76
+ );
77
+ if (res.data.status === "active") {
78
+ return res.data;
79
+ }
80
+ } catch {
81
+ }
82
+ }
83
+ throw new ConnectionTimeoutError();
84
+ }
85
+ };
86
+ var Connections = class {
87
+ constructor(client) {
88
+ this.client = client;
89
+ }
90
+ async initiate(params) {
91
+ const body = {
92
+ mcp_slug: params.mcpSlug
93
+ };
94
+ if (params.appName) body.app_name = params.appName;
95
+ if (params.userId) body.user_id = params.userId;
96
+ if (params.credentials) body.credentials = params.credentials;
97
+ if (params.authScheme) body.auth_scheme = params.authScheme;
98
+ const res = await this.client.fetch(
99
+ "/connections",
100
+ { method: "POST", body: JSON.stringify(body) }
101
+ );
102
+ return new ConnectionRequest(this.client, res.data);
103
+ }
104
+ async list() {
105
+ const res = await this.client.fetch("/connections");
106
+ return res.data;
107
+ }
108
+ async get(id) {
109
+ const res = await this.client.fetch(
110
+ `/connections/${encodeURIComponent(id)}`
111
+ );
112
+ return res.data;
113
+ }
114
+ async revoke(id) {
115
+ await this.client.fetch(
116
+ `/connections/${encodeURIComponent(id)}`,
117
+ { method: "DELETE" }
118
+ );
119
+ }
120
+ };
121
+ function sleep(ms) {
122
+ return new Promise((resolve) => setTimeout(resolve, ms));
123
+ }
124
+
125
+ // src/tools.ts
126
+ var Tools = class {
127
+ constructor(client) {
128
+ this.client = client;
129
+ }
130
+ async list(mcpSlug) {
131
+ const res = await this.client.fetch(
132
+ `/mcps/${encodeURIComponent(mcpSlug)}/tools`
133
+ );
134
+ return res.data;
135
+ }
136
+ async execute(params) {
137
+ const res = await this.client.fetch(
138
+ "/tools/execute",
139
+ {
140
+ method: "POST",
141
+ body: JSON.stringify({
142
+ mcp_slug: params.mcpSlug,
143
+ connection_id: params.connectionId,
144
+ tool_name: params.toolName,
145
+ arguments: params.arguments
146
+ })
147
+ }
148
+ );
149
+ return res.data;
150
+ }
151
+ };
152
+
153
+ // src/client.ts
154
+ var HornerosSSP = class {
155
+ constructor(config) {
156
+ this.baseUrl = config.baseUrl.replace(/\/+$/, "");
157
+ this.mcps = new Mcps(this);
158
+ this.connections = new Connections(this);
159
+ this.tools = new Tools(this);
160
+ }
161
+ /** @internal */
162
+ async fetch(path, options = {}) {
163
+ const url = `${this.baseUrl}/api/v1${path}`;
164
+ const headers = {
165
+ "Content-Type": "application/json",
166
+ ...options.headers
167
+ };
168
+ const res = await globalThis.fetch(url, {
169
+ ...options,
170
+ headers
171
+ });
172
+ if (!res.ok) {
173
+ let body;
174
+ try {
175
+ body = await res.json();
176
+ } catch {
177
+ body = await res.text().catch(() => null);
178
+ }
179
+ const message = (body && typeof body === "object" && "error" in body ? body.error : null) || `HTTP ${res.status}`;
180
+ throw new HornerosError(message, res.status, body);
181
+ }
182
+ if (res.status === 204) {
183
+ return void 0;
184
+ }
185
+ return res.json();
186
+ }
187
+ };
188
+
189
+ // src/auth-scheme.ts
190
+ var AuthScheme = class {
191
+ static APIKey(params) {
192
+ return { type: "api_key", data: params };
193
+ }
194
+ static Bearer(params) {
195
+ return { type: "bearer", data: params };
196
+ }
197
+ static Basic(params) {
198
+ return { type: "basic", data: params };
199
+ }
200
+ static OAuth2(params) {
201
+ return {
202
+ type: "oauth2",
203
+ data: params
204
+ };
205
+ }
206
+ static GoogleLogin() {
207
+ return { type: "google_login", data: {} };
208
+ }
209
+ };
210
+ export {
211
+ AuthScheme,
212
+ ConnectionRequest,
213
+ ConnectionTimeoutError,
214
+ Connections,
215
+ HornerosError,
216
+ HornerosSSP,
217
+ Mcps,
218
+ NotFoundError,
219
+ Tools,
220
+ ValidationError
221
+ };
222
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts","../src/mcps.ts","../src/connections.ts","../src/tools.ts","../src/client.ts","../src/auth-scheme.ts"],"sourcesContent":["export class HornerosError extends Error {\n public readonly statusCode: number;\n public readonly body: unknown;\n\n constructor(message: string, statusCode: number, body?: unknown) {\n super(message);\n this.name = \"HornerosError\";\n this.statusCode = statusCode;\n this.body = body;\n }\n}\n\nexport class NotFoundError extends HornerosError {\n constructor(message: string, body?: unknown) {\n super(message, 404, body);\n this.name = \"NotFoundError\";\n }\n}\n\nexport class ValidationError extends HornerosError {\n constructor(message: string, body?: unknown) {\n super(message, 400, body);\n this.name = \"ValidationError\";\n }\n}\n\nexport class ConnectionTimeoutError extends HornerosError {\n constructor(message = \"Connection timed out waiting for activation\") {\n super(message, 408);\n this.name = \"ConnectionTimeoutError\";\n }\n}\n","import type { HornerosSSP } from \"./client\";\nimport type { McpInfo, McpDetail, ApiResponse } from \"./types\";\n\nexport class Mcps {\n constructor(private client: HornerosSSP) {}\n\n async list(): Promise<McpInfo[]> {\n const res = await this.client.fetch<ApiResponse<McpInfo[]>>(\"/mcps\");\n return res.data;\n }\n\n async get(slug: string): Promise<McpDetail> {\n const res = await this.client.fetch<ApiResponse<McpDetail>>(\n `/mcps/${encodeURIComponent(slug)}`\n );\n return res.data;\n }\n}\n","import type { HornerosSSP } from \"./client\";\nimport type {\n ConnectionInfo,\n ConnectionRequestData,\n InitiateConnectionParams,\n ApiResponse,\n} from \"./types\";\nimport { ConnectionTimeoutError } from \"./errors\";\n\nexport class ConnectionRequest {\n public readonly id: string;\n public readonly mcpUrl: string | null;\n public readonly token: string | null;\n public readonly redirectUrl: string | null;\n public readonly status: \"active\" | \"pending\";\n\n constructor(\n private client: HornerosSSP,\n data: ConnectionRequestData\n ) {\n this.id = data.id;\n this.mcpUrl = data.mcpUrl;\n this.token = data.token;\n this.redirectUrl = data.redirectUrl;\n this.status = data.status;\n }\n\n /**\n * Polls the connection until it becomes active.\n * Useful for OAuth/interactive flows where the user needs to\n * complete authentication in a browser.\n * @param timeout Max wait time in ms (default: 120000 = 2 min)\n */\n async waitForConnection(timeout = 120_000): Promise<ConnectionInfo> {\n if (this.status === \"active\") {\n const res = await this.client.fetch<ApiResponse<ConnectionInfo>>(\n `/connections/${encodeURIComponent(this.id)}`\n );\n return res.data;\n }\n\n const start = Date.now();\n const interval = 2000;\n\n while (Date.now() - start < timeout) {\n await sleep(interval);\n try {\n const res = await this.client.fetch<ApiResponse<ConnectionInfo>>(\n `/connections/${encodeURIComponent(this.id)}`\n );\n if (res.data.status === \"active\") {\n return res.data;\n }\n } catch {\n // Connection not yet created, keep polling\n }\n }\n\n throw new ConnectionTimeoutError();\n }\n}\n\nexport class Connections {\n constructor(private client: HornerosSSP) {}\n\n async initiate(params: InitiateConnectionParams): Promise<ConnectionRequest> {\n const body: Record<string, unknown> = {\n mcp_slug: params.mcpSlug,\n };\n\n if (params.appName) body.app_name = params.appName;\n if (params.userId) body.user_id = params.userId;\n if (params.credentials) body.credentials = params.credentials;\n if (params.authScheme) body.auth_scheme = params.authScheme;\n\n const res = await this.client.fetch<ApiResponse<ConnectionRequestData>>(\n \"/connections\",\n { method: \"POST\", body: JSON.stringify(body) }\n );\n\n return new ConnectionRequest(this.client, res.data);\n }\n\n async list(): Promise<ConnectionInfo[]> {\n const res =\n await this.client.fetch<ApiResponse<ConnectionInfo[]>>(\"/connections\");\n return res.data;\n }\n\n async get(id: string): Promise<ConnectionInfo> {\n const res = await this.client.fetch<ApiResponse<ConnectionInfo>>(\n `/connections/${encodeURIComponent(id)}`\n );\n return res.data;\n }\n\n async revoke(id: string): Promise<void> {\n await this.client.fetch<void>(\n `/connections/${encodeURIComponent(id)}`,\n { method: \"DELETE\" }\n );\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { HornerosSSP } from \"./client\";\nimport type {\n ToolDefinition,\n ToolResult,\n ExecuteToolParams,\n ApiResponse,\n} from \"./types\";\n\nexport class Tools {\n constructor(private client: HornerosSSP) {}\n\n async list(mcpSlug: string): Promise<ToolDefinition[]> {\n const res = await this.client.fetch<ApiResponse<ToolDefinition[]>>(\n `/mcps/${encodeURIComponent(mcpSlug)}/tools`\n );\n return res.data;\n }\n\n async execute(params: ExecuteToolParams): Promise<ToolResult> {\n const res = await this.client.fetch<ApiResponse<ToolResult>>(\n \"/tools/execute\",\n {\n method: \"POST\",\n body: JSON.stringify({\n mcp_slug: params.mcpSlug,\n connection_id: params.connectionId,\n tool_name: params.toolName,\n arguments: params.arguments,\n }),\n }\n );\n return res.data;\n }\n}\n","import type { HornerosSSPConfig } from \"./types\";\nimport { HornerosError } from \"./errors\";\nimport { Mcps } from \"./mcps\";\nimport { Connections } from \"./connections\";\nimport { Tools } from \"./tools\";\n\nexport class HornerosSSP {\n public readonly mcps: Mcps;\n public readonly connections: Connections;\n public readonly tools: Tools;\n\n private readonly baseUrl: string;\n\n constructor(config: HornerosSSPConfig) {\n this.baseUrl = config.baseUrl.replace(/\\/+$/, \"\");\n\n this.mcps = new Mcps(this);\n this.connections = new Connections(this);\n this.tools = new Tools(this);\n }\n\n /** @internal */\n async fetch<T>(\n path: string,\n options: RequestInit = {}\n ): Promise<T> {\n const url = `${this.baseUrl}/api/v1${path}`;\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...(options.headers as Record<string, string>),\n };\n\n const res = await globalThis.fetch(url, {\n ...options,\n headers,\n });\n\n if (!res.ok) {\n let body: unknown;\n try {\n body = await res.json();\n } catch {\n body = await res.text().catch(() => null);\n }\n const message =\n (body && typeof body === \"object\" && \"error\" in body\n ? (body as { error: string }).error\n : null) || `HTTP ${res.status}`;\n throw new HornerosError(message, res.status, body);\n }\n\n if (res.status === 204) {\n return undefined as T;\n }\n\n return res.json() as Promise<T>;\n }\n}\n","import type { ConnectionData } from \"./types\";\n\nexport class AuthScheme {\n static APIKey(params: { api_key: string; [k: string]: string }): ConnectionData {\n return { type: \"api_key\", data: params };\n }\n\n static Bearer(params: { token: string }): ConnectionData {\n return { type: \"bearer\", data: params };\n }\n\n static Basic(params: { username: string; password: string }): ConnectionData {\n return { type: \"basic\", data: params };\n }\n\n static OAuth2(params: {\n access_token: string;\n refresh_token?: string;\n }): ConnectionData {\n return {\n type: \"oauth2\",\n data: params as Record<string, string>,\n };\n }\n\n static GoogleLogin(): ConnectionData {\n return { type: \"google_login\", data: {} };\n }\n}\n"],"mappings":";AAAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAIvC,YAAY,SAAiB,YAAoB,MAAgB;AAC/D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,cAAc;AAAA,EAC/C,YAAY,SAAiB,MAAgB;AAC3C,UAAM,SAAS,KAAK,IAAI;AACxB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,cAAc;AAAA,EACjD,YAAY,SAAiB,MAAgB;AAC3C,UAAM,SAAS,KAAK,IAAI;AACxB,SAAK,OAAO;AAAA,EACd;AAC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IAAI,KAAK;AAAA,EAClB;AACF;;;ACxDO,IAAM,aAAN,MAAiB;AAAA,EACtB,OAAO,OAAO,QAAkE;AAC9E,WAAO,EAAE,MAAM,WAAW,MAAM,OAAO;AAAA,EACzC;AAAA,EAEA,OAAO,OAAO,QAA2C;AACvD,WAAO,EAAE,MAAM,UAAU,MAAM,OAAO;AAAA,EACxC;AAAA,EAEA,OAAO,MAAM,QAAgE;AAC3E,WAAO,EAAE,MAAM,SAAS,MAAM,OAAO;AAAA,EACvC;AAAA,EAEA,OAAO,OAAO,QAGK;AACjB,WAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,OAAO,cAA8B;AACnC,WAAO,EAAE,MAAM,gBAAgB,MAAM,CAAC,EAAE;AAAA,EAC1C;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "hornerosssp",
3
+ "version": "0.1.0",
4
+ "description": "SDK for HornerosSSP - integrate MCPs into any app",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "dev": "tsup --watch"
21
+ },
22
+ "devDependencies": {
23
+ "tsup": "^8.0.0",
24
+ "typescript": "^5.0.0"
25
+ },
26
+ "license": "MIT"
27
+ }