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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ Required values:
Important distinction:

- `TRUSTSIGNAL_API_BASE_URL` is the outbound verification API this service calls, for example `https://api.trustsignal.dev`.
- Primary route expected by this service: `${TRUSTSIGNAL_API_BASE_URL}/v1/verifications/github`
- Compatibility route (if needed): `${TRUSTSIGNAL_API_BASE_URL}/api/v1/verifications/github`
- Primary route expected by this service: `${TRUSTSIGNAL_API_BASE_URL}/api/v1/verifications/github`
- Compatibility route (if needed): `${TRUSTSIGNAL_API_BASE_URL}/v1/verifications/github`

The API base URL is distinct from the webhook host:
- App callback/base webhook host: `https://github.trustsignal.dev`
Expand Down
4 changes: 2 additions & 2 deletions apps/action/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4152,7 +4152,7 @@ function mapProvenanceEventName(eventName) {
// src/trustsignal/client.ts
var TrustSignalVerificationClient = class {
baseUrl;
candidatePaths = ["/v1/verifications/github", "/api/v1/verifications/github"];
candidatePaths = ["/api/v1/verifications/github", "/v1/verifications/github"];
timeoutMs;
fetchImpl;
constructor(config, fetchImpl = globalThis.fetch) {
Expand Down Expand Up @@ -4220,7 +4220,7 @@ var TrustSignalVerificationClient = class {
}
}
canFallback(path) {
return path === "/v1/verifications/github";
return path === "/api/v1/verifications/github";
}
};
function looksLikeJson(value) {
Expand Down
4 changes: 2 additions & 2 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ This keeps the website, outbound verification API, and inbound webhook receiver

`TRUSTSIGNAL_API_BASE_URL` must target the API origin only and is currently normalized as:

- Primary path: `/v1/verifications/github`
- Compatibility path: `/api/v1/verifications/github` (used when the primary route is unavailable)
- Primary path: `/api/v1/verifications/github`
- Compatibility path: `/v1/verifications/github` (used when the primary route is unavailable)

If the API is moved or renamed, update `TRUSTSIGNAL_API_BASE_URL` and keep only one canonical base URL.

Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
"sha": "'"${GITHUB_SHA}"'",
"artifactDigest": "'"${{ steps.digest.outputs.sha256 }}"'"
}' \
"${TRUSTSIGNAL_API_BASE_URL}/v1/verifications/github"
"${TRUSTSIGNAL_API_BASE_URL}/api/v1/verifications/github"
```

## Compatibility Notes
Expand Down
4 changes: 2 additions & 2 deletions src/trustsignal/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface FetchLike {

export class TrustSignalVerificationClient {
private readonly baseUrl: string;
private readonly candidatePaths = ["/v1/verifications/github", "/api/v1/verifications/github"] as const;
private readonly candidatePaths = ["/api/v1/verifications/github", "/v1/verifications/github"] as const;
private readonly timeoutMs: number;
private readonly fetchImpl: FetchLike;

Expand Down Expand Up @@ -111,7 +111,7 @@ export class TrustSignalVerificationClient {
}

private canFallback(path: (typeof this.candidatePaths)[number]) {
return path === "/v1/verifications/github";
return path === "/api/v1/verifications/github";
}
}

Expand Down
12 changes: 6 additions & 6 deletions tests/trustsignalClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("TrustSignalVerificationClient", () => {
const result = await client.verify(request);

expect(fetchImpl).toHaveBeenCalledWith(
"https://trustsignal.example.com/v1/verifications/github",
"https://trustsignal.example.com/api/v1/verifications/github",
expect.objectContaining({
method: "POST",
headers: expect.objectContaining({
Expand All @@ -62,7 +62,7 @@ describe("TrustSignalVerificationClient", () => {
expect(result.receiptId).toBe("rcpt_1");
});

it("falls back to /api/v1/verifications/github when /v1 returns HTML", async () => {
it("falls back to /v1/verifications/github when /api returns HTML", async () => {
const fallbackResponse = {
ok: true,
status: 200,
Expand All @@ -89,7 +89,7 @@ describe("TrustSignalVerificationClient", () => {
};

const fetchImplementation = vi.fn(async (url: string) => {
const response = url === "https://trustsignal.example.com/v1/verifications/github" ? primaryResponse : fallbackResponse;
const response = url === "https://trustsignal.example.com/api/v1/verifications/github" ? primaryResponse : fallbackResponse;
return {
ok: response.ok,
status: response.status,
Expand Down Expand Up @@ -131,7 +131,7 @@ describe("TrustSignalVerificationClient", () => {
expect(fetchImplementation).toHaveBeenCalledTimes(2);
expect(fetchImplementation).toHaveBeenNthCalledWith(
1,
"https://trustsignal.example.com/v1/verifications/github",
"https://trustsignal.example.com/api/v1/verifications/github",
expect.objectContaining({
method: "POST",
headers: expect.objectContaining({
Expand All @@ -141,7 +141,7 @@ describe("TrustSignalVerificationClient", () => {
);
expect(fetchImplementation).toHaveBeenNthCalledWith(
2,
"https://trustsignal.example.com/api/v1/verifications/github",
"https://trustsignal.example.com/v1/verifications/github",
expect.objectContaining({
method: "POST",
headers: expect.objectContaining({
Expand Down Expand Up @@ -188,7 +188,7 @@ describe("TrustSignalVerificationClient", () => {
},
});

await expect(client.verify(request)).rejects.toThrow("TrustSignal verification response for https://trustsignal.example.com/api/v1/verifications/github was not JSON");
await expect(client.verify(request)).rejects.toThrow("TrustSignal verification response for https://trustsignal.example.com/v1/verifications/github was not JSON");
expect(fetchImplementation).toHaveBeenCalledTimes(2);
});
});
Loading