@kosha-ai/server 0.0.1 → 0.0.3

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,32 @@
1
+ import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
2
+ /**
3
+ * Drops per-connection headers, plus any header that `Connection` itself
4
+ * names. A sender uses that list to mark a header as meant for the next
5
+ * recipient only, so honouring it keeps internal headers from leaking through
6
+ * the proxy.
7
+ */
8
+ export declare function stripHopByHopHeaders(headers: IncomingHttpHeaders): IncomingHttpHeaders;
9
+ export interface AdminProxyOptions {
10
+ /** Port the admin UI listens on, on the loopback interface. */
11
+ adminPort: number;
12
+ /** The server's own prefix. Everything under it stays with Nest. */
13
+ globalPrefix: string;
14
+ }
15
+ type Next = (error?: unknown) => void;
16
+ /**
17
+ * Lets the server answer for the whole app on one port.
18
+ *
19
+ * `kosha start` runs the Nest server and the admin UI on two ports. Without
20
+ * this, deploying meant either two hostnames or a reverse proxy in front of
21
+ * both. Here `/api/*` stays with Nest and everything else is piped to the
22
+ * admin over loopback, so a single URL serves the API and the UI.
23
+ *
24
+ * One origin also keeps the session cookie same-site, so it survives without
25
+ * `SameSite=None` or https, and CORS never comes up.
26
+ *
27
+ * ponytail: no WebSocket upgrade handling. The admin's production build never
28
+ * opens one. Forward the server's `upgrade` event if that changes.
29
+ */
30
+ export declare function createAdminProxy(options: AdminProxyOptions): (req: IncomingMessage, res: ServerResponse, next: Next) => void;
31
+ export {};
32
+ //# sourceMappingURL=admin-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-proxy.d.ts","sourceRoot":"","sources":["../src/admin-proxy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,cAAc,EACf,MAAM,WAAW,CAAC;AAmBnB;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,mBAAmB,GAC3B,mBAAmB,CAmBrB;AAED,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;AAEtC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,IAIvD,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,MAAM,IAAI,KACT,IAAI,CAyCR"}
@@ -0,0 +1,88 @@
1
+ import { request as httpRequest } from 'node:http';
2
+ /**
3
+ * Headers that belong to one connection rather than to the message, so they
4
+ * must not be forwarded (RFC 9110 §7.6.1). `transfer-encoding` is the one that
5
+ * causes real damage: Node frames the forwarded response itself, and setting
6
+ * upstream's framing on top of that corrupts the body.
7
+ */
8
+ const HOP_BY_HOP_HEADERS = new Set([
9
+ 'connection',
10
+ 'keep-alive',
11
+ 'proxy-authenticate',
12
+ 'proxy-authorization',
13
+ 'te',
14
+ 'trailer',
15
+ 'transfer-encoding',
16
+ 'upgrade',
17
+ ]);
18
+ /**
19
+ * Drops per-connection headers, plus any header that `Connection` itself
20
+ * names. A sender uses that list to mark a header as meant for the next
21
+ * recipient only, so honouring it keeps internal headers from leaking through
22
+ * the proxy.
23
+ */
24
+ export function stripHopByHopHeaders(headers) {
25
+ const connection = headers.connection;
26
+ const named = typeof connection === 'string'
27
+ ? connection
28
+ .split(',')
29
+ .map((token) => token.trim().toLowerCase())
30
+ .filter(Boolean)
31
+ : [];
32
+ const forwarded = {};
33
+ for (const [name, value] of Object.entries(headers)) {
34
+ const lower = name.toLowerCase();
35
+ if (HOP_BY_HOP_HEADERS.has(lower) || named.includes(lower))
36
+ continue;
37
+ forwarded[name] = value;
38
+ }
39
+ return forwarded;
40
+ }
41
+ /**
42
+ * Lets the server answer for the whole app on one port.
43
+ *
44
+ * `kosha start` runs the Nest server and the admin UI on two ports. Without
45
+ * this, deploying meant either two hostnames or a reverse proxy in front of
46
+ * both. Here `/api/*` stays with Nest and everything else is piped to the
47
+ * admin over loopback, so a single URL serves the API and the UI.
48
+ *
49
+ * One origin also keeps the session cookie same-site, so it survives without
50
+ * `SameSite=None` or https, and CORS never comes up.
51
+ *
52
+ * ponytail: no WebSocket upgrade handling. The admin's production build never
53
+ * opens one. Forward the server's `upgrade` event if that changes.
54
+ */
55
+ export function createAdminProxy(options) {
56
+ const apiPrefix = `/${options.globalPrefix}`;
57
+ return function adminProxy(req, res, next) {
58
+ const url = req.url ?? '/';
59
+ // Match on a boundary so a path like `/apidocs` is not taken for the API.
60
+ const isApi = url === apiPrefix ||
61
+ url.startsWith(`${apiPrefix}/`) ||
62
+ url.startsWith(`${apiPrefix}?`);
63
+ if (isApi) {
64
+ next();
65
+ return;
66
+ }
67
+ const upstream = httpRequest({
68
+ host: '127.0.0.1',
69
+ port: options.adminPort,
70
+ method: req.method,
71
+ path: url,
72
+ // `host` is forwarded on purpose, so the admin builds absolute URLs
73
+ // from the public hostname instead of loopback.
74
+ headers: stripHopByHopHeaders(req.headers),
75
+ });
76
+ upstream.on('response', (adminRes) => {
77
+ res.writeHead(adminRes.statusCode ?? 502, stripHopByHopHeaders(adminRes.headers));
78
+ adminRes.pipe(res);
79
+ });
80
+ upstream.on('error', () => {
81
+ if (!res.headersSent) {
82
+ res.writeHead(502, { 'content-type': 'text/plain' });
83
+ }
84
+ res.end('Kosha admin UI is not reachable.');
85
+ });
86
+ req.pipe(upstream);
87
+ };
88
+ }
@@ -26,6 +26,11 @@ export interface KoshaAuthApi {
26
26
  export type KoshaAuth = Auth & {
27
27
  api: Auth['api'] & KoshaAuthApi;
28
28
  };
29
+ export declare function resolveAuthBaseURL(config: ResolvedKoshaConfig): string;
30
+ export declare function crossSiteCookieAttributes(config: ResolvedKoshaConfig): {
31
+ sameSite: 'none';
32
+ secure: true;
33
+ } | undefined;
29
34
  /**
30
35
  * A factory rather than a module-level singleton: the framework is a library
31
36
  * now, so nothing may read `process.env` at import time — the consuming app
@@ -1 +1 @@
1
- {"version":3,"file":"auth.factory.d.ts","sourceRoot":"","sources":["../../src/auth/auth.factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,gFAAgF;AAChF,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,GAAG,OAAO,CAAC;QACtD,KAAK,EAAE,OAAO,CAAC;QACf,GAAG,CAAC,EAAE;YAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,GAAG,IAAI,CAAC;QAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC,CAAC;CACJ;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG;IAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,YAAY,CAAA;CAAE,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,YAAY,GACnB,SAAS,CAoBX"}
1
+ {"version":3,"file":"auth.factory.d.ts","sourceRoot":"","sources":["../../src/auth/auth.factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,gFAAgF;AAChF,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,GAAG,OAAO,CAAC;QACtD,KAAK,EAAE,OAAO,CAAC;QACf,GAAG,CAAC,EAAE;YAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,GAAG,IAAI,CAAC;QAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC,CAAC;CACJ;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG;IAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,YAAY,CAAA;CAAE,CAAC;AAEnE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAEtE;AAUD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,mBAAmB,GAC1B;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,IAAI,CAAA;CAAE,GAAG,SAAS,CAYhD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,YAAY,GACnB,SAAS,CAqBX"}
@@ -2,6 +2,30 @@ import { apiKey } from '@better-auth/api-key';
2
2
  import { betterAuth } from 'better-auth';
3
3
  import { prismaAdapter } from 'better-auth/adapters/prisma';
4
4
  import { organization } from 'better-auth/plugins';
5
+ export function resolveAuthBaseURL(config) {
6
+ return config.auth.baseURL ?? `http://localhost:${config.server.port}`;
7
+ }
8
+ function hostnameOf(url) {
9
+ try {
10
+ return new URL(url).hostname;
11
+ }
12
+ catch {
13
+ return undefined;
14
+ }
15
+ }
16
+ export function crossSiteCookieAttributes(config) {
17
+ const baseURL = resolveAuthBaseURL(config);
18
+ if (!baseURL.startsWith('https://'))
19
+ return undefined;
20
+ const host = hostnameOf(baseURL);
21
+ const crossSite = (config.auth.trustedOrigins ?? []).some((origin) => {
22
+ if (!origin.startsWith('https://'))
23
+ return false;
24
+ const other = hostnameOf(origin);
25
+ return other !== undefined && other !== host;
26
+ });
27
+ return crossSite ? { sameSite: 'none', secure: true } : undefined;
28
+ }
5
29
  /**
6
30
  * A factory rather than a module-level singleton: the framework is a library
7
31
  * now, so nothing may read `process.env` at import time — the consuming app
@@ -11,12 +35,13 @@ export function createAuth(config, prisma) {
11
35
  const auth = betterAuth({
12
36
  database: prismaAdapter(prisma, { provider: 'postgresql' }),
13
37
  secret: config.auth.secret,
14
- baseURL: config.auth.baseURL ?? `http://localhost:${config.server.port}`,
38
+ baseURL: resolveAuthBaseURL(config),
15
39
  basePath: `/${config.server.globalPrefix}/auth`,
16
40
  emailAndPassword: {
17
41
  enabled: config.auth.emailAndPassword?.enabled ?? true,
18
42
  },
19
43
  trustedOrigins: config.auth.trustedOrigins ?? [],
44
+ advanced: { defaultCookieAttributes: crossSiteCookieAttributes(config) },
20
45
  plugins: [
21
46
  organization(),
22
47
  apiKey({ references: 'organization', requireName: true }),
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI5D;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,gBAAgB,CAAC,CAgB3B;AAED,gCAAgC;AAChC,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,gBAAgB,CAAC,CAW3B"}
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAG/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI5D;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,gBAAgB,CAAC,CAgB3B;AAED,gCAAgC;AAChC,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,gBAAgB,CAAC,CAkB3B"}
package/dist/bootstrap.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Logger } from '@nestjs/common';
2
2
  import { NestFactory } from '@nestjs/core';
3
+ import { createAdminProxy } from './admin-proxy.js';
3
4
  import { resolveConfig } from './config/kosha-config.js';
4
5
  import { KoshaModule } from './kosha.module.js';
5
6
  /**
@@ -27,7 +28,11 @@ export async function createKoshaServer(config) {
27
28
  export async function startKoshaServer(config) {
28
29
  const resolved = resolveConfig(config);
29
30
  const app = await createKoshaServer(resolved);
31
+ app.use(createAdminProxy({
32
+ adminPort: resolved.admin.port,
33
+ globalPrefix: resolved.server.globalPrefix,
34
+ }));
30
35
  await app.listen(resolved.server.port);
31
- Logger.log(`🚀 Kosha is running on http://localhost:${resolved.server.port}/${resolved.server.globalPrefix}`, 'Bootstrap');
36
+ Logger.log(`🚀 Kosha is running on ${resolved.server.publicUrl} (API under /${resolved.server.globalPrefix})`, 'Bootstrap');
32
37
  return app;
33
38
  }
@@ -9,12 +9,12 @@ export declare class ConfigurationsController {
9
9
  constructor(configurations: ConfigurationsService);
10
10
  list(session: UserSession): import("../generated/prisma/internal/prismaNamespace.js").PrismaPromise<({
11
11
  provider: {
12
+ name: string;
12
13
  key: string;
13
14
  id: string;
14
- name: string;
15
- authType: import("../generated/prisma/enums.js").AuthType;
16
15
  createdAt: Date;
17
16
  updatedAt: Date;
17
+ authType: import("../generated/prisma/enums.js").AuthType;
18
18
  authorizationUrl: string | null;
19
19
  tokenUrl: string | null;
20
20
  revokeUrl: string | null;
@@ -25,28 +25,28 @@ export declare class ConfigurationsController {
25
25
  isActive: boolean;
26
26
  };
27
27
  } & {
28
+ name: string;
28
29
  id: string;
30
+ createdAt: Date;
31
+ updatedAt: Date;
32
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
33
+ scopes: string[];
29
34
  organizationId: string;
30
35
  providerId: string;
31
- name: string;
32
36
  environment: import("../generated/prisma/enums.js").ConnectionEnvironment;
33
37
  authType: import("../generated/prisma/enums.js").AuthType;
34
38
  clientId: string | null;
35
39
  redirectUri: string | null;
36
- scopes: string[];
37
40
  isEnabled: boolean;
38
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
39
- createdAt: Date;
40
- updatedAt: Date;
41
41
  })[]>;
42
42
  get(session: UserSession, id: string): Promise<{
43
43
  provider: {
44
+ name: string;
44
45
  key: string;
45
46
  id: string;
46
- name: string;
47
- authType: import("../generated/prisma/enums.js").AuthType;
48
47
  createdAt: Date;
49
48
  updatedAt: Date;
49
+ authType: import("../generated/prisma/enums.js").AuthType;
50
50
  authorizationUrl: string | null;
51
51
  tokenUrl: string | null;
52
52
  revokeUrl: string | null;
@@ -57,28 +57,28 @@ export declare class ConfigurationsController {
57
57
  isActive: boolean;
58
58
  };
59
59
  } & {
60
+ name: string;
60
61
  id: string;
62
+ createdAt: Date;
63
+ updatedAt: Date;
64
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
65
+ scopes: string[];
61
66
  organizationId: string;
62
67
  providerId: string;
63
- name: string;
64
68
  environment: import("../generated/prisma/enums.js").ConnectionEnvironment;
65
69
  authType: import("../generated/prisma/enums.js").AuthType;
66
70
  clientId: string | null;
67
71
  redirectUri: string | null;
68
- scopes: string[];
69
72
  isEnabled: boolean;
70
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
71
- createdAt: Date;
72
- updatedAt: Date;
73
73
  }>;
74
74
  create(session: UserSession, body: CreateConfigurationInput): Promise<{
75
75
  provider: {
76
+ name: string;
76
77
  key: string;
77
78
  id: string;
78
- name: string;
79
- authType: import("../generated/prisma/enums.js").AuthType;
80
79
  createdAt: Date;
81
80
  updatedAt: Date;
81
+ authType: import("../generated/prisma/enums.js").AuthType;
82
82
  authorizationUrl: string | null;
83
83
  tokenUrl: string | null;
84
84
  revokeUrl: string | null;
@@ -89,28 +89,28 @@ export declare class ConfigurationsController {
89
89
  isActive: boolean;
90
90
  };
91
91
  } & {
92
+ name: string;
92
93
  id: string;
94
+ createdAt: Date;
95
+ updatedAt: Date;
96
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
97
+ scopes: string[];
93
98
  organizationId: string;
94
99
  providerId: string;
95
- name: string;
96
100
  environment: import("../generated/prisma/enums.js").ConnectionEnvironment;
97
101
  authType: import("../generated/prisma/enums.js").AuthType;
98
102
  clientId: string | null;
99
103
  redirectUri: string | null;
100
- scopes: string[];
101
104
  isEnabled: boolean;
102
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
103
- createdAt: Date;
104
- updatedAt: Date;
105
105
  }>;
106
106
  update(session: UserSession, id: string, body: UpdateConfigurationInput): Promise<{
107
107
  provider: {
108
+ name: string;
108
109
  key: string;
109
110
  id: string;
110
- name: string;
111
- authType: import("../generated/prisma/enums.js").AuthType;
112
111
  createdAt: Date;
113
112
  updatedAt: Date;
113
+ authType: import("../generated/prisma/enums.js").AuthType;
114
114
  authorizationUrl: string | null;
115
115
  tokenUrl: string | null;
116
116
  revokeUrl: string | null;
@@ -121,19 +121,19 @@ export declare class ConfigurationsController {
121
121
  isActive: boolean;
122
122
  };
123
123
  } & {
124
+ name: string;
124
125
  id: string;
126
+ createdAt: Date;
127
+ updatedAt: Date;
128
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
129
+ scopes: string[];
125
130
  organizationId: string;
126
131
  providerId: string;
127
- name: string;
128
132
  environment: import("../generated/prisma/enums.js").ConnectionEnvironment;
129
133
  authType: import("../generated/prisma/enums.js").AuthType;
130
134
  clientId: string | null;
131
135
  redirectUri: string | null;
132
- scopes: string[];
133
136
  isEnabled: boolean;
134
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
135
- createdAt: Date;
136
- updatedAt: Date;
137
137
  }>;
138
138
  remove(session: UserSession, id: string): Promise<{
139
139
  id: string;
@@ -35,12 +35,12 @@ export declare class ConfigurationsService {
35
35
  callbackUrlFor(providerKey: string): string;
36
36
  list(organizationId: string): Prisma.PrismaPromise<({
37
37
  provider: {
38
+ name: string;
38
39
  key: string;
39
40
  id: string;
40
- name: string;
41
- authType: import("../generated/prisma/enums.js").AuthType;
42
41
  createdAt: Date;
43
42
  updatedAt: Date;
43
+ authType: import("../generated/prisma/enums.js").AuthType;
44
44
  authorizationUrl: string | null;
45
45
  tokenUrl: string | null;
46
46
  revokeUrl: string | null;
@@ -51,28 +51,28 @@ export declare class ConfigurationsService {
51
51
  isActive: boolean;
52
52
  };
53
53
  } & {
54
+ name: string;
54
55
  id: string;
56
+ createdAt: Date;
57
+ updatedAt: Date;
58
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
59
+ scopes: string[];
55
60
  organizationId: string;
56
61
  providerId: string;
57
- name: string;
58
62
  environment: import("../generated/prisma/enums.js").ConnectionEnvironment;
59
63
  authType: import("../generated/prisma/enums.js").AuthType;
60
64
  clientId: string | null;
61
65
  redirectUri: string | null;
62
- scopes: string[];
63
66
  isEnabled: boolean;
64
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
65
- createdAt: Date;
66
- updatedAt: Date;
67
67
  })[]>;
68
68
  get(organizationId: string, id: string): Promise<{
69
69
  provider: {
70
+ name: string;
70
71
  key: string;
71
72
  id: string;
72
- name: string;
73
- authType: import("../generated/prisma/enums.js").AuthType;
74
73
  createdAt: Date;
75
74
  updatedAt: Date;
75
+ authType: import("../generated/prisma/enums.js").AuthType;
76
76
  authorizationUrl: string | null;
77
77
  tokenUrl: string | null;
78
78
  revokeUrl: string | null;
@@ -83,28 +83,28 @@ export declare class ConfigurationsService {
83
83
  isActive: boolean;
84
84
  };
85
85
  } & {
86
+ name: string;
86
87
  id: string;
88
+ createdAt: Date;
89
+ updatedAt: Date;
90
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
91
+ scopes: string[];
87
92
  organizationId: string;
88
93
  providerId: string;
89
- name: string;
90
94
  environment: import("../generated/prisma/enums.js").ConnectionEnvironment;
91
95
  authType: import("../generated/prisma/enums.js").AuthType;
92
96
  clientId: string | null;
93
97
  redirectUri: string | null;
94
- scopes: string[];
95
98
  isEnabled: boolean;
96
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
97
- createdAt: Date;
98
- updatedAt: Date;
99
99
  }>;
100
100
  create(organizationId: string, input: CreateConfigurationInput): Promise<{
101
101
  provider: {
102
+ name: string;
102
103
  key: string;
103
104
  id: string;
104
- name: string;
105
- authType: import("../generated/prisma/enums.js").AuthType;
106
105
  createdAt: Date;
107
106
  updatedAt: Date;
107
+ authType: import("../generated/prisma/enums.js").AuthType;
108
108
  authorizationUrl: string | null;
109
109
  tokenUrl: string | null;
110
110
  revokeUrl: string | null;
@@ -115,28 +115,28 @@ export declare class ConfigurationsService {
115
115
  isActive: boolean;
116
116
  };
117
117
  } & {
118
+ name: string;
118
119
  id: string;
120
+ createdAt: Date;
121
+ updatedAt: Date;
122
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
123
+ scopes: string[];
119
124
  organizationId: string;
120
125
  providerId: string;
121
- name: string;
122
126
  environment: import("../generated/prisma/enums.js").ConnectionEnvironment;
123
127
  authType: import("../generated/prisma/enums.js").AuthType;
124
128
  clientId: string | null;
125
129
  redirectUri: string | null;
126
- scopes: string[];
127
130
  isEnabled: boolean;
128
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
129
- createdAt: Date;
130
- updatedAt: Date;
131
131
  }>;
132
132
  update(organizationId: string, id: string, input: UpdateConfigurationInput): Promise<{
133
133
  provider: {
134
+ name: string;
134
135
  key: string;
135
136
  id: string;
136
- name: string;
137
- authType: import("../generated/prisma/enums.js").AuthType;
138
137
  createdAt: Date;
139
138
  updatedAt: Date;
139
+ authType: import("../generated/prisma/enums.js").AuthType;
140
140
  authorizationUrl: string | null;
141
141
  tokenUrl: string | null;
142
142
  revokeUrl: string | null;
@@ -147,19 +147,19 @@ export declare class ConfigurationsService {
147
147
  isActive: boolean;
148
148
  };
149
149
  } & {
150
+ name: string;
150
151
  id: string;
152
+ createdAt: Date;
153
+ updatedAt: Date;
154
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
155
+ scopes: string[];
151
156
  organizationId: string;
152
157
  providerId: string;
153
- name: string;
154
158
  environment: import("../generated/prisma/enums.js").ConnectionEnvironment;
155
159
  authType: import("../generated/prisma/enums.js").AuthType;
156
160
  clientId: string | null;
157
161
  redirectUri: string | null;
158
- scopes: string[];
159
162
  isEnabled: boolean;
160
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
161
- createdAt: Date;
162
- updatedAt: Date;
163
163
  }>;
164
164
  remove(organizationId: string, id: string): Promise<void>;
165
165
  /**
@@ -169,12 +169,12 @@ export declare class ConfigurationsService {
169
169
  getWithDecryptedSecret(configurationId: string): Promise<{
170
170
  clientSecret: string;
171
171
  provider: {
172
+ name: string;
172
173
  key: string;
173
174
  id: string;
174
- name: string;
175
- authType: import("../generated/prisma/enums.js").AuthType;
176
175
  createdAt: Date;
177
176
  updatedAt: Date;
177
+ authType: import("../generated/prisma/enums.js").AuthType;
178
178
  authorizationUrl: string | null;
179
179
  tokenUrl: string | null;
180
180
  revokeUrl: string | null;
@@ -184,20 +184,20 @@ export declare class ConfigurationsService {
184
184
  logoUrl: string | null;
185
185
  isActive: boolean;
186
186
  };
187
+ name: string;
187
188
  id: string;
189
+ createdAt: Date;
190
+ updatedAt: Date;
191
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
192
+ scopes: string[];
188
193
  organizationId: string;
189
194
  providerId: string;
190
- name: string;
191
195
  environment: import("../generated/prisma/enums.js").ConnectionEnvironment;
192
196
  authType: import("../generated/prisma/enums.js").AuthType;
193
197
  clientId: string | null;
194
198
  encryptedClientSecret: string | null;
195
199
  redirectUri: string | null;
196
- scopes: string[];
197
200
  isEnabled: boolean;
198
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
199
- createdAt: Date;
200
- updatedAt: Date;
201
201
  }>;
202
202
  private validateScopes;
203
203
  /**
@@ -5,26 +5,26 @@ export declare class ConnectionsController {
5
5
  constructor(connections: ConnectionsService);
6
6
  list(session: UserSession, endUserExternalId?: string): import("../generated/prisma/internal/prismaNamespace.js").PrismaPromise<({
7
7
  configuration: {
8
- id: string;
9
8
  name: string;
9
+ id: string;
10
10
  provider: {
11
- key: string;
12
11
  name: string;
12
+ key: string;
13
13
  };
14
14
  };
15
15
  endUser: {
16
16
  name: string | null;
17
- externalId: string;
18
17
  email: string | null;
18
+ externalId: string;
19
19
  };
20
20
  } & {
21
21
  id: string;
22
- organizationId: string;
23
- scopes: string[];
24
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
25
22
  createdAt: Date;
26
23
  updatedAt: Date;
27
24
  status: import("../generated/prisma/enums.js").ConnectionStatus;
25
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
26
+ scopes: string[];
27
+ organizationId: string;
28
28
  endUserId: string;
29
29
  configurationId: string;
30
30
  label: string | null;
@@ -35,26 +35,26 @@ export declare class ConnectionsController {
35
35
  })[]>;
36
36
  get(session: UserSession, id: string): Promise<{
37
37
  configuration: {
38
- id: string;
39
38
  name: string;
39
+ id: string;
40
40
  provider: {
41
- key: string;
42
41
  name: string;
42
+ key: string;
43
43
  };
44
44
  };
45
45
  endUser: {
46
46
  name: string | null;
47
- externalId: string;
48
47
  email: string | null;
48
+ externalId: string;
49
49
  };
50
50
  } & {
51
51
  id: string;
52
- organizationId: string;
53
- scopes: string[];
54
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
55
52
  createdAt: Date;
56
53
  updatedAt: Date;
57
54
  status: import("../generated/prisma/enums.js").ConnectionStatus;
55
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
56
+ scopes: string[];
57
+ organizationId: string;
58
58
  endUserId: string;
59
59
  configurationId: string;
60
60
  label: string | null;
@@ -6,26 +6,26 @@ export declare class ConnectionsService {
6
6
  endUserExternalId?: string;
7
7
  }): import("../generated/prisma/internal/prismaNamespace.js").PrismaPromise<({
8
8
  configuration: {
9
- id: string;
10
9
  name: string;
10
+ id: string;
11
11
  provider: {
12
- key: string;
13
12
  name: string;
13
+ key: string;
14
14
  };
15
15
  };
16
16
  endUser: {
17
17
  name: string | null;
18
- externalId: string;
19
18
  email: string | null;
19
+ externalId: string;
20
20
  };
21
21
  } & {
22
22
  id: string;
23
- organizationId: string;
24
- scopes: string[];
25
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
26
23
  createdAt: Date;
27
24
  updatedAt: Date;
28
25
  status: import("../generated/prisma/enums.js").ConnectionStatus;
26
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
27
+ scopes: string[];
28
+ organizationId: string;
29
29
  endUserId: string;
30
30
  configurationId: string;
31
31
  label: string | null;
@@ -36,26 +36,26 @@ export declare class ConnectionsService {
36
36
  })[]>;
37
37
  get(organizationId: string, id: string): Promise<{
38
38
  configuration: {
39
- id: string;
40
39
  name: string;
40
+ id: string;
41
41
  provider: {
42
- key: string;
43
42
  name: string;
43
+ key: string;
44
44
  };
45
45
  };
46
46
  endUser: {
47
47
  name: string | null;
48
- externalId: string;
49
48
  email: string | null;
49
+ externalId: string;
50
50
  };
51
51
  } & {
52
52
  id: string;
53
- organizationId: string;
54
- scopes: string[];
55
- metadata: import("@prisma/client/runtime/client").JsonValue | null;
56
53
  createdAt: Date;
57
54
  updatedAt: Date;
58
55
  status: import("../generated/prisma/enums.js").ConnectionStatus;
56
+ metadata: import("@prisma/client/runtime/client").JsonValue | null;
57
+ scopes: string[];
58
+ organizationId: string;
59
59
  endUserId: string;
60
60
  configurationId: string;
61
61
  label: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"integration.registry.d.ts","sourceRoot":"","sources":["../../src/integrations/integration.registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAGnF;;;;;GAKG;AACH,qBACa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuC;gBAG/B,YAAY,EAAE,SAAS,gBAAgB,EAAE;IAOvE,6EAA6E;IAC7E,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB;IAUlC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAI/C,IAAI,IAAI,gBAAgB,EAAE;IAI1B,IAAI,IAAI,MAAM,EAAE;IAIhB,2EAA2E;IAC3E,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe;CAGnC"}
1
+ {"version":3,"file":"integration.registry.d.ts","sourceRoot":"","sources":["../../src/integrations/integration.registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAGnC;;;;;GAKG;AACH,qBACa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuC;gBAG/B,YAAY,EAAE,SAAS,gBAAgB,EAAE;IAOvE,6EAA6E;IAC7E,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB;IAUlC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAI/C,IAAI,IAAI,gBAAgB,EAAE;IAI1B,IAAI,IAAI,MAAM,EAAE;IAIhB,2EAA2E;IAC3E,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe;CAGnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosha-ai/server",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Kosha server: OAuth handshake, encrypted credential storage, token refresh, and an authenticated request proxy for third-party integrations",
5
5
  "keywords": [
6
6
  "kosha",
@@ -105,14 +105,14 @@
105
105
  "rxjs": "^7.8.0",
106
106
  "tslib": "^2.3.0",
107
107
  "zod": "4.5.4",
108
- "@kosha-ai/integration-sdk": "0.0.1"
108
+ "@kosha-ai/integration-sdk": "0.0.3"
109
109
  },
110
110
  "devDependencies": {
111
111
  "@nestjs/testing": "^11.0.0",
112
112
  "@types/express": "^5.0.6",
113
113
  "@types/pg": "^8.23.1",
114
114
  "prisma": "^7.10.0",
115
- "@kosha-ai/integration-github": "0.0.1",
116
- "@kosha-ai/integration-slack": "0.0.1"
115
+ "@kosha-ai/integration-github": "0.0.3",
116
+ "@kosha-ai/integration-slack": "0.0.3"
117
117
  }
118
118
  }