Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const testCredentialCipher = createEnvKeyCredentialCipher(
export function recordingRouter() {
const mail: Parameters<HookRouter["routeMail"]>[] = [];
const router: HookRouter = {
routeMail: (...args) => {
routeMail: async (...args) => {
mail.push(args);
return true;
},
Expand Down
9 changes: 5 additions & 4 deletions e2e/hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import {
type TestDb,
} from "./helpers.js";

const TENANT = "tnt_e2e";
const TENANT = "tnte2e";
const CREATOR = "prn_creator";
const DEFINITION = "wfd_hook";
const DEPLOYMENT = "run_hook";
const ADDRESS = "run_hook@tnt_e2e.example.test";
const ADDRESS = "run_hook@tnte2e.example.test";
const HOOK = "crd_hook";
const SECRET = "whsec_c2VjcmV0LWtleS1ieXRlcw==";

Expand Down Expand Up @@ -80,6 +80,7 @@ async function seedDeployment(db: TestDb["db"]): Promise<void> {
anchorRunId: DEPLOYMENT,
definitionId: DEFINITION,
address: ADDRESS,
publicKey: "pk_hook",
status: "deployed",
});
await db.insert(provider).values({
Expand Down Expand Up @@ -230,10 +231,10 @@ describe.skipIf(!harnessDbAvailable())(
test("the tenant-scoped name path resolves only inside that tenant", async () => {
const recorded = recordingRouter();
const app = mountHookRoutes({ db: db(), router: recorded.router });
await seedTenant(db(), "tnt_other");
await seedTenant(db(), "tntother");
const body = `{"text":"hi"}`;

const miss = await app.request("/api/hooks/tnt_other/my-hook", {
const miss = await app.request("/api/hooks/tntother/my-hook", {
method: "POST",
headers: await standardWebhooksHeaders(body),
body,
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@corbits/webhooks",
"version": "0.3.1",
"version": "0.3.2",
"description": "Receive signed webhooks (Slack, Standard Webhooks, bearer) and start a workflow run.",
"keywords": [
"corbits",
Expand Down Expand Up @@ -53,13 +53,13 @@
"check": "bun run typecheck && bun run lint && bun run format:check && bun run test"
},
"devDependencies": {
"@intx/crypto": "0.4.0",
"@intx/db": "0.4.0",
"@intx/hub-api": "0.4.0",
"@intx/hub-common": "0.4.0",
"@intx/hub-sessions": "0.4.0",
"@intx/mime": "0.4.0",
"@intx/types": "0.4.0",
"@intx/crypto": "0.5.0",
"@intx/db": "0.5.0",
"@intx/hub-api": "0.5.0",
"@intx/hub-common": "0.5.0",
"@intx/hub-sessions": "0.5.0",
"@intx/mime": "0.5.0",
"@intx/types": "0.5.0",
"@types/bun": "1.3.9",
"drizzle-orm": "0.45.3",
"hono": "4.11.9",
Expand All @@ -69,13 +69,13 @@
"typescript": "5.9.3"
},
"peerDependencies": {
"@intx/crypto": "^0.4.0",
"@intx/db": "^0.4.0",
"@intx/hub-api": "^0.4.0",
"@intx/hub-common": "^0.4.0",
"@intx/hub-sessions": "^0.4.0",
"@intx/mime": "^0.4.0",
"@intx/types": "^0.4.0",
"@intx/crypto": "^0.5.0",
"@intx/db": "^0.5.0",
"@intx/hub-api": "^0.5.0",
"@intx/hub-common": "^0.5.0",
"@intx/hub-sessions": "^0.5.0",
"@intx/mime": "^0.5.0",
"@intx/types": "^0.5.0",
"drizzle-orm": "^0.45.1",
"hono": "^4.11.9",
"postgres": "^3.4.8"
Expand Down
4 changes: 2 additions & 2 deletions src/deliver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function durableSystemSender() {
function recordingRouter() {
const calls: Parameters<HookRouter["routeMail"]>[] = [];
const router: HookRouter = {
routeMail: (...args) => {
routeMail: async (...args) => {
calls.push(args);
return true;
},
Expand Down Expand Up @@ -165,7 +165,7 @@ describe("createRunTriggerDeliverer", () => {
test("a dead run address fails with its run identity, not a bare string", async () => {
const sender = await durableSystemSender();
const recorded = recordingRouter();
recorded.router.routeMail = () => false;
recorded.router.routeMail = async () => false;
const error = await deliverer(recorded.router, sender.sender)
.to(ADDRESS, "tick", "tnt_1", undefined)
.then(
Expand Down
2 changes: 2 additions & 0 deletions src/deliver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export function createRunTriggerDeliverer(
throw new Error("destination is not a workflow deployment");
case "materialized":
break;
case "notReady":
throw new Error("destination run grants are not ready");
default:
grants satisfies never;
}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function handle(c: Context, opts: HookAppOptions) {
}

const tenantHint =
(pathTenant?.startsWith("tnt_") ? pathTenant : undefined) ??
pathTenant ??
emptyToUndef(c.req.header("x-tenant-id")) ??
emptyToUndef(c.req.query("tenant"));

Expand Down
Loading