The Coline App SDK: apps, tools, file types and surfaces that run inside Coline workspaces, and public websites with Coline Sites. TypeScript, with an in-memory test workspace. MIT.
| 5 |
| COLINE_SIGNATURE_HEADER, |
| 6 | COLINE_TIMESTAMP_HEADER, |
| 7 | createSignedAppRequestHeaders, |
| 8 | signAppRequest, |
| 9 | verifyAppRequestSignature, |
| 10 | } from "./signing"; |
| 11 |
| 12 | describe("app signing helpers", () => { |
| 13 | it("builds the canonical signing payload", () => { |
| 14 | expect( |
| 15 | buildSigningPayload({ |
| 16 | timestamp: "2026-03-08T12:00:00.000Z", |
| 17 | body: "{\"ok\":true}", |
| 18 | }), |
| 19 | ).toBe("2026-03-08T12:00:00.000Z.{\"ok\":true}"); |
| 20 | }); |
| 21 |
| 22 | it("signs and verifies a request body", async () => { |
| 23 | const signature = await signAppRequest({ |
| 24 | secret: "test-signing-secret-with-at-least-16", |
| 25 | timestamp: "2026-03-08T12:00:00.000Z", |
| 26 | body: "{\"type\":\"app.home.render.requested\"}", |
| 27 | }); |
| 28 |
| 29 | expect(signature).toMatch(/^[a-f0-9]+$/); |
| 30 | await expect( |
| 31 | verifyAppRequestSignature({ |
| 32 | secret: "test-signing-secret-with-at-least-16", |
| 33 | timestamp: "2026-03-08T12:00:00.000Z", |
| 34 | body: "{\"type\":\"app.home.render.requested\"}", |
| 35 | signature, |
| 36 | }), |
| 37 | ).resolves.toBe(true); |
| 38 | }); |
| 39 |
| 40 | it("creates a full header map for outbound delivery", async () => { |
| 41 | const headers = await createSignedAppRequestHeaders({ |
| 42 | secret: "test-signing-secret-with-at-least-16", |
| 43 | body: "{\"id\":\"delivery_1\"}", |
| 44 | deliveryId: "delivery_1", |
| 45 | timestamp: "2026-03-08T12:00:00.000Z", |
| 46 | }); |
| 47 |
| 48 | expect(headers[COLINE_DELIVERY_HEADER]).toBe("delivery_1"); |
| 49 | expect(headers[COLINE_TIMESTAMP_HEADER]).toBe("2026-03-08T12:00:00.000Z"); |
| 50 | expect(headers[COLINE_SIGNATURE_HEADER]).toBeDefined(); |
| 51 | }); |
| 52 | }); |
| 53 |