| 1 |
"use strict"; |
| 2 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 3 |
exports.RekorV2 = void 0; |
| 4 |
/* |
| 5 |
Copyright 2025 The Sigstore Authors. |
| 6 |
|
| 7 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 |
you may not use this file except in compliance with the License. |
| 9 |
You may obtain a copy of the License at |
| 10 |
|
| 11 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 12 |
|
| 13 |
Unless required by applicable law or agreed to in writing, software |
| 14 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 15 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 |
See the License for the specific language governing permissions and |
| 17 |
limitations under the License. |
| 18 |
*/ |
| 19 |
const fetch_1 = require("./fetch"); |
| 20 |
const protobuf_specs_1 = require("@sigstore/protobuf-specs"); |
| 21 |
const v2_1 = require("@sigstore/protobuf-specs/rekor/v2"); |
| 22 |
/** |
| 23 |
* Rekor API client. |
| 24 |
*/ |
| 25 |
class RekorV2 { |
| 26 |
options; |
| 27 |
constructor(options) { |
| 28 |
this.options = options; |
| 29 |
} |
| 30 |
async createEntry(proposedEntry) { |
| 31 |
const { baseURL, timeout, retry } = this.options; |
| 32 |
const url = `${baseURL}/api/v2/log/entries`; |
| 33 |
const response = await (0, fetch_1.fetchWithRetry)(url, { |
| 34 |
headers: { |
| 35 |
'Content-Type': 'application/json', |
| 36 |
Accept: 'application/json', |
| 37 |
}, |
| 38 |
body: JSON.stringify(v2_1.CreateEntryRequest.toJSON(proposedEntry)), |
| 39 |
timeout, |
| 40 |
retry, |
| 41 |
}); |
| 42 |
return response.json().then((data) => protobuf_specs_1.TransparencyLogEntry.fromJSON(data)); |
| 43 |
} |
| 44 |
} |
| 45 |
exports.RekorV2 = RekorV2; |