Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/rekor-fetch-on-conflict.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sigstore/sign": patch
---

Fetch existing Rekor entries by default when a create request returns a conflict.
17 changes: 17 additions & 0 deletions packages/sign/src/__tests__/witness/tlog/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@ describe('TLogClient', () => {
.reply(409, {}, { Location: `/api/v1/log/entries/${uuid}` });
});

describe('by default', () => {
const subject = new TLogClient({ rekorBaseURL });

describe('when the fetch is successful', () => {
beforeEach(() => {
nock(rekorBaseURL)
.get(`/api/v1/log/entries/${uuid}`)
.reply(200, rekorEntry);
});

it('returns a tlog entry', async () => {
const entry = await subject.createEntry(proposedEntry);
expect(entry).toBeTruthy();
});
});
});

describe('when fetchOnConflict is false', () => {
const subject = new TLogClient({
rekorBaseURL,
Expand Down
2 changes: 1 addition & 1 deletion packages/sign/src/witness/tlog/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class TLogClient implements TLog {
private fetchOnConflict: boolean;

constructor(options: TLogClientOptions) {
this.fetchOnConflict = options.fetchOnConflict ?? false;
this.fetchOnConflict = options.fetchOnConflict ?? true;
this.rekor = new Rekor({
baseURL: options.rekorBaseURL,
retry: options.retry,
Expand Down