Repository navigation
fix(integrations): validate fathom, grain, obsidian and fireflies #10166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c69831b
fix(integrations): validate fathom, grain, obsidian and fireflies
waleedlatif1 fa43cc8
fix(fathom): fail closed without a signing secret and nest trigger ob…
waleedlatif1 f0f9c4e
fix(fathom): keep the missing-secret log message static
waleedlatif1 ef9d85b
fix(fathom): log a failed orphan webhook delete
waleedlatif1 47ada0c
fix(fireflies): only pass through a numeric reprocessed_at
waleedlatif1 a909d60
fix(fathom): keep recorder and summary outputs open and correct the l…
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import crypto from 'node:crypto' | ||
| import { NextRequest } from 'next/server' | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { fathomHandler } from '@/lib/webhooks/providers/fathom' | ||
|
|
||
| const SECRET_BYTES = Buffer.from('fathom-test-secret-key-padding!!!!!!') | ||
| const SIGNING_SECRET = `whsec_${SECRET_BYTES.toString('base64')}` | ||
|
|
||
| function sign(msgId: string, timestamp: string, rawBody: string): string { | ||
| const sig = crypto | ||
| .createHmac('sha256', SECRET_BYTES) | ||
| .update(`${msgId}.${timestamp}.${rawBody}`, 'utf8') | ||
| .digest('base64') | ||
| return `v1,${sig}` | ||
| } | ||
|
|
||
| function request(msgId: string, timestamp: string, signature: string): NextRequest { | ||
| return new NextRequest('http://localhost/test', { | ||
| headers: { | ||
| 'webhook-id': msgId, | ||
| 'webhook-timestamp': timestamp, | ||
| 'webhook-signature': signature, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| const nowSeconds = () => `${Math.floor(Date.now() / 1000)}` | ||
| const rawBody = JSON.stringify({ title: 'QBR', recording_id: 123 }) | ||
|
|
||
| describe('Fathom webhook provider verifyAuth', () => { | ||
| it('rejects a forged delivery when the webhook has a signing secret', async () => { | ||
| const res = await fathomHandler.verifyAuth?.({ | ||
| webhook: {}, | ||
| workflow: {}, | ||
| request: request('msg_1', nowSeconds(), 'v1,Zm9yZ2Vk'), | ||
| rawBody, | ||
| requestId: 'fathom-t1', | ||
| providerConfig: { signingSecret: SIGNING_SECRET }, | ||
| }) | ||
|
|
||
| expect(res?.status).toBe(401) | ||
| }) | ||
|
|
||
| it('accepts a correctly signed delivery', async () => { | ||
| const ts = nowSeconds() | ||
| const res = await fathomHandler.verifyAuth?.({ | ||
| webhook: {}, | ||
| workflow: {}, | ||
| request: request('msg_1', ts, sign('msg_1', ts, rawBody)), | ||
| rawBody, | ||
| requestId: 'fathom-t2', | ||
| providerConfig: { signingSecret: SIGNING_SECRET }, | ||
| }) | ||
|
|
||
| expect(res).toBeNull() | ||
| }) | ||
|
|
||
| it('keeps accepting webhooks registered before the secret was stored', async () => { | ||
| const res = await fathomHandler.verifyAuth?.({ | ||
| webhook: {}, | ||
| workflow: {}, | ||
| request: request('msg_1', nowSeconds(), 'v1,Zm9yZ2Vk'), | ||
| rawBody, | ||
| requestId: 'fathom-t3', | ||
| providerConfig: {}, | ||
| }) | ||
|
|
||
| expect(res ?? null).toBeNull() | ||
| }) | ||
| }) | ||
|
|
||
| describe('Fathom webhook provider createSubscription', () => { | ||
| const fetchMock = vi.fn() | ||
|
|
||
| beforeEach(() => { | ||
| fetchMock.mockReset() | ||
| vi.stubGlobal('fetch', fetchMock) | ||
| }) | ||
|
|
||
| it('stores the signing secret Fathom returns', async () => { | ||
| fetchMock.mockResolvedValueOnce({ | ||
| ok: true, | ||
| status: 201, | ||
| json: async () => ({ id: 'ikEoQ4bVoq4JYUmc', secret: SIGNING_SECRET }), | ||
| }) | ||
|
|
||
| const result = await fathomHandler.createSubscription?.({ | ||
| webhook: { id: 'wh_1', path: 'p1', providerConfig: { apiKey: 'fathom_key' } }, | ||
| requestId: 'fathom-sub1', | ||
| } as never) | ||
|
|
||
| expect(result?.providerConfigUpdates).toEqual({ | ||
| externalId: 'ikEoQ4bVoq4JYUmc', | ||
| signingSecret: SIGNING_SECRET, | ||
| }) | ||
| }) | ||
|
|
||
| it('deletes the webhook and fails when the response omits the signing secret', async () => { | ||
| fetchMock.mockResolvedValueOnce({ | ||
| ok: true, | ||
| status: 201, | ||
| json: async () => ({ id: 'ikEoQ4bVoq4JYUmc' }), | ||
| }) | ||
| fetchMock.mockResolvedValueOnce({ ok: true, status: 204 }) | ||
|
|
||
| await expect( | ||
| fathomHandler.createSubscription?.({ | ||
| webhook: { id: 'wh_2', path: 'p2', providerConfig: { apiKey: 'fathom_key' } }, | ||
| requestId: 'fathom-sub2', | ||
| } as never) | ||
| ).rejects.toThrow(/signing secret/) | ||
|
|
||
| const [url, init] = fetchMock.mock.calls[1] | ||
| expect(init.method).toBe('DELETE') | ||
| expect(url).toBe('https://api.fathom.ai/external/v1/webhooks/ikEoQ4bVoq4JYUmc') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import type { OutputSchema } from '@/executor/utils/block-reference' | ||
| import { isPathInSchema } from '@/executor/utils/block-reference' | ||
| import { buildMeetingOutputs } from '@/triggers/fathom/utils' | ||
|
|
||
| describe('Fathom meeting trigger outputs', () => { | ||
| const schema = buildMeetingOutputs() as unknown as OutputSchema | ||
|
|
||
| it('resolves the documented recorder and summary fields', () => { | ||
| expect(isPathInSchema(schema, ['recorded_by', 'team'])).toBe(true) | ||
| expect(isPathInSchema(schema, ['default_summary', 'markdown_formatted'])).toBe(true) | ||
| }) | ||
|
|
||
| it('keeps accepting sub-paths saved before the fields were declared', () => { | ||
| expect(isPathInSchema(schema, ['recorded_by', 'id'])).toBe(true) | ||
| expect(isPathInSchema(schema, ['default_summary', 'sections'])).toBe(true) | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.