avancement planning

This commit is contained in:
2026-05-26 11:58:39 +02:00
parent 619a2b240a
commit 150b97cd2e
4892 changed files with 99214 additions and 429382 deletions
+1
View File
@@ -10,5 +10,6 @@ export type Config = {
fetchTimeout: number;
fetchRetries: number | undefined;
fetchRetry: MakeFetchHappenOptions['retry'];
userAgent?: string;
};
export declare const defaultConfig: Config;
+1
View File
@@ -12,4 +12,5 @@ exports.defaultConfig = {
fetchTimeout: 100000, // milliseconds
fetchRetries: undefined,
fetchRetry: 2,
userAgent: '',
};
+2
View File
@@ -11,10 +11,12 @@ export declare abstract class BaseFetcher implements Fetcher {
}
type Retry = MakeFetchHappenOptions['retry'];
interface FetcherOptions {
userAgent?: string;
timeout?: number;
retry?: Retry;
}
export declare class DefaultFetcher extends BaseFetcher {
private userAgent?;
private timeout?;
private retry?;
constructor(options?: FetcherOptions);
+6
View File
@@ -11,6 +11,7 @@ const util_1 = __importDefault(require("util"));
const error_1 = require("./error");
const tmpfile_1 = require("./utils/tmpfile");
const log = (0, debug_1.default)('tuf:fetch');
const USER_AGENT_HEADER = 'User-Agent';
class BaseFetcher {
// Download file from given URL. The file is downloaded to a temporary
// location and then passed to the given handler. The handler is responsible
@@ -54,16 +55,21 @@ class BaseFetcher {
}
exports.BaseFetcher = BaseFetcher;
class DefaultFetcher extends BaseFetcher {
userAgent;
timeout;
retry;
constructor(options = {}) {
super();
this.userAgent = options.userAgent;
this.timeout = options.timeout;
this.retry = options.retry;
}
async fetch(url) {
log('GET %s', url);
const response = await (0, make_fetch_happen_1.default)(url, {
headers: {
[USER_AGENT_HEADER]: this.userAgent || '',
},
timeout: this.timeout,
retry: this.retry,
});
+4 -2
View File
@@ -1,4 +1,6 @@
export { TargetFile } from '@tufjs/models';
export { BaseFetcher, Fetcher } from './fetcher';
export { Updater, UpdaterOptions } from './updater';
export { BaseFetcher } from './fetcher';
export { Updater } from './updater';
export type { Config } from './config';
export type { Fetcher } from './fetcher';
export type { UpdaterOptions } from './updater';
+5
View File
@@ -41,6 +41,7 @@ const models_1 = require("@tufjs/models");
const debug_1 = __importDefault(require("debug"));
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const package_json_1 = require("../package.json");
const config_1 = require("./config");
const error_1 = require("./error");
const fetcher_1 = require("./fetcher");
@@ -66,9 +67,13 @@ class Updater {
const data = this.loadLocalMetadata(models_1.MetadataKind.Root);
this.trustedSet = new store_1.TrustedMetadataStore(data);
this.config = { ...config_1.defaultConfig, ...config };
const userAgent = config?.userAgent
? `${config.userAgent} tuf-js/${package_json_1.version}`
: `tuf-js/${package_json_1.version}`;
this.fetcher =
fetcher ||
new fetcher_1.DefaultFetcher({
userAgent,
timeout: this.config.fetchTimeout,
retry: this.config.fetchRetries ?? this.config.fetchRetry,
});