avancement planning
This commit is contained in:
+4
@@ -28,6 +28,10 @@ function isMetadataKind(value) {
|
||||
* are common for all TUF metadata types (roles).
|
||||
*/
|
||||
class Signed {
|
||||
specVersion;
|
||||
expires;
|
||||
version;
|
||||
unrecognizedFields;
|
||||
constructor(options) {
|
||||
this.specVersion = options.specVersion || SPECIFICATION_VERSION.join('.');
|
||||
const specList = this.specVersion.split('.');
|
||||
|
||||
+4
@@ -16,6 +16,10 @@ const utils_1 = require("./utils");
|
||||
* describing targets with designated pathnames and/or further delegations.
|
||||
*/
|
||||
class Delegations {
|
||||
keys;
|
||||
roles;
|
||||
unrecognizedFields;
|
||||
succinctRoles;
|
||||
constructor(options) {
|
||||
this.keys = options.keys;
|
||||
this.unrecognizedFields = options.unrecognizedFields || {};
|
||||
|
||||
+8
@@ -12,6 +12,10 @@ const utils_1 = require("./utils");
|
||||
//
|
||||
// This class is used for Timestamp and Snapshot metadata.
|
||||
class MetaFile {
|
||||
version;
|
||||
length;
|
||||
hashes;
|
||||
unrecognizedFields;
|
||||
constructor(opts) {
|
||||
if (opts.version <= 0) {
|
||||
throw new error_1.ValueError('Metafile version must be at least 1');
|
||||
@@ -94,6 +98,10 @@ exports.MetaFile = MetaFile;
|
||||
//
|
||||
// This class is used for Target metadata.
|
||||
class TargetFile {
|
||||
length;
|
||||
path;
|
||||
hashes;
|
||||
unrecognizedFields;
|
||||
constructor(opts) {
|
||||
validateLength(opts.length);
|
||||
this.length = opts.length;
|
||||
|
||||
+5
@@ -10,6 +10,11 @@ const utils_1 = require("./utils");
|
||||
const key_1 = require("./utils/key");
|
||||
// A container class representing the public portion of a Key.
|
||||
class Key {
|
||||
keyID;
|
||||
keyType;
|
||||
scheme;
|
||||
keyVal;
|
||||
unrecognizedFields;
|
||||
constructor(options) {
|
||||
const { keyID, keyType, scheme, keyVal, unrecognizedFields } = options;
|
||||
this.keyID = keyID;
|
||||
|
||||
+6
-1
@@ -39,6 +39,9 @@ const utils_1 = require("./utils");
|
||||
* reasonable default values for new metadata.
|
||||
*/
|
||||
class Metadata {
|
||||
signed;
|
||||
signatures;
|
||||
unrecognizedFields;
|
||||
constructor(signed, signatures, unrecognizedFields) {
|
||||
this.signed = signed;
|
||||
this.signatures = signatures || {};
|
||||
@@ -103,7 +106,9 @@ class Metadata {
|
||||
if (!(other instanceof Metadata)) {
|
||||
return false;
|
||||
}
|
||||
return (this.signed.equals(other.signed) &&
|
||||
return (
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||
this.signed.equals(other.signed) &&
|
||||
util_1.default.isDeepStrictEqual(this.signatures, other.signatures) &&
|
||||
util_1.default.isDeepStrictEqual(this.unrecognizedFields, other.unrecognizedFields));
|
||||
}
|
||||
|
||||
+11
@@ -22,6 +22,9 @@ exports.TOP_LEVEL_ROLE_NAMES = [
|
||||
* metadata, and which keys are accepted.
|
||||
*/
|
||||
class Role {
|
||||
keyIDs;
|
||||
threshold;
|
||||
unrecognizedFields;
|
||||
constructor(options) {
|
||||
const { keyIDs, threshold, unrecognizedFields } = options;
|
||||
if (hasDuplicates(keyIDs)) {
|
||||
@@ -80,6 +83,10 @@ function hasDuplicates(array) {
|
||||
* set, at least one of them must be set.
|
||||
*/
|
||||
class DelegatedRole extends Role {
|
||||
name;
|
||||
terminating;
|
||||
paths;
|
||||
pathHashPrefixes;
|
||||
constructor(opts) {
|
||||
super(opts);
|
||||
const { name, terminating, paths, pathHashPrefixes } = opts;
|
||||
@@ -187,6 +194,10 @@ function isTargetInPathPattern(target, pattern) {
|
||||
* For details: https://github.com/theupdateframework/taps/blob/master/tap15.md
|
||||
*/
|
||||
class SuccinctRoles extends Role {
|
||||
bitLength;
|
||||
namePrefix;
|
||||
numberOfBins;
|
||||
suffixLen;
|
||||
constructor(opts) {
|
||||
super(opts);
|
||||
const { bitLength, namePrefix } = opts;
|
||||
|
||||
+4
-1
@@ -17,9 +17,12 @@ const utils_1 = require("./utils");
|
||||
* This role specifies trusted keys for all other top-level roles, which may further delegate trust.
|
||||
*/
|
||||
class Root extends base_1.Signed {
|
||||
type = base_1.MetadataKind.Root;
|
||||
keys;
|
||||
roles;
|
||||
consistentSnapshot;
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.type = base_1.MetadataKind.Root;
|
||||
this.keys = options.keys || {};
|
||||
this.consistentSnapshot = options.consistentSnapshot ?? true;
|
||||
if (!options.roles) {
|
||||
|
||||
+2
@@ -10,6 +10,8 @@ exports.Signature = void 0;
|
||||
* Provide a `fromJSON` method to create a Signature from a JSON object.
|
||||
*/
|
||||
class Signature {
|
||||
keyID;
|
||||
sig;
|
||||
constructor(options) {
|
||||
const { keyID, sig } = options;
|
||||
this.keyID = keyID;
|
||||
|
||||
+2
-1
@@ -16,9 +16,10 @@ const utils_1 = require("./utils");
|
||||
* and hence the latest versions of all targets (including any dependencies between them) on the repository.
|
||||
*/
|
||||
class Snapshot extends base_1.Signed {
|
||||
type = base_1.MetadataKind.Snapshot;
|
||||
meta;
|
||||
constructor(opts) {
|
||||
super(opts);
|
||||
this.type = base_1.MetadataKind.Snapshot;
|
||||
this.meta = opts.meta || { 'targets.json': new file_1.MetaFile({ version: 1 }) };
|
||||
}
|
||||
equals(other) {
|
||||
|
||||
+3
-1
@@ -14,9 +14,11 @@ const utils_1 = require("./utils");
|
||||
// Targets contains verifying information about target files and also delegates
|
||||
// responsible to other Targets roles.
|
||||
class Targets extends base_1.Signed {
|
||||
type = base_1.MetadataKind.Targets;
|
||||
targets;
|
||||
delegations;
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.type = base_1.MetadataKind.Targets;
|
||||
this.targets = options.targets || {};
|
||||
this.delegations = options.delegations;
|
||||
}
|
||||
|
||||
+2
-1
@@ -11,9 +11,10 @@ const utils_1 = require("./utils");
|
||||
* and hence the latest versions of all metadata and targets on the repository.
|
||||
*/
|
||||
class Timestamp extends base_1.Signed {
|
||||
type = base_1.MetadataKind.Timestamp;
|
||||
snapshotMeta;
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.type = base_1.MetadataKind.Timestamp;
|
||||
this.snapshotMeta = options.snapshotMeta || new file_1.MetaFile({ version: 1 });
|
||||
}
|
||||
equals(other) {
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
export * as guard from './guard';
|
||||
export { JSONObject, JSONValue } from './types';
|
||||
export * as crypto from './verify';
|
||||
export type { JSONObject, JSONValue } from './types';
|
||||
|
||||
+17
-7
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.crypto = exports.guard = void 0;
|
||||
exports.guard = __importStar(require("./guard"));
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tufjs/models",
|
||||
"version": "3.0.1",
|
||||
"version": "4.1.0",
|
||||
"description": "TUF metadata models",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
@@ -8,8 +8,8 @@
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc --build",
|
||||
"clean": "rm -rf dist && rm tsconfig.tsbuildinfo",
|
||||
"build": "tsc --build tsconfig.build.json",
|
||||
"clean": "rm -rf dist && rm tsconfig.build.tsbuildinfo",
|
||||
"test": "jest"
|
||||
},
|
||||
"repository": {
|
||||
@@ -29,9 +29,9 @@
|
||||
"homepage": "https://github.com/theupdateframework/tuf-js/tree/main/packages/models#readme",
|
||||
"dependencies": {
|
||||
"@tufjs/canonical-json": "2.0.0",
|
||||
"minimatch": "^9.0.5"
|
||||
"minimatch": "^10.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.17.0 || >=20.5.0"
|
||||
"node": "^20.17.0 || >=22.9.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user