Class: Sigstore::TUF::Timestamp

Inherits:
Object
  • Object
show all
Defined in:
lib/sigstore/tuf/timestamp.rb

Constant Summary collapse

TYPE =
"timestamp"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Timestamp

Returns a new instance of Timestamp.

Raises:



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sigstore/tuf/timestamp.rb', line 23

def initialize(data)
  type = data.fetch("_type")
  raise Error::InvalidData, "Expected type to be #{TYPE}, got #{type.inspect}" unless type == TYPE

  @version = data.fetch("version")
  @spec_version = data.fetch("spec_version")
  @expires = Time.iso8601 data.fetch("expires")
  meta_dict = data.fetch("meta")
  @snapshot_meta = Snapshot::Meta.from_hash(meta_dict["snapshot.json"])
  @unrecognized_fields = data.fetch("unrecognized_fields", {})
end

Instance Attribute Details

#expiresObject (readonly)

Returns the value of attribute expires.



21
22
23
# File 'lib/sigstore/tuf/timestamp.rb', line 21

def expires
  @expires
end

#snapshot_metaObject (readonly)

Returns the value of attribute snapshot_meta.



21
22
23
# File 'lib/sigstore/tuf/timestamp.rb', line 21

def snapshot_meta
  @snapshot_meta
end

#spec_versionObject (readonly)

Returns the value of attribute spec_version.



21
22
23
# File 'lib/sigstore/tuf/timestamp.rb', line 21

def spec_version
  @spec_version
end

#unrecognized_fieldsObject (readonly)

Returns the value of attribute unrecognized_fields.



21
22
23
# File 'lib/sigstore/tuf/timestamp.rb', line 21

def unrecognized_fields
  @unrecognized_fields
end

#versionObject (readonly)

Returns the value of attribute version.



21
22
23
# File 'lib/sigstore/tuf/timestamp.rb', line 21

def version
  @version
end

Instance Method Details

#expired?(reference_time) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/sigstore/tuf/timestamp.rb', line 35

def expired?(reference_time)
  @expires < reference_time
end