Skip to content

Commit a0a58b7

Browse files
committed
deps: @sigstore/tuf@2.2.0
1 parent f3a7380 commit a0a58b7

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

node_modules/@sigstore/tuf/dist/client.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const tuf_js_1 = require("tuf-js");
2525
const target_1 = require("./target");
2626
class TUFClient {
2727
constructor(options) {
28-
initTufCache(options.cachePath, options.rootPath);
29-
const remote = initRemoteConfig(options.cachePath, options.mirrorURL);
28+
initTufCache(options);
29+
const remote = initRemoteConfig(options);
3030
this.updater = initClient(options.cachePath, remote, options);
3131
}
3232
async refresh() {
@@ -42,7 +42,7 @@ exports.TUFClient = TUFClient;
4242
// created. If the targets directory does not exist, it will be created.
4343
// If the root.json file does not exist, it will be copied from the
4444
// rootPath argument.
45-
function initTufCache(cachePath, tufRootPath) {
45+
function initTufCache({ cachePath, rootPath: tufRootPath, force, }) {
4646
const targetsPath = path_1.default.join(cachePath, 'targets');
4747
const cachedRootPath = path_1.default.join(cachePath, 'root.json');
4848
if (!fs_1.default.existsSync(cachePath)) {
@@ -51,22 +51,28 @@ function initTufCache(cachePath, tufRootPath) {
5151
if (!fs_1.default.existsSync(targetsPath)) {
5252
fs_1.default.mkdirSync(targetsPath);
5353
}
54-
if (!fs_1.default.existsSync(cachedRootPath)) {
54+
// If the root.json file does not exist (or we're forcing re-initialization),
55+
// copy it from the rootPath argument
56+
if (!fs_1.default.existsSync(cachedRootPath) || force) {
5557
fs_1.default.copyFileSync(tufRootPath, cachedRootPath);
5658
}
5759
return cachePath;
5860
}
5961
// Initializes the remote.json file, which contains the URL of the TUF
6062
// repository. If the file does not exist, it will be created. If the file
6163
// exists, it will be parsed and returned.
62-
function initRemoteConfig(rootDir, mirrorURL) {
64+
function initRemoteConfig({ cachePath, mirrorURL, force, }) {
6365
let remoteConfig;
64-
const remoteConfigPath = path_1.default.join(rootDir, 'remote.json');
65-
if (fs_1.default.existsSync(remoteConfigPath)) {
66+
const remoteConfigPath = path_1.default.join(cachePath, 'remote.json');
67+
// If the remote config file exists, read it and parse it (skip if force is
68+
// true)
69+
if (!force && fs_1.default.existsSync(remoteConfigPath)) {
6670
const data = fs_1.default.readFileSync(remoteConfigPath, 'utf-8');
6771
remoteConfig = JSON.parse(data);
6872
}
69-
if (!remoteConfig) {
73+
// If the remote config file does not exist (or we're forcing initialization),
74+
// create it
75+
if (!remoteConfig || force) {
7076
remoteConfig = { mirror: mirrorURL };
7177
fs_1.default.writeFileSync(remoteConfigPath, JSON.stringify(remoteConfig));
7278
}

node_modules/@sigstore/tuf/dist/index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.TUFError = exports.initTUF = exports.getTrustedRoot = void 0;
3+
exports.TUFError = exports.initTUF = exports.getTrustedRoot = exports.DEFAULT_MIRROR_URL = void 0;
44
/*
55
Copyright 2023 The Sigstore Authors.
66
@@ -19,8 +19,8 @@ limitations under the License.
1919
const protobuf_specs_1 = require("@sigstore/protobuf-specs");
2020
const appdata_1 = require("./appdata");
2121
const client_1 = require("./client");
22+
exports.DEFAULT_MIRROR_URL = 'https://tuf-repo-cdn.sigstore.dev';
2223
const DEFAULT_CACHE_DIR = 'sigstore-js';
23-
const DEFAULT_MIRROR_URL = 'https://tuf-repo-cdn.sigstore.dev';
2424
const DEFAULT_TUF_ROOT_PATH = '../store/public-good-instance-root.json';
2525
const DEFAULT_RETRY = { retries: 2 };
2626
const DEFAULT_TIMEOUT = 5000;
@@ -46,9 +46,10 @@ function createClient(options) {
4646
return new client_1.TUFClient({
4747
cachePath: options.cachePath || (0, appdata_1.appDataPath)(DEFAULT_CACHE_DIR),
4848
rootPath: options.rootPath || require.resolve(DEFAULT_TUF_ROOT_PATH),
49-
mirrorURL: options.mirrorURL || DEFAULT_MIRROR_URL,
49+
mirrorURL: options.mirrorURL || exports.DEFAULT_MIRROR_URL,
5050
retry: options.retry ?? DEFAULT_RETRY,
5151
timeout: options.timeout ?? DEFAULT_TIMEOUT,
52+
force: options.force ?? false,
5253
});
5354
}
5455
var error_1 = require("./error");

node_modules/@sigstore/tuf/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sigstore/tuf",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"description": "Client for the Sigstore TUF repository",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

package-lock.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"@npmcli/package-json": "^5.0.0",
9898
"@npmcli/promise-spawn": "^7.0.0",
9999
"@npmcli/run-script": "^7.0.2",
100-
"@sigstore/tuf": "^2.1.0",
100+
"@sigstore/tuf": "^2.2.0",
101101
"abbrev": "^2.0.0",
102102
"archy": "~1.0.0",
103103
"cacache": "^18.0.0",
@@ -3818,9 +3818,9 @@
38183818
}
38193819
},
38203820
"node_modules/@sigstore/tuf": {
3821-
"version": "2.1.0",
3822-
"resolved": "https://registry.npmjs.org/@sigstore/tuf/-/tuf-2.1.0.tgz",
3823-
"integrity": "sha512-BUoVCx+7Wj+8moEGvUU2MyBI+f93lmg1CLmoG6KrhQMeDyAG8HAZNk+YRCNuvwvSDCfPhwsj37Bg63/Q+bnGsw==",
3821+
"version": "2.2.0",
3822+
"resolved": "https://registry.npmjs.org/@sigstore/tuf/-/tuf-2.2.0.tgz",
3823+
"integrity": "sha512-KKATZ5orWfqd9ZG6MN8PtCIx4eevWSuGRKQvofnWXRpyMyUEpmrzg5M5BrCpjM+NfZ0RbNGOh5tCz/P2uoRqOA==",
38243824
"inBundle": true,
38253825
"dependencies": {
38263826
"@sigstore/protobuf-specs": "^0.2.1",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@npmcli/package-json": "^5.0.0",
6060
"@npmcli/promise-spawn": "^7.0.0",
6161
"@npmcli/run-script": "^7.0.2",
62-
"@sigstore/tuf": "^2.1.0",
62+
"@sigstore/tuf": "^2.2.0",
6363
"abbrev": "^2.0.0",
6464
"archy": "~1.0.0",
6565
"cacache": "^18.0.0",

0 commit comments

Comments
 (0)