diff --git a/README.md b/README.md index c6eac4e..4435eb0 100644 --- a/README.md +++ b/README.md @@ -685,6 +685,15 @@ The SDK provides commands for ingesting events into Flowcore event types. > **Important**: Ingestion operations require API key authentication. +Create an API-key client before running either ingestion command. The SDK sends the raw key in the `Authorization` header and keeps it out of the webhook URL. Load the key from a secret store; do not put it in a query string. + +```typescript +const client = new FlowcoreClient({ + apiKeyId: process.env.FLOWCORE_API_KEY_ID!, + apiKey: process.env.FLOWCORE_API_KEY!, +}) +``` + #### Ingest a Single Event ```typescript diff --git a/test/fixtures/fetch.fixture.ts b/test/fixtures/fetch.fixture.ts index e4896d7..4370ba7 100644 --- a/test/fixtures/fetch.fixture.ts +++ b/test/fixtures/fetch.fixture.ts @@ -8,6 +8,7 @@ interface MockedRequest { path: string headers: Record | null searchParams: Record | null + noSearchParams: boolean body: string | Record | Array | null status: number response: string | Record | Array | null @@ -160,6 +161,10 @@ export class FetchMockBuilder { } } + if (mockedRequest.noSearchParams && Object.keys(searchParams).length > 0) { + return false + } + if (mockedRequest.headers) { try { assertObjectMatch(mockedRequest.headers, headers) @@ -213,6 +218,7 @@ class FetchMockBuilderPath { private path: string private headers: Record | null = null private searchParams: Record | null = null + private noSearchParams = false private body: string | Record | Array | null = null private status = 200 private response: string | Record | Array | null = null @@ -230,6 +236,11 @@ class FetchMockBuilderPath { return this } + public withoutSearchParams() { + this.noSearchParams = true + return this + } + public matchBody(body: string | Record | Array) { this.body = body return this @@ -261,6 +272,7 @@ class FetchMockBuilderPath { path: this.path, headers: this.headers, searchParams: this.searchParams, + noSearchParams: this.noSearchParams, body: this.body, status: this.status, response: this.response, diff --git a/test/tests/commands/ingestion.test.ts b/test/tests/commands/ingestion.test.ts index 3a40dcd..5bfb976 100644 --- a/test/tests/commands/ingestion.test.ts +++ b/test/tests/commands/ingestion.test.ts @@ -30,6 +30,7 @@ describe("Ingestion", () => { const fetchMockerBuilder = fetchMocker.mock(mockWebhookUrl) fetchMockerBuilder.post(`/event/${tenantName}/${dataCoreId}/${flowTypeName}/${eventTypeName}`) + .withoutSearchParams() .matchBody(eventData) .matchHeaders({ "Content-Type": "application/json", @@ -233,6 +234,7 @@ describe("Ingestion", () => { const fetchMockerBuilder = fetchMocker.mock(mockWebhookUrl) fetchMockerBuilder.post(`/events/${tenantName}/${dataCoreId}/${flowTypeName}/${eventTypeName}`) + .withoutSearchParams() .matchBody(events) .matchHeaders({ "Content-Type": "application/json",