{
  "$schema":"https://json-schema.org/draft/2020-12/schema",
  "$id":"urn:si:feed-recovery:1.0",
  "title":"Offline namespace recovery authorization 1.0",
  "type":"object","additionalProperties":false,
  "required":["recovery_contract_version","authorization_id","mode","retired_namespace","revoked_checkpoint","issuer_checkpoint","new_namespace","first_new_sequence","old_root_digest","old_targets_digest","new_root_digest","new_targets_digest","new_manifest_digest","new_snapshot_digest","metadata_floors","authorization_metadata_version","new_metadata_versions","compromised_key_ids","reason_code","created_at","expires_at"],
  "properties":{
    "recovery_contract_version":{"const":"1.0"},"authorization_id":{"$ref":"#/$defs/id"},"mode":{"const":"namespace_recovery"},
    "retired_namespace":{"$ref":"#/$defs/namespace"},"revoked_checkpoint":{"$ref":"#/$defs/checkpoint"},"issuer_checkpoint":{"$ref":"#/$defs/issuer"},"new_namespace":{"$ref":"#/$defs/namespace"},"first_new_sequence":{"const":1},
    "old_root_digest":{"$ref":"#/$defs/digest"},"old_targets_digest":{"$ref":"#/$defs/digest"},"new_root_digest":{"$ref":"#/$defs/digest"},"new_targets_digest":{"$ref":"#/$defs/digest"},"new_manifest_digest":{"$ref":"#/$defs/digest"},"new_snapshot_digest":{"$ref":"#/$defs/digest"},
    "metadata_floors":{"$ref":"#/$defs/versions"},"authorization_metadata_version":{"$ref":"#/$defs/positive"},"new_metadata_versions":{"$ref":"#/$defs/versions"},
    "compromised_key_ids":{"type":"array","minItems":0,"maxItems":128,"uniqueItems":true,"items":{"type":"string","pattern":"^[0-9a-f]{64}$","minLength":64,"maxLength":64}},
    "reason_code":{"$ref":"#/$defs/id"},"created_at":{"$ref":"#/$defs/time"},"expires_at":{"$ref":"#/$defs/time"}
  },
  "$defs":{
    "id":{"type":"string","minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"},
    "digest":{"type":"string","minLength":71,"maxLength":71,"pattern":"^sha256:[0-9a-f]{64}$"},
    "nullableDigest":{"anyOf":[{"$ref":"#/$defs/digest"},{"type":"null"}]},
    "integer":{"type":"integer","minimum":0,"maximum":9007199254740991},"positive":{"type":"integer","minimum":1,"maximum":9007199254740991},
    "time":{"type":"string","minLength":20,"maxLength":20,"format":"date-time","pattern":"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"},
    "namespace":{"type":"object","additionalProperties":false,"required":["service_id","feed_id","channel","scope_digest","dataset_epoch"],"properties":{"service_id":{"$ref":"#/$defs/id"},"feed_id":{"$ref":"#/$defs/id"},"channel":{"const":"public-all"},"scope_digest":{"$ref":"#/$defs/digest"},"dataset_epoch":{"$ref":"#/$defs/id"}}},
    "versions":{"type":"object","additionalProperties":false,"required":["root","targets","feed","recovery","snapshot","timestamp"],"properties":{"root":{"$ref":"#/$defs/positive"},"targets":{"$ref":"#/$defs/positive"},"feed":{"$ref":"#/$defs/integer"},"recovery":{"$ref":"#/$defs/positive"},"snapshot":{"$ref":"#/$defs/integer"},"timestamp":{"$ref":"#/$defs/integer"}}},
    "checkpoint":{"oneOf":[
      {"type":"object","additionalProperties":false,"required":["kind","sequence","digest","genesis_registration_digest"],"properties":{"kind":{"const":"no_publication"},"sequence":{"const":0},"digest":{"type":"null"},"genesis_registration_digest":{"$ref":"#/$defs/digest"}}},
      {"type":"object","additionalProperties":false,"required":["kind","sequence","digest","genesis_registration_digest"],"properties":{"kind":{"const":"published"},"sequence":{"$ref":"#/$defs/positive"},"digest":{"$ref":"#/$defs/digest"},"genesis_registration_digest":{"type":"null"}}}
    ]},
    "pending":{"type":"object","additionalProperties":false,"required":["release_id","release_digest","plan_digest","sequence","manifest_digest","snapshot_digest","versions","artifacts_digest","publish_started"],"properties":{"release_id":{"$ref":"#/$defs/id"},"release_digest":{"$ref":"#/$defs/digest"},"plan_digest":{"$ref":"#/$defs/digest"},"sequence":{"$ref":"#/$defs/positive"},"manifest_digest":{"$ref":"#/$defs/digest"},"snapshot_digest":{"$ref":"#/$defs/digest"},"versions":{"$ref":"#/$defs/versions"},"artifacts_digest":{"$ref":"#/$defs/nullableDigest"},"publish_started":{"type":"boolean"}}},
    "issuer":{"type":"object","additionalProperties":false,"required":["checkpoint_id","state_digest","config_digest","registration_digest","published","last_issued_sequence","last_issued_versions","pending","last_disposition_digest"],"properties":{"checkpoint_id":{"$ref":"#/$defs/digest"},"state_digest":{"$ref":"#/$defs/digest"},"config_digest":{"$ref":"#/$defs/digest"},"registration_digest":{"$ref":"#/$defs/digest"},"published":{"$ref":"#/$defs/checkpoint"},"last_issued_sequence":{"$ref":"#/$defs/integer"},"last_issued_versions":{"$ref":"#/$defs/versions"},"pending":{"anyOf":[{"$ref":"#/$defs/pending"},{"type":"null"}]},"last_disposition_digest":{"$ref":"#/$defs/nullableDigest"}}}
  }
}
