cognova 0.2.21 → 0.2.23

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.
@@ -1,4 +1,4 @@
1
- import { d as defineEventHandler, a6 as getAdapterByPlatform, c as createError, e as readBody } from '../../../nitro/nitro.mjs';
1
+ import { d as defineEventHandler, a6 as getAdapterByPlatform, c as createError, i as getQuery, e as readBody } from '../../../nitro/nitro.mjs';
2
2
  import '@anthropic-ai/claude-agent-sdk';
3
3
  import 'module';
4
4
  import 'path';
@@ -44,6 +44,11 @@ const bluebubbles_post = defineEventHandler(async (event) => {
44
44
  throw createError({ statusCode: 404, message: "iMessage bridge not active" });
45
45
  }
46
46
  const adapter = entry.adapter;
47
+ const query = getQuery(event);
48
+ const providedSecret = query.secret;
49
+ if (!providedSecret || providedSecret !== adapter.secret) {
50
+ throw createError({ statusCode: 403, message: "Invalid webhook secret" });
51
+ }
47
52
  const body = await readBody(event);
48
53
  void adapter.handleWebhook(body).catch((error) => {
49
54
  console.error("[bluebubbles webhook] Error processing event:", error);
@@ -1 +1 @@
1
- {"version":3,"file":"bluebubbles.post.mjs","sources":["../../../../../../server/api/webhooks/bluebubbles.post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,yBAAA,kBAAA,CAAA,OAAA,KAAA,KAAA;AACA,EAAA,MAAA,KAAA,GAAA,qBAAA,UAAA,CAAA;AACA,EAAA,IAAA,CAAA,KAAA,EAAA;AACA,IAAA,MAAA,YAAA,EAAA,UAAA,EAAA,GAAA,EAAA,OAAA,EAAA,8BAAA,CAAA;AAAA,EACA;AAEA,EAAA,MAAA,UAAA,KAAA,CAAA,OAAA;AACA,EAAA,MAAA,IAAA,GAAA,MAAA,QAAA,CAAA,KAAA,CAAA;AAGA,EAAA,KAAA,QAAA,aAAA,CAAA,IAAA,CAAA,CAAA,KAAA,CAAA,CAAA,KAAA,KAAA;AACA,IAAA,OAAA,CAAA,KAAA,CAAA,iDAAA,KAAA,CAAA;AAAA,EACA,CAAA,CAAA;AAEA,EAAA,OAAA,EAAA,IAAA,IAAA,EAAA;AACA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"bluebubbles.post.mjs","sources":["../../../../../../server/api/webhooks/bluebubbles.post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,yBAAA,kBAAA,CAAA,OAAA,KAAA,KAAA;AACA,EAAA,MAAA,KAAA,GAAA,qBAAA,UAAA,CAAA;AACA,EAAA,IAAA,CAAA,KAAA,EAAA;AACA,IAAA,MAAA,YAAA,EAAA,UAAA,EAAA,GAAA,EAAA,OAAA,EAAA,8BAAA,CAAA;AAAA,EACA;AAEA,EAAA,MAAA,UAAA,KAAA,CAAA,OAAA;AAGA,EAAA,MAAA,KAAA,GAAA,SAAA,KAAA,CAAA;AACA,EAAA,MAAA,iBAAA,KAAA,CAAA,MAAA;AACA,EAAA,IAAA,CAAA,cAAA,IAAA,cAAA,KAAA,OAAA,CAAA,MAAA,EAAA;AACA,IAAA,MAAA,YAAA,EAAA,UAAA,EAAA,GAAA,EAAA,OAAA,EAAA,0BAAA,CAAA;AAAA,EACA;AAEA,EAAA,MAAA,IAAA,GAAA,MAAA,QAAA,CAAA,KAAA,CAAA;AAGA,EAAA,KAAA,QAAA,aAAA,CAAA,IAAA,CAAA,CAAA,KAAA,CAAA,CAAA,KAAA,KAAA;AACA,IAAA,OAAA,CAAA,KAAA,CAAA,iDAAA,KAAA,CAAA;AAAA,EACA,CAAA,CAAA;AAEA,EAAA,OAAA,EAAA,IAAA,IAAA,EAAA;AACA,CAAA,CAAA;;;;"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cognova-prod",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "type": "module",
5
5
  "private": true,
6
6
  "dependencies": {
package/dist/cli/index.js CHANGED
@@ -1751,6 +1751,9 @@ function generateEnvFile(config) {
1751
1751
  `BETTER_AUTH_SECRET=${config.auth.authSecret || crypto2.randomBytes(32).toString("base64")}`,
1752
1752
  `BETTER_AUTH_URL=${config.accessMode === "any" ? "" : config.appUrl}`,
1753
1753
  "",
1754
+ "# Public URL for webhooks (BlueBubbles, Telegram, etc.)",
1755
+ `NUXT_PUBLIC_URL=${config.accessMode === "any" ? "" : config.appUrl}`,
1756
+ "",
1754
1757
  "# Admin (used on first startup to seed database)",
1755
1758
  `ADMIN_EMAIL=${config.auth.adminEmail}`,
1756
1759
  `ADMIN_PASSWORD=${config.auth.adminPassword}`,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cognova",
3
3
  "type": "module",
4
- "version": "0.2.21",
4
+ "version": "0.2.23",
5
5
  "description": "Personal knowledge management system with Claude Code integration",
6
6
  "repository": {
7
7
  "type": "git",
@@ -12,6 +12,14 @@ export default defineEventHandler(async (event) => {
12
12
  }
13
13
 
14
14
  const adapter = entry.adapter as IMessageAdapter
15
+
16
+ // Validate webhook secret
17
+ const query = getQuery(event)
18
+ const providedSecret = query.secret as string | undefined
19
+ if (!providedSecret || providedSecret !== adapter.secret) {
20
+ throw createError({ statusCode: 403, message: 'Invalid webhook secret' })
21
+ }
22
+
15
23
  const body = await readBody<BlueBubblesWebhookEvent>(event)
16
24
 
17
25
  // Process asynchronously — return 200 quickly
@@ -160,8 +160,7 @@ export class IMessageAdapter implements BridgeAdapter {
160
160
  body: JSON.stringify({
161
161
  chatGuid,
162
162
  tempGuid: `temp-${randomBytes(16).toString('hex')}`,
163
- message: msg.text,
164
- method: 'private-api'
163
+ message: msg.text
165
164
  })
166
165
  })
167
166
 
@@ -186,7 +185,7 @@ export class IMessageAdapter implements BridgeAdapter {
186
185
  private getWebhookUrl(): string | null {
187
186
  const baseUrl = process.env.NUXT_PUBLIC_URL || process.env.APP_URL
188
187
  if (baseUrl)
189
- return `${baseUrl.replace(/\/$/, '')}/api/webhooks/bluebubbles`
188
+ return `${baseUrl.replace(/\/$/, '')}/api/webhooks/bluebubbles?secret=${this.webhookSecret}`
190
189
  return null
191
190
  }
192
191
 
@@ -194,7 +193,7 @@ export class IMessageAdapter implements BridgeAdapter {
194
193
  if (!this.bbUrl || !this.bbPassword) return
195
194
 
196
195
  try {
197
- await fetch(`${this.bbUrl}/api/v1/webhook?password=${encodeURIComponent(this.bbPassword)}`, {
196
+ const resp = await fetch(`${this.bbUrl}/api/v1/webhook?password=${encodeURIComponent(this.bbPassword)}`, {
198
197
  method: 'POST',
199
198
  headers: { 'Content-Type': 'application/json' },
200
199
  body: JSON.stringify({
@@ -202,6 +201,13 @@ export class IMessageAdapter implements BridgeAdapter {
202
201
  events: ['new-message']
203
202
  })
204
203
  })
204
+
205
+ if (!resp.ok) {
206
+ const body = await resp.text()
207
+ console.warn(`[imessage] Failed to register BlueBubbles webhook: ${resp.status} ${body.substring(0, 200)}`)
208
+ return
209
+ }
210
+
205
211
  console.log(`[imessage] BlueBubbles webhook registered: ${url}`)
206
212
  } catch (error) {
207
213
  console.warn('[imessage] Failed to register BlueBubbles webhook:', error)
@@ -8,6 +8,7 @@ const publicPaths = [
8
8
  '/api/health', // Health check
9
9
  '/api/home', // Public home page content
10
10
  '/api/_mdc', // MDC syntax highlighting
11
+ '/api/webhooks', // External webhooks (BlueBubbles, Telegram, etc.)
11
12
  '/_nuxt', // Nuxt assets
12
13
  '/login', // Login page
13
14
  '/view' // Public document viewer
@@ -1 +0,0 @@
1
- {"id":"36770554-14f7-4f3a-add8-2f51436e3d25","timestamp":1771901252223,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}