cognova 0.2.21 → 0.2.22

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.22",
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.22",
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
@@ -186,7 +186,7 @@ export class IMessageAdapter implements BridgeAdapter {
186
186
  private getWebhookUrl(): string | null {
187
187
  const baseUrl = process.env.NUXT_PUBLIC_URL || process.env.APP_URL
188
188
  if (baseUrl)
189
- return `${baseUrl.replace(/\/$/, '')}/api/webhooks/bluebubbles`
189
+ return `${baseUrl.replace(/\/$/, '')}/api/webhooks/bluebubbles?secret=${this.webhookSecret}`
190
190
  return null
191
191
  }
192
192
 
@@ -194,7 +194,7 @@ export class IMessageAdapter implements BridgeAdapter {
194
194
  if (!this.bbUrl || !this.bbPassword) return
195
195
 
196
196
  try {
197
- await fetch(`${this.bbUrl}/api/v1/webhook?password=${encodeURIComponent(this.bbPassword)}`, {
197
+ const resp = await fetch(`${this.bbUrl}/api/v1/webhook?password=${encodeURIComponent(this.bbPassword)}`, {
198
198
  method: 'POST',
199
199
  headers: { 'Content-Type': 'application/json' },
200
200
  body: JSON.stringify({
@@ -202,6 +202,13 @@ export class IMessageAdapter implements BridgeAdapter {
202
202
  events: ['new-message']
203
203
  })
204
204
  })
205
+
206
+ if (!resp.ok) {
207
+ const body = await resp.text()
208
+ console.warn(`[imessage] Failed to register BlueBubbles webhook: ${resp.status} ${body.substring(0, 200)}`)
209
+ return
210
+ }
211
+
205
212
  console.log(`[imessage] BlueBubbles webhook registered: ${url}`)
206
213
  } catch (error) {
207
214
  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":[]}