@worktango/ai-assistant 0.0.37 → 0.0.38

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.
package/dist/express.js CHANGED
@@ -11195,10 +11195,14 @@ function setupAiAssistantRoutes(args) {
11195
11195
  target: `${protocol}://${args.targetHost}:${port}`,
11196
11196
  changeOrigin: true,
11197
11197
  pathRewrite: (path, req) => {
11198
- return args.getTargetPath(req.url || path);
11198
+ const expressRequest = req;
11199
+ return args.getTargetPath(expressRequest.originalUrl || path);
11199
11200
  },
11200
11201
  on: {
11201
11202
  proxyReq: async (proxyReq, req) => {
11203
+ if (!proxyReq.writable) {
11204
+ return;
11205
+ }
11202
11206
  try {
11203
11207
  const bearerToken = await args.getBearerToken(req.headers);
11204
11208
  proxyReq.setHeader("Authorization", `Bearer ${bearerToken}`);
package/express.d.ts CHANGED
@@ -7,7 +7,9 @@ export function setupAiAssistantRoutes(args: {
7
7
  * back-channel request proxying. This should be a JWT token that can be
8
8
  * decoded on the `kazoo-web` application to authenticate the request.
9
9
  */
10
- getBearerToken: (req: Request) => Promise<string>;
10
+ getBearerToken: (
11
+ headers: Record<string, undefined | string | string[]>
12
+ ) => Promise<string>;
11
13
  /**
12
14
  * The host of the application to proxy requests to.
13
15
  */
@@ -31,8 +33,15 @@ export function setupAiAssistantRoutes(args: {
31
33
  preflightMiddlewares?: RequestHandler[];
32
34
  /**
33
35
  * A function that should return the target path for the proxy request, based
34
- * on the incoming request object. The path returned will be appended to the
36
+ * on the incoming full path. The path returned will be appended to the
35
37
  * target host and port to form the final URL.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * getTargetPath: (fullPath) => {
42
+ * return fullPath;
43
+ * }
44
+ * ```
36
45
  */
37
- getTargetPath: (req: Request) => string;
46
+ getTargetPath: (fullPath: string) => string;
38
47
  }): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worktango/ai-assistant",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
4
4
  "files": [
5
5
  "dist",
6
6
  "express.d.ts",