{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/google-digital-assetlinks/latest.json",
  "title": "Google Digital Assetlinks",
  "description": "Google Digital Assetlinks Schema",
  "x-lintel": {
    "source": "https://www.schemastore.org/assetlinks.json",
    "sourceSha256": "c26c89c96df9eb37e75455f2d1ae7c061609451b0c410df4abcba40fecabc78c",
    "fileMatch": [
      "assetlinks.json"
    ],
    "parsers": [
      "json"
    ]
  },
  "type": "array",
  "$defs": {
    "android_app": {
      "description": "The target asset belong to an android application",
      "type": "object",
      "properties": {
        "namespace": {
          "description": "Must be android_app for Android apps",
          "type": "string",
          "const": "android_app"
        },
        "package_name": {
          "description": "Android application's package name",
          "type": "string",
          "pattern": "^([A-Za-z]{1}[A-Za-z0-9_]*\\.)+[A-Za-z][A-Za-z0-9_]*$"
        },
        "sha256_cert_fingerprints": {
          "description": "SHA256s from keystore",
          "type": "array",
          "uniqueItems": true,
          "minItems": 1,
          "items": {
            "type": "string",
            "pattern": "^(?:[A-F0-9]{2}:){31}[A-F0-9]{2}$"
          }
        }
      },
      "required": [
        "namespace",
        "package_name",
        "sha256_cert_fingerprints"
      ],
      "additionalProperties": false
    },
    "web": {
      "description": "The target asset belong to a web application",
      "type": "object",
      "properties": {
        "namespace": {
          "description": "Must be web for websites",
          "type": "string",
          "const": "web"
        },
        "site": {
          "description": "Website's uri that following the format http[s]://<hostname>[:<port>]",
          "type": "string"
        }
      },
      "required": [
        "namespace",
        "site"
      ],
      "additionalProperties": false
    },
    "relation": {
      "description": "Describe the relation being declared about the target",
      "type": "array",
      "minItems": 1,
      "items": {
        "oneOf": [
          {
            "const": "delegate_permission/common.handle_all_urls",
            "description": "Grants the target permission to handle all URLs that the source can handle"
          },
          {
            "const": "delegate_permission/common.get_login_creds",
            "description": "Grants the target permission to retrieve sign-in credentials stored for the source"
          }
        ]
      }
    }
  },
  "items": {
    "title": "Statement list",
    "description": "Website or app statements as JSON objects",
    "type": "object",
    "properties": {
      "relation": {
        "$ref": "#/$defs/relation"
      },
      "target": {
        "description": "The target asset to whom this statement applies",
        "type": "object",
        "oneOf": [
          {
            "$ref": "#/$defs/android_app"
          },
          {
            "$ref": "#/$defs/web"
          }
        ]
      }
    },
    "additionalProperties": false
  }
}
