Skip to content

Reference source · 0.1.0-dev.11

exchange.schema.json

schemas/exchange.schema.json · Download original file

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:oprp:experimental:0.1:exchange",
  "title": "OPRP experimental 0.1 envelope",
  "description": "Structural schema only. Cryptographic validation, decoded payloads, canonical base64url and compact JSON restrictions are enforced separately.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "protected",
    "credential",
    "kem",
    "nonce",
    "ciphertext",
    "tag",
    "signature"
  ],
  "properties": {
    "protected": {
      "$ref": "#/$defs/base64url",
      "maxLength": 4000
    },
    "credential": {
      "$ref": "#/$defs/credential"
    },
    "kem": {
      "$ref": "#/$defs/base64url",
      "minLength": 1451,
      "maxLength": 1451
    },
    "nonce": {
      "$ref": "#/$defs/base64url",
      "minLength": 16,
      "maxLength": 16
    },
    "ciphertext": {
      "$ref": "#/$defs/base64url",
      "maxLength": 1400000
    },
    "tag": {
      "$ref": "#/$defs/base64url",
      "minLength": 22,
      "maxLength": 22
    },
    "signature": {
      "$ref": "#/$defs/base64url",
      "minLength": 4412,
      "maxLength": 4412
    }
  },
  "$defs": {
    "base64url": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]*$"
    },
    "identifier": {
      "type": "string",
      "pattern": "^[A-Za-z0-9:@._/-]{1,200}$"
    },
    "credential": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "payload",
        "signature"
      ],
      "properties": {
        "payload": {
          "$ref": "#/$defs/base64url",
          "maxLength": 12000
        },
        "signature": {
          "$ref": "#/$defs/base64url",
          "minLength": 4412,
          "maxLength": 4412
        }
      }
    },
    "scope": {
      "enum": [
        "patient/Patient.r",
        "patient/Patient.u",
        "patient/Observation.rs?category=laboratory",
        "patient/Observation.c?category=laboratory",
        "oprp/record.export",
        "oprp/record.transfer",
        "patient/Condition.rs",
        "patient/Condition.c",
        "patient/Condition.u",
        "patient/Condition.d",
        "patient/AllergyIntolerance.rs",
        "patient/AllergyIntolerance.c",
        "patient/AllergyIntolerance.u",
        "patient/AllergyIntolerance.d",
        "patient/MedicationStatement.rs",
        "patient/MedicationStatement.c",
        "patient/MedicationStatement.u",
        "patient/MedicationStatement.d",
        "patient/Encounter.rs",
        "patient/Encounter.c",
        "patient/Encounter.u",
        "patient/Encounter.d",
        "patient/Procedure.rs",
        "patient/Procedure.c",
        "patient/Procedure.u",
        "patient/Procedure.d",
        "patient/Immunization.rs",
        "patient/Immunization.c",
        "patient/Immunization.u",
        "patient/Immunization.d"
      ]
    },
    "actorProof": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "credential",
        "payload",
        "signature"
      ],
      "properties": {
        "credential": {
          "$ref": "#/$defs/credential"
        },
        "payload": {
          "$ref": "#/$defs/base64url",
          "maxLength": 3000
        },
        "signature": {
          "$ref": "#/$defs/base64url",
          "minLength": 4412,
          "maxLength": 4412
        }
      }
    },
    "accessRequest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "request_id",
        "patient",
        "scopes",
        "requested_duration_seconds",
        "refresh_requested"
      ],
      "properties": {
        "request_id": {
          "$ref": "#/$defs/identifier"
        },
        "patient": {
          "$ref": "#/$defs/identifier"
        },
        "scopes": {
          "type": "array",
          "minItems": 1,
          "maxItems": 30,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/scope"
          }
        },
        "requested_duration_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 31536000
        },
        "refresh_requested": {
          "type": "boolean"
        },
        "actor_proof": {
          "$ref": "#/$defs/actorProof"
        }
      }
    }
  }
}