{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://extol.work/attestation/org/v1/signing-delegation/schema.json",
  "title": "Signing delegation",
  "description": "An organization authorizes an individual operator to sign attestations of a specified class on the organization's behalf, for a specified time range. See https://extol.work/attestation/org/v1/signing-delegation for the human-readable specification.",
  "type": "object",
  "required": ["organization", "operator", "org_root", "authorized_activity_types", "effective_from", "effective_until", "authorization_source", "terms_uri"],
  "properties": {
    "organization": {
      "type": "object",
      "required": ["legal_name", "ein", "jurisdiction", "entity_type", "registration_reference"],
      "properties": {
        "legal_name": { "type": "string", "description": "Organization's legal name" },
        "ein": { "type": "string", "pattern": "^[0-9]{2}-[0-9]{7}$", "description": "US Employer Identification Number, format XX-XXXXXXX" },
        "jurisdiction": { "type": "string", "description": "ISO 3166 country code with optional subdivision (e.g., US-CA)" },
        "entity_type": { "type": "string", "description": "e.g., 501c3, 501c4, LLC, government_agency" },
        "registration_reference": {
          "type": "object",
          "required": ["type", "verified_via"],
          "properties": {
            "type": { "type": "string", "description": "e.g., irs_eo_select_check" },
            "verified_at": { "type": "string", "format": "date-time" },
            "verified_via": { "type": "string", "description": "SHA-256 hex of the anchoring Extol onboarding-verification attestation's canonical bytes, prefixed with extol_onboarding_verification_attestation:" }
          }
        }
      }
    },
    "operator": {
      "type": "object",
      "required": ["pubkey", "legal_name", "title", "role_scope"],
      "properties": {
        "pubkey": { "type": "string", "contentEncoding": "base64", "description": "32-byte Ed25519 public key, base64-encoded" },
        "legal_name": { "type": "string", "description": "Operator's full legal name (Neptune §3.1 REQUIRED)" },
        "title": { "type": "string", "description": "Operator's title within the organization (Neptune §3.1 REQUIRED)" },
        "role_scope": { "type": "string", "description": "Human-readable scope description (e.g., authorized_signatory_all_service_hour_verifications)" }
      }
    },
    "org_root": {
      "type": "object",
      "required": ["pubkey", "custody_tier"],
      "properties": {
        "pubkey": { "type": "string", "contentEncoding": "base64", "description": "32-byte Ed25519 public key of the org root identity, base64-encoded" },
        "custody_tier": { "type": "string", "enum": ["B", "C", "D"], "description": "EXT-245 custody tier: B=single officer, C=multi-officer any-of-N, D=K-of-N Squads multisig" },
        "signing_officer_pubkey": { "type": "string", "contentEncoding": "base64", "description": "Under tier C: the specific officer's pubkey who executed this delegation" },
        "signing_officer_legal_name": { "type": "string", "description": "Under tier C: the specific officer's legal name" },
        "signing_officer_title": { "type": "string", "description": "Under tier C: the specific officer's title" }
      }
    },
    "authorized_activity_types": {
      "type": "array",
      "items": { "type": "string", "format": "uri-reference" },
      "minItems": 1,
      "description": "Machine-enforceable list of activity_type URIs the operator may sign under this delegation"
    },
    "effective_from": { "type": "string", "format": "date-time" },
    "effective_until": { "type": "string", "format": "date-time" },
    "authorization_source": {
      "type": "object",
      "required": ["type", "reference"],
      "properties": {
        "type": { "type": "string", "description": "e.g., board_resolution, bylaws_section" },
        "reference": { "type": "string", "description": "Paper-world identifier" },
        "external_url": { "type": "string", "format": "uri" },
        "revocation_conditions_reference": { "type": "string", "format": "uri", "description": "Pointer to bylaws section governing when authority may be revoked (Neptune §5.3)" }
      }
    },
    "terms_uri": {
      "type": "string",
      "format": "uri",
      "description": "Pointer to the versioned Pattern 3 attestation terms in effect at issuance (Iapetus IETF versioned-terms pattern)"
    }
  }
}
