{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "additionalProperties": false,
    "id": "https://github.com/ml-learning/digital-certificates-schema/certificate-schema-v1.json",
    "properties": {
        "assertion": {
            "additionalProperties": false,
            "properties": {
                "evidence": {
                    "description": "Text, uri, etc. that shows evidence of the recipient's learning that the certificate represents. Can be left as an empty string if not used.",
                    "type": "string"
                },
                "id": {
                    "_format": "uri",
                    "description": "URI that links to the certificate on the viewer. Default is https://[domain]/[uid]",
                    "type": "string"
                },
                "image:signature": {
                    "description": "A base-64 encoded png image of the issuer's signature.",
                    "pattern": "data:image/png;base64,",
                    "type": "string"
                },
                "issuedOn": {
                    "_format": "date-time",
                    "description": "Date the the certificate JSON was created.",
                    "type": "string"
                },
                "uid": {
                    "description": "Unique identifier. By default it is created using the string of a BSON ObjectId(), yielding an identifier 24 characters long.",
                    "type": "string"
                }
            },
            "required": [
                "evidence",
                "uid",
                "issuedOn",
                "id",
                "image:signature"
            ],
            "type": "object"
        },
        "certificate": {
            "additionalProperties": false,
            "properties": {
                "description": {
                    "description": "Description of what the certificate represents. Usually one - three sentences long.",
                    "type": "string"
                },
                "id": {
                    "_format": "uri",
                    "description": "URI link to a JSON that describes the type of certificate. Default format is https://[domain]/criteria/[year]/[month]/[certificate_title].json.",
                    "type": "string"
                },
                "image": {
                    "description": "A base-64 encoded png image of the certificate's image.",
                    "pattern": "data:image/png;base64,",
                    "type": "string"
                },
                "issuer": {
                    "additionalProperties": false,
                    "description": "Details about the issuer of the certificate.",
                    "properties": {
                        "email": {
                            "_format": "email",
                            "description": "Email address of the issuer.",
                            "type": "string"
                        },
                        "id": {
                            "_format": "uri",
                            "description": "Link to a JSON that details the issuer's issuing and recovation keys. Default is https://[domain]/issuer/[org_abbr]-issuer.json. Included for (near) backward compatibility with open badges specification 1.1",
                            "type": "string"
                        },
                        "image": {
                            "description": "A base-64 encoded png image of the issuer's logo.",
                            "pattern": "data:image/png;base64,",
                            "type": "string"
                        },
                        "name": {
                            "description": "Name of the issuer.",
                            "type": "string"
                        },
                        "url": {
                            "_format": "uri",
                            "description": "URI of the issuer's homepage",
                            "type": "string"
                        }
                    },
                    "required": [
                        "image",
                        "id",
                        "url",
                        "name",
                        "email"
                    ],
                    "type": "object"
                },
                "language": {
                    "description": "Represents the ieft language and ieft country codes. Format is [ieft_language]-[IEFT_COUNTRY]. Backcompatible change to make this field not required.",
                    "pattern": "[a-z]{2}-[A-Z]{2}",
                    "type": "string"
                },
                "subtitle": {
                    "additionalProperties": false,
                    "description": "Subtitle of the certificate.",
                    "properties": {
                        "content": {
                            "description": "Content of the subtitle.",
                            "type": "string"
                        },
                        "display": {
                            "description": "Flag that indicates whether to show or hide the subtitle in the viewer. Backcompatible change to allow 2 types that occurred in the wild before proper validation.",
                            "oneOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "boolean"
                                }
                            ]
                        }
                    },
                    "required": [
                        "content",
                        "display"
                    ],
                    "type": "object"
                },
                "title": {
                    "description": "Title of the certificate.",
                    "type": "string"
                }
            },
            "required": [
                "id",
                "image",
                "subtitle",
                "title",
                "issuer",
                "description"
            ],
            "type": "object"
        },
        "extension": {
            "description": "Extension object that includes extra fields not in the standard.",
            "properties": {
                "assertion": {
                    "properties": {},
                    "type": "object"
                },
                "certificate": {
                    "properties": {},
                    "type": "object"
                },
                "recipient": {
                    "properties": {},
                    "type": "object"
                },
                "verify": {
                    "properties": {},
                    "type": "object"
                }
            },
            "type": "object"
        },
        "recipient": {
            "additionalProperties": false,
            "properties": {
                "familyName": {
                    "description": "Family name of the recipient.",
                    "type": "string"
                },
                "givenName": {
                    "description": "Given name of the recipient",
                    "type": "string"
                },
                "hashed": {
                    "description": "Describes if the value in the identity field is hashed or not. Default is false, indicating that the identity is not hashed. Backcompatible change to allow 2 types that occurred in the wild before proper validation.",
                    "oneOf": [
                        {
                            "type": "string"
                        },
                        {
                            "type": "boolean"
                        }
                    ]
                },
                "identity": {
                    "description": "String that represents a recipient's identity. By default, it is an email address.",
                    "type": "string"
                },
                "pubkey": {
                    "description": "Bitcoin address (compressed public key, usually 24 characters) of the recipient.",
                    "type": "string"
                },
                "type": {
                    "description": "Type of value in the identity field. Default is 'email'.",
                    "type": "string"
                }
            },
            "required": [
                "familyName",
                "identity",
                "type",
                "hashed",
                "pubkey",
                "givenName"
            ],
            "type": "object"
        },
        "signature": {
            "description": "String of signature created when the Bitcoin private key signs the value in the attribute-signed field.",
            "type": "string"
        },
        "verify": {
            "additionalProperties": false,
            "properties": {
                "attribute-signed": {
                    "description": "Name of the attribute in the json that is signed by the issuer's private key. Default is 'uid', referring to the uid attribute.",
                    "type": "string"
                },
                "signer": {
                    "_format": "uri",
                    "description": "URI where issuer's public key is presented. Default is https://[domain]/keys/[org-abbr]-certs-public-key.asc. Compatible with open badges specification v1.1. Ideally, we would change this to point to a JSON instead, so we could retire keys (similar to the way we handle the issuer ID), but for now we're sticking with the OBS 1.1.",
                    "type": "string"
                },
                "type": {
                    "description": "Name of the signing method. Default is 'ECDSA(secp256k1)', referring to the Bitcoin method of signing messages with the issuer's private key.",
                    "type": "string"
                }
            },
            "required": [
                "attribute-signed",
                "type",
                "signer"
            ],
            "type": "object"
        }
    },
    "required": [
        "certificate",
        "assertion",
        "verify",
        "recipient"
    ],
    "title": "Certificate schema V1.1",
    "type": "object"
}