{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "402Mob portable checkout share",
  "description": "v4 binds optional immutable purchase-decision metadata. v3 preserves private artifact commitments for offers without metadata; v1 remains compatible, v2 is recovery-only.",
  "oneOf": [
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema",
        "origin",
        "offer",
        "id"
      ],
      "properties": {
        "schema": {
          "const": "402mob.checkout-share.v1"
        },
        "origin": {
          "type": "string",
          "description": "Must equal the buyer runtime's explicitly configured service origin."
        },
        "id": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "SHA-256 of canonical JSON containing schema, origin, offer in that order. Offer fields use the order listed here. Validated by the library."
        },
        "offer": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "merchantId",
            "offerId",
            "version",
            "title",
            "description",
            "payee",
            "network",
            "asset",
            "amountAtomic",
            "amountUSDC",
            "contentType",
            "resultSizeKnownBeforePayment",
            "checkout"
          ],
          "properties": {
            "merchantId": {
              "$ref": "#/$defs/uuid"
            },
            "offerId": {
              "$ref": "#/$defs/uuid"
            },
            "version": {
              "type": "string",
              "maxLength": 128,
              "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
            },
            "title": {
              "type": "string",
              "maxLength": 512
            },
            "description": {
              "type": "string",
              "maxLength": 2048
            },
            "payee": {
              "type": "string",
              "pattern": "^0x[a-f0-9]{40}$"
            },
            "network": {
              "const": "eip155:8453"
            },
            "asset": {
              "const": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
            },
            "amountAtomic": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,11}$"
            },
            "amountUSDC": {
              "type": "string",
              "pattern": "^(0|[1-9][0-9]{0,5})\\.[0-9]{6}$",
              "not": {
                "const": "0.000000"
              }
            },
            "contentType": {
              "enum": [
                "application/json",
                "text/plain"
              ],
              "description": "Canonical media type; an optional UTF-8 charset parameter from the service is normalized. Other charsets are rejected."
            },
            "resultSizeKnownBeforePayment": {
              "const": false
            },
            "checkout": {
              "type": "string",
              "description": "Exact origin + /v1/merchants/{merchantId}/offers/{offerId}/checkout, checked by the library."
            }
          }
        }
      }
    },
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema",
        "origin",
        "offer",
        "id"
      ],
      "properties": {
        "schema": {
          "const": "402mob.checkout-share.v2"
        },
        "origin": {
          "type": "string",
          "description": "Must equal the buyer runtime's explicitly configured service origin."
        },
        "id": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "SHA-256 of canonical JSON containing schema, origin, offer in that order. Offer fields use the order listed here. Validated by the library."
        },
        "offer": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "merchantId",
            "offerId",
            "version",
            "title",
            "description",
            "payee",
            "network",
            "asset",
            "amountAtomic",
            "amountUSDC",
            "contentType",
            "resultSizeKnownBeforePayment",
            "checkout",
            "artifact"
          ],
          "properties": {
            "merchantId": {
              "$ref": "#/$defs/uuid"
            },
            "offerId": {
              "$ref": "#/$defs/uuid"
            },
            "version": {
              "type": "string",
              "maxLength": 128,
              "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
            },
            "title": {
              "type": "string",
              "maxLength": 512
            },
            "description": {
              "type": "string",
              "maxLength": 2048
            },
            "payee": {
              "type": "string",
              "pattern": "^0x[a-f0-9]{40}$"
            },
            "network": {
              "const": "eip155:8453"
            },
            "asset": {
              "const": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
            },
            "amountAtomic": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,11}$"
            },
            "amountUSDC": {
              "type": "string",
              "pattern": "^(0|[1-9][0-9]{0,5})\\.[0-9]{6}$",
              "not": {
                "const": "0.000000"
              }
            },
            "contentType": {
              "enum": [
                "application/json",
                "text/plain"
              ],
              "description": "Canonical media type; an optional UTF-8 charset parameter from the service is normalized. Other charsets are rejected."
            },
            "resultSizeKnownBeforePayment": {
              "const": true
            },
            "checkout": {
              "type": "string",
              "description": "Exact origin + /v1/merchants/{merchantId}/offers/{offerId}/checkout, checked by the library."
            },
            "artifact": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "sha256",
                "byteLength"
              ],
              "properties": {
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "byteLength": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 49152
                }
              }
            }
          }
        }
      }
    },
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema",
        "origin",
        "offer",
        "id"
      ],
      "properties": {
        "schema": {
          "const": "402mob.checkout-share.v3"
        },
        "origin": {
          "type": "string",
          "description": "Must equal the buyer runtime's explicitly configured service origin."
        },
        "id": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "SHA-256 of canonical JSON containing schema, origin, offer in that order. Offer fields use the order listed here. Validated by the library."
        },
        "offer": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "merchantId",
            "offerId",
            "version",
            "title",
            "description",
            "payee",
            "network",
            "asset",
            "amountAtomic",
            "amountUSDC",
            "contentType",
            "resultSizeKnownBeforePayment",
            "checkout",
            "artifact"
          ],
          "properties": {
            "merchantId": {
              "$ref": "#/$defs/uuid"
            },
            "offerId": {
              "$ref": "#/$defs/uuid"
            },
            "version": {
              "type": "string",
              "maxLength": 128,
              "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
            },
            "title": {
              "type": "string",
              "maxLength": 512
            },
            "description": {
              "type": "string",
              "maxLength": 2048
            },
            "payee": {
              "type": "string",
              "pattern": "^0x[a-f0-9]{40}$"
            },
            "network": {
              "const": "eip155:8453"
            },
            "asset": {
              "const": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
            },
            "amountAtomic": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,11}$"
            },
            "amountUSDC": {
              "type": "string",
              "pattern": "^(0|[1-9][0-9]{0,5})\\.[0-9]{6}$",
              "not": {
                "const": "0.000000"
              }
            },
            "contentType": {
              "enum": [
                "application/json",
                "text/plain"
              ],
              "description": "Canonical media type; an optional UTF-8 charset parameter from the service is normalized. Other charsets are rejected."
            },
            "resultSizeKnownBeforePayment": {
              "const": false
            },
            "checkout": {
              "type": "string",
              "description": "Exact origin + /v1/merchants/{merchantId}/offers/{offerId}/checkout, checked by the library."
            },
            "artifact": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "algorithm",
                "commitment",
                "sizeUpperBound"
              ],
              "properties": {
                "algorithm": {
                  "const": "sha256-private-proof-v1"
                },
                "commitment": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "sizeUpperBound": {
                  "type": "integer",
                  "minimum": 1024,
                  "maximum": 49152,
                  "multipleOf": 1024
                }
              }
            }
          }
        }
      }
    },
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema",
        "origin",
        "offer",
        "id"
      ],
      "properties": {
        "schema": {
          "const": "402mob.checkout-share.v4"
        },
        "origin": {
          "type": "string",
          "description": "Must equal the buyer runtime's explicitly configured service origin."
        },
        "id": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "SHA-256 of canonical JSON containing schema, origin, offer in that order. Offer fields use the order listed here. Validated by the library."
        },
        "offer": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "merchantId",
            "offerId",
            "version",
            "title",
            "description",
            "payee",
            "network",
            "asset",
            "amountAtomic",
            "amountUSDC",
            "contentType",
            "resultSizeKnownBeforePayment",
            "checkout",
            "artifact",
            "purchaseDecision",
            "offerTermsHash"
          ],
          "properties": {
            "merchantId": {
              "$ref": "#/$defs/uuid"
            },
            "offerId": {
              "$ref": "#/$defs/uuid"
            },
            "version": {
              "type": "string",
              "maxLength": 128,
              "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
            },
            "title": {
              "type": "string",
              "maxLength": 512
            },
            "description": {
              "type": "string",
              "maxLength": 2048
            },
            "payee": {
              "type": "string",
              "pattern": "^0x[a-f0-9]{40}$"
            },
            "network": {
              "const": "eip155:8453"
            },
            "asset": {
              "const": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
            },
            "amountAtomic": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,11}$"
            },
            "amountUSDC": {
              "type": "string",
              "pattern": "^(0|[1-9][0-9]{0,5})\\.[0-9]{6}$",
              "not": {
                "const": "0.000000"
              }
            },
            "contentType": {
              "enum": [
                "application/json",
                "text/plain"
              ],
              "description": "Canonical media type; an optional UTF-8 charset parameter from the service is normalized. Other charsets are rejected."
            },
            "resultSizeKnownBeforePayment": {
              "const": false
            },
            "checkout": {
              "type": "string",
              "description": "Exact origin + /v1/merchants/{merchantId}/offers/{offerId}/checkout, checked by the library."
            },
            "artifact": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "algorithm",
                "commitment",
                "sizeUpperBound"
              ],
              "properties": {
                "algorithm": {
                  "const": "sha256-private-proof-v1"
                },
                "commitment": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                },
                "sizeUpperBound": {
                  "type": "integer",
                  "minimum": 1024,
                  "maximum": 49152,
                  "multipleOf": 1024
                }
              }
            },
            "purchaseDecision": {
              "type": "object",
              "properties": {
                "protocol": {
                  "type": "string",
                  "const": "402mob.purchase-decision.v1"
                },
                "intendedUse": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 500
                },
                "resultSchema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "uri": {
                          "type": "string",
                          "maxLength": 2048,
                          "format": "uri",
                          "pattern": "^https://"
                        },
                        "version": {
                          "type": "string",
                          "pattern": "^(0|[1-9][0-9]{0,8})\\.(0|[1-9][0-9]{0,8})\\.(0|[1-9][0-9]{0,8})$"
                        },
                        "sha256": {
                          "type": "string",
                          "pattern": "^[a-f0-9]{64}$"
                        }
                      },
                      "required": [
                        "uri",
                        "version",
                        "sha256"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "coverage": {
                  "type": "object",
                  "properties": {
                    "asOf": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                    },
                    "from": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                    },
                    "through": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                    }
                  },
                  "required": [
                    "asOf"
                  ],
                  "additionalProperties": false,
                  "dependentRequired": {
                    "from": [
                      "through"
                    ],
                    "through": [
                      "from"
                    ]
                  }
                },
                "limitations": {
                  "minItems": 1,
                  "maxItems": 8,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 300
                  }
                },
                "reuseTerms": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 3000
                },
                "publicSample": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 1024
                }
              },
              "required": [
                "protocol",
                "intendedUse",
                "resultSchema",
                "coverage",
                "limitations",
                "reuseTerms"
              ],
              "additionalProperties": false,
              "description": "Optional immutable seller declarations; at most 8192 bytes of canonical UTF-8 JSON. The service does not fetch references, validate result conformance or certify claims."
            },
            "offerTermsHash": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          }
        }
      }
    }
  ],
  "$defs": {
    "uuid": {
      "type": "string",
      "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
    }
  }
}
