base.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { Signature } from './signature';
  2. import { JSONObject, JSONValue } from './utils';
  3. export interface Signable {
  4. signatures: Record<string, Signature>;
  5. signed: Signed;
  6. }
  7. export interface SignedOptions {
  8. version: number;
  9. specVersion: string;
  10. expires: string;
  11. unrecognizedFields?: Record<string, JSONValue>;
  12. }
  13. export declare enum MetadataKind {
  14. Root = "root",
  15. Timestamp = "timestamp",
  16. Snapshot = "snapshot",
  17. Targets = "targets"
  18. }
  19. export declare function isMetadataKind(value: unknown): value is MetadataKind;
  20. /***
  21. * A base class for the signed part of TUF metadata.
  22. *
  23. * Objects with base class Signed are usually included in a ``Metadata`` object
  24. * on the signed attribute. This class provides attributes and methods that
  25. * are common for all TUF metadata types (roles).
  26. */
  27. export declare abstract class Signed {
  28. readonly specVersion: string;
  29. readonly expires: string;
  30. readonly version: number;
  31. readonly unrecognizedFields: Record<string, JSONValue>;
  32. constructor(options: SignedOptions);
  33. equals(other: Signed): boolean;
  34. isExpired(referenceTime?: Date): boolean;
  35. static commonFieldsFromJSON(data: JSONObject): SignedOptions;
  36. abstract toJSON(): JSONObject;
  37. }