Debian Codegraph @

node_modules/@sigstore/sign/dist/external/tsa.js

raw
1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true });
3 exports.TimestampAuthority = void 0;
4 /*
5 Copyright 2023 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 class TimestampAuthority {
21 options;
22 constructor(options) {
23 this.options = options;
24 }
25 async createTimestamp(request) {
26 const { baseURL, timeout, retry } = this.options;
27 // Account for the fact that the TSA URL may already include the full
28 // path if the client was initalized from a `SigningConfig` service entry
29 // (which always uses the full URL).
30 const url = new URL(baseURL).pathname === '/'
31 ? `${baseURL}/api/v1/timestamp`
32 : baseURL;
33 const response = await (0, fetch_1.fetchWithRetry)(url, {
34 headers: {
35 'Content-Type': 'application/json',
36 },
37 body: JSON.stringify(request),
38 timeout,
39 retry,
40 });
41 return response.buffer();
42 }
43 }
44 exports.TimestampAuthority = TimestampAuthority;