<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude"
     ipr="trust200902"
     category="std"
     docName="draft-ietf-jmap-sieve-12"
     obsoletes=""
     updates=""
     submissionType="IETF"
     consensus="true"
     xml:lang="en"
     tocInclude="true"
     symRefs="true"
     sortRefs="true"
     version="3">

  <!-- xml2rfc v2v3 conversion 3.10.0 -->
  <front>
    <title abbrev="JMAP Sieve">JMAP for Sieve Scripts</title>
    <seriesInfo name="Internet-Draft" value="draft-ietf-jmap-sieve-12"/>
    <author initials="K." surname="Murchison" fullname="Kenneth Murchison">
      <organization abbrev="Fastmail">Fastmail US LLC</organization>
      <address>
        <postal>
          <street>1429 Walnut Street - Suite 1201</street>
          <city>Philadelphia</city>
          <region>PA</region>
          <code>19102</code>
          <country>USA</country>
        </postal>
        <email>murch@fastmailteam.com</email>
      </address>
    </author>
    <date/>
    <area>ART</area>
    <!-- <workgroup>Independent Submission</workgroup>-->
    <workgroup>JMAP</workgroup>
    <keyword>JMAP</keyword>
    <keyword>JSON</keyword>
    <keyword>Sieve</keyword>
    <abstract>
      <t>This document specifies a data model for managing Sieve
      scripts on a server using the JSON Meta Application Protocol (JMAP).
      </t>
    </abstract>
    <!--
    <note title="Open Issues">
      <t>
        <list style="symbols">
        </list>
      </t>
    </note>
-->
  </front>

  <middle>
    <section numbered="true" toc="default">
      <name>Introduction</name>
      <t><xref target="RFC8620" format="default">JMAP</xref>
      (JSON Meta Application Protocol) is a generic protocol for
      synchronizing data, such as mail, calendars or contacts, between
      a client and a server.

      It is optimized for mobile and web environments, and aims to
      provide a consistent interface to different data types.
      </t>
      <t>This specification defines a data model for managing
      <xref target="RFC5228" format="default">Sieve</xref> scripts on
      a server using JMAP.

      The data model is designed to allow a server to provide
      consistent access to the same scripts via
      <xref target="RFC5804" format="default">ManageSieve</xref> as
      well as JMAP, however the functionality offered over the two
      protocols may differ.
      </t>

      <section numbered="true" toc="default">
        <name>Notational Conventions</name>
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
        "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT
        RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
        interpreted as described in BCP 14
        <xref target="RFC2119" format="default"/>
        <xref target="RFC8174" format="default"/> when, and only when,
        they appear in all capitals, as shown here.
        </t>
        <t>Type signatures, examples, and property descriptions in
        this document follow the conventions established in Section
        1.1 of <xref target="RFC8620" format="default"/>.
        Data types defined in the
        core specification are also used in this document. 
        </t>
        <t>Servers MUST support all properties specified for the new
        data type defined in this document.</t>
        <t>For compatibility with publishing requirements, line breaks
        have been inserted inside long JSON strings, with the
        following continuation lines indented.  To form the valid JSON
        example, any line breaks inside a string must be replaced with
        a space and any other white space after the line break
        removed.</t>
      </section>

      <section numbered="true" toc="default">
        <name>Terminology</name>
        <t>The same terminology is used in this document as in the
        core JMAP specification,
        see <xref target="RFC8620" format="default"/>, Section 1.6.
        </t>
        <t>The term SieveScript (with this specific capitalization) is
        used to refer to the data type defined in this document and
        instances of those data types. 
        </t>
      </section>
      <section numbered="true" toc="default">
        <name>Addition to the Capabilities Object</name>
        <t>The capabilities object is returned as part of the JMAP
        Session object; see <xref target="RFC8620" format="default"/>,
        Section 2.
        This document defines one additional capability URI.
        </t>

        <section anchor="capa" numbered="true" toc="default">
          <name>urn:ietf:params:jmap:sieve</name>
          <t>This represents support for the SieveScript data type and
          associated API methods.
          The value of this property in the JMAP Session
          capabilities property is an empty object.
          </t>
          <t>The value of this property in an account's
          accountCapabilities property is an object that MUST contain
          the following information on server capabilities:

          </t>
          <ul spacing="normal">
            <li>
              <t><strong>maxSizeScriptName</strong>:
                <tt>UnsignedInt</tt>
              </t>
              <t>
                The maximum length, in (UTF-8) octets, allowed for the
                name of a SieveScript.
                For compatibility with ManageSieve, this MUST be at
                least 512 (up to 128 Unicode characters).
              </t>
              <t/>
            </li>
            <li>
              <t><strong>maxSizeScript</strong>:
                <tt>UnsignedInt|null</tt>
              </t>
              <t>
                The maximum size (in octets) of a Sieve script the
                server is willing to store for the user,
                or <tt>null</tt> for no limit.
              </t>
              <t/>
            </li>
            <li>
              <t><strong>maxNumberScripts</strong>:
                <tt>UnsignedInt|null</tt>
              </t>
              <t>
                The maximum number of Sieve scripts the server is
                willing to store for the user,
                or <tt>null</tt> for no limit.
              </t>
              <t/>
            </li>
            <li>
              <t><strong>maxNumberRedirects</strong>:
                <tt>UnsignedInt|null</tt>
              </t>
              <t>
                The maximum number of Sieve "redirect" actions a
                script can perform during a single evaluation
                or <tt>null</tt> for no limit.
                Note that this is different from the total number of
                "redirect" actions a script can contain.
              </t>
              <t/>
            </li>
            <li>
              <t><strong>sieveExtensions</strong>:
                <tt>String[]</tt>
              </t>
              <t>
                A list of case-sensitive Sieve capability strings (as
                listed in Sieve "require" action; see
                <xref target="RFC5228" format="default"/>, Section 3.2)
                indicating the extensions supported by the Sieve engine.
              </t>
              <t/>
            </li>
            <li>
              <t><strong>notificationMethods</strong>:
                <tt>String[]|null</tt>
              </t>
              <t>
                A list of
                <xref target="RFC3986" format="default">URI schema parts</xref>
                for notification methods supported by the Sieve
                <xref target="RFC5435" format="default">"enotify"</xref>
                extension, or <tt>null</tt> if the extension
                is not supported by the Sieve engine.
              </t>
              <t/>
            </li>
            <li>
              <t><strong>externalLists</strong>:
                <tt>String[]|null</tt>
              </t>
              <t>
                A list of
                <xref target="RFC3986" format="default">URI schema parts</xref>
                for externally stored list types supported by the
                Sieve <xref target="RFC6134" format="default">"extlists"</xref>
                extension, or <tt>null</tt> if the extension
                is not supported by the Sieve engine.
              </t>
            </li>
          </ul>
        </section>
      </section>
    </section>
    <section anchor="object" numbered="true" toc="default">
      <name>Sieve Scripts</name>
      <t>A <strong>SieveScript</strong> object represents
      a single <xref target="RFC5228" format="default">Sieve</xref> script for
      filtering email messages at time of final delivery.
      </t>
      <t>A <strong>SieveScript</strong> object has the
      following properties:

      </t>
      <ul spacing="normal">
        <li>
          <t><strong>id</strong>:
            <tt>Id</tt>
            (immutable; server-set)
          </t>
          <t>
            The id of the script.
          </t>
          <t/>
        </li>
        <li>
          <t><strong>name</strong>:
            <tt>String|null</tt>
            (optional; default is server-dependent)
          </t>
          <t>
            User-visible name for the SieveScript.
            If non-null, this MUST be a
            <xref target="RFC5198" format="default">Net-Unicode</xref>
            string of at least 1 character in length, subject to the
            maximum size given in the capability object.

            For compatibility with ManageSieve, servers MUST reject
            names that contain control characters.  Servers MAY reject
            names that violate server policy (e.g., names containing
            slash (/)).

            The name MUST be unique among all SieveScripts within an
            account.
          </t>
          <t/>
        </li>
        <li>
          <t><strong>blobId</strong>:
            <tt>Id</tt>
          </t>
          <t>
            The id of the blob containing the raw octets of the script.
          </t>
          <t>

            The script MUST be
            <xref target="RFC3629" format="default">UTF-8</xref>
            content of at least 1 character in length, subject to the
            syntax of <xref target="RFC5228" format="default">Sieve</xref>.
            The script MUST NOT contain any "require" statement(s)
            mentioning Sieve capabiltity strings not present in the
            <xref target="capa" format="default">capability</xref> object.
            Note that if the Sieve
            <xref target="RFC5463" format="default">"ihave"</xref>
            capability string is present in the capability object,
            the script MAY mention unrecognized/unsupported extensions
            in the "ihave" test.
          </t>
          <t/>
        </li>
        <li>
          <t><strong>isActive</strong>:
            <tt>Boolean</tt>
            (server-set; default: false)
          </t>
          <t>
            A user may have multiple SieveScripts on the server, yet
            only one script may be used for filtering of incoming
            messages.  This is the active script.  Users may have zero
            or one active script.
            The <xref target="set" format="default">SieveScript/set</xref>
            method is used for changing the active script or disabling Sieve
            processing.
          </t>
          <t/>
        </li>
      </ul>
      <section anchor="get" numbered="true" toc="default">
        <name>SieveScript/get</name>
        <t>This is a standard "/get" method as described in
        <xref target="RFC8620" format="default"/>, Section 5.1.
        The <em>ids</em> argument may be
        <tt>null</tt> to fetch all at once. 
        </t>
        <t>This method provides similar functionality to the GETSCRIPT
        and LISTSCRIPTS commands in <xref target="RFC5804" format="default"/>.
        </t>

        <section numbered="true" toc="default">
          <name>Examples</name>
          <t keepWithNext="true">
                Request (and response) to list all scripts:
          </t>
          <artwork name="" type="" align="left" alt=""><![CDATA[
{
  "using": [ "urn:ietf:params:jmap:core",
             "urn:ietf:params:jmap:sieve" ],
  "methodCalls": [
    ["SieveScript/get", {
      "accountId": "ken"
    }, "0"]
  ]
}

{
  "methodResponses": [
    [
      "SieveScript/get",
      {
        "state": "1634915373.240633104-120",
        "list": [
          {
            "id": "2d647053-dded-418d-917a-63eda3ac8f7b",
            "name": "test1",
            "isActive": true,
            "blobId": "S123"
          }
        ],
        "notFound": [],
        "accountId": "ken"
      },
      "0"
    ]
  ]
}
]]></artwork>

          <t keepWithNext="true">
                Request (and response) to download the script
                (assuming that the JMAP Download URL has been
                advertised in the JMAP Session object as having a path
                of
               "/jmap/download/{accountId}/{blobId}/{name}?accept={type}").
                Note that the request-line has been wrapped for
                presentation purposes only.
          </t>
          <artwork name="" type="" align="left" alt=""><![CDATA[
GET
 /jmap/download/ken/S123/test1.siv?accept=application/sieve
 HTTP/1.1
Host: jmap.example.com
Authorization: Basic a2VuOnBhc3N3b3Jk

HTTP/1.1 200 OK
Date: Fri, 22 Oct 2021 15:27:38 GMT
Content-Type: application/sieve; charset=utf-8
Content-Disposition: attachment; filename="test1.siv"
Content-Length: 49

require ["fileinto"];
fileinto "INBOX.target";
]]></artwork>

          <t keepWithNext="true">
                Request (and response) to fetch the content of a single script:
          </t>
          <artwork name="" type="" align="left" alt=""><![CDATA[
{
  "using": [ "urn:ietf:params:jmap:core",
             "urn:ietf:params:jmap:blob",
             "urn:ietf:params:jmap:sieve" ],
  "methodCalls": [
    ["SieveScript/get", {
      "accountId": "ken",
      "ids": [ "2d647053-dded-418d-917a-63eda3ac8f7b" ]
    }, "0"],
    ["Blob/get", {
      "accountId": "ken",
      "#ids": {
        "resultOf": "0",
        "name": "SieveScript/get",
        "path": "/list/*/blobId"
      }
    }, "1"]
  ]
}

{
  "methodResponses": [
    [
      "SieveScript/get",
      {
        "state": "1634915373.240633104-120",
        "list": [
          {
            "id": "2d647053-dded-418d-917a-63eda3ac8f7b",
            "name": "test1",
            "isActive": true,
            "blobId": "S123"
          }
        ],
        "notFound": [],
        "accountId": "ken"
      },
      "0"
    ],
    [
      "Blob/get",
      {
        "list": [
          {
            "id": "S123",
           "data:asText":
 "require [\"fileinto\"];\\r\\nfileinto \"INBOX.target\";\\r\\n",
            "size": 49
          }
        ],
        "notFound": [],
        "accountId": "ken"
      },
      "1"
    ]
  ]
}
]]></artwork>
        </section>
      </section>
      <!-- /get -->

      <section anchor="set" numbered="true" toc="default">
        <name>SieveScript/set</name>
        <t>This is a standard "/set" method as described in
        <xref target="RFC8620" format="default"/>,
        Section 5.3 but with the following
        additional request argument, which may be omitted:

        </t>
        <ul spacing="normal">
          <li>
            <t><strong>onSuccessActivateScript</strong>:
            <tt>Id|null</tt>
            (optional)
            </t>
            <t>
            If <tt>null</tt>, the currently active
            SieveScript (if any) will be deactivated if and only if
            all of the creations, modifications, and destructions (if
            any) succeed.
            Otherwise, the id of the SieveScript to activate if and
            only if all of the creations, modifications, and
            destructions (if any) succeed.
            (For references to SieveScript creations, this is
            equivalent to a creation-reference, so the id will be the
            creation id prefixed with a "#".)
            If this argument is not present in the request, the
            currently active SieveScript (if any) will remain as such.
            </t>
            <t>

            The id of any activated SieveScript MUST be reported in
            either the "created" or "updated" argument in the response
            as appropriate.
            The id of any deactivated SieveScript MUST be reported in
            the "updated" argument in the response.
            </t>
            <t/>
          </li>
        </ul>
        <t>This method provides similar functionality to the
        PUTSCRIPT, DELETESCRIPT, RENAMESCRIPT, and SETACTIVE commands
        in <xref target="RFC5804" format="default"/>.
        </t>
        <t>Script content must first be uploaded as a blob using
        either the standard upload mechanism
        (see <xref target="RFC8620" format="default"/>
        Section 6.1) or the JMAP Blob management extension
        (see <xref target="I-D.ietf-jmap-blob" format="default"/> Section 3.1).
        </t>
        <t>If the SieveScript can not be created or updated because it
        would result in two SieveScripts with the same name, the
        server MUST reject the request with an "alreadyExists"
        SetError.
        An "existingId" property of type "Id" MUST be included on the
        SetError object with the id of the existing SieveScript.</t>
        <t>If the SieveScript can not be created or updated because
        its size exceeds the "maxSizeScript" limit, the server MUST
        reject the request with a "tooLarge" SetError.</t>
        <t>If the Sieve Script can not be created because it would
        exceed the "maxNumberScripts" limit, the server MUST
        reject the request with an "overQuota" SetError.</t>
        <t>The active SieveScript MUST NOT be destroyed
        unless it is first deactivated in a separate SieveScript/set
        method call.</t>
        <t>The following extra SetError types are defined:
        </t>
        <t>For "create" and "update":
        </t>
        <ul spacing="normal">
          <li>
            <t><strong>invalidScript</strong>:
            </t>
            <t>
              The SieveScript content violates the
              <xref target="RFC5228" format="default">Sieve</xref>
              grammar and/or one
              or more extensions mentioned in the script's "require"
              statement(s) are not supported by the Sieve interpreter.
              The <em>description</em> property on
              the SetError object SHOULD contain a specific error
              message giving at least the line number of the first error.
            </t>
            <t/>
          </li>
        </ul>
        <t>For "destroy":
        </t>
        <ul spacing="normal">
          <li>
            <t><strong>scriptIsActive</strong>:
            </t>
            <t>
              The SieveScript is active.
            </t>
            <t/>
          </li>
        </ul>
        <section numbered="true" toc="default">
          <name>Examples</name>
          <t keepWithNext="true">
                Request (and response) to upload a script
                requiring the Imap4Flags
                <xref target="RFC5232" format="default"/>
                Extension (assuming that the JMAP Upload URL has been
                advertised in the JMAP Session object as having a path of
                "/jmap/upload/{accountId}/"):
          </t>
          <artwork name="" type="" align="left" alt=""><![CDATA[
POST /jmap/upload/ken/ HTTP/1.1
Host: jmap.example.com
Authorization: Basic a2VuOnBhc3N3b3Jk
Content-Type: application/sieve
Content-Length: 98

require "imapflags";

if address :is ["To", "Cc"] "jmap@ietf.org" {
  setflag "\\Flagged";
}


HTTP/1.1 201 Created
Date: Thu, 10 Dec 2020 17:14:31 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 171

{
  "accountId": "ken",
  "blobId": "Gabcc83e44a6e19991c4568d0b94e1767c83dd123",
  "type": "application/sieve"
  "size": 98
}
]]></artwork>
          <t keepWithNext="true">
                Request (and response) to create and activate a script
                using the uploaded blob:
          </t>
          <artwork name="" type="" align="left" alt=""><![CDATA[
{
  "using": [ "urn:ietf:params:jmap:core",
             "urn:ietf:params:jmap:sieve" ],
  "methodCalls": [
    ["SieveScript/set", {
      "accountId": "ken",
      "create": {
        "A": {
          "name": null,
          "blobId": "Gabcc83e44a6e19991c4568d0b94e1767c83dd123"
        }
      },
      "onSuccessActivateScript": "#A"
    }, "0"]
  ]
}

{
  "methodResponses": [
    [
      "SieveScript/set",
      {
        "oldState": "1603741717.50737918-4096",
        "newState": "1603741751.227268529-4096",
        "created": {
          "A": {
            "id": "dd1b164f-8cdc-448c-9f54",
            "name": "ken-20201210T171432-0",
            "blobId": "Sdd1b164f-8cdc-448c-9f54",
            "isActive": true
          }
        },
        "updated": null,
        "destroyed": null,
        "notCreated": null,
        "notUpdated": null,
        "notDestroyed": null,
        "accountId": "ken"
      },
      "0"
    ]
  ]
}
]]></artwork>
          <t keepWithNext="true">
                Request (and response) to update script content using
                the <xref target="I-D.ietf-jmap-blob" format="default">
                JMAP Blob management extension</xref>:
          </t>
          <artwork name="" type="" align="left" alt=""><![CDATA[
{
  "using": [ "urn:ietf:params:jmap:core",
             "urn:ietf:params:jmap:blob",
             "urn:ietf:params:jmap:sieve" ],
  "methodCalls": [
    ["Blob/upload", {
      "accountId": "ken",
      "create": {
        "B": {
          "data": [ {
            "data:asText":
              "redirect \"ken@example.com\"\r\n;"
           } ],
          "type": "application/sieve"
        }
      }
    }, "1"],
    ["SieveScript/set", {
      "accountId": "ken",
      "update": { "dd1b164f-8cdc-448c-9f54": {
        "blobId": "#B"
        }
      }
    }, "2"]
  ]
}

{
  "methodResponses": [
    [
      "Blob/upload",
      {
        "oldState": null,
        "newState": "1603741700.309607123-0128",
        "created": {
          "B": {
            "id": "G969c83e44a6e10871c4568d0b94e1767c83ddeae",
            "blobId": "G969c83e44a6e10871c4568d0b94e1767c83ddeae",
            "type": "application/sieve",
            "size": 29
          }
        },
        "notCreated": null,
        "accountId": "ken"
      },
      "1"
    ],
    [
      "SieveScript/set",
      {
        "oldState": "1603741751.227268529-4096",
        "newState": "1603742603.309607868-4096",
        "created": null,
        "updated": {
          "dd1b164f-8cdc-448c-9f54": null
        },
        "destroyed": null,
        "notCreated": null,
        "notUpdated": null,
        "notDestroyed": null,
        "accountId": "ken"
      },
      "2"
    ]
  ]
}
]]></artwork>
          <t keepWithNext="true">
                Request (and response) to update script name and deactivate:
          </t>
          <artwork name="" type="" align="left" alt=""><![CDATA[
{
  "using": [ "urn:ietf:params:jmap:core",
             "urn:ietf:params:jmap:sieve" ],
  "methodCalls": [
    ["SieveScript/set", {
      "accountId": "ken",
      "update": { "dd1b164f-8cdc-448c-9f54": {
        "name": "myscript"
        }
      },
      "onSuccessActivateScript": null
    }, "3"]
  ]
}

{
  "methodResponses": [
    [
      "SieveScript/set",
      {
        "oldState": "1603742603.309607868-4096",
        "newState": "1603742967.852315428-4096",
        "created": null,
        "updated": {
          "dd1b164f-8cdc-448c-9f54": {
            "isActive": false
          }
        },
        "destroyed": null,
        "notCreated": null,
        "notUpdated": null,
        "notDestroyed": null,
        "accountId": "ken"
      },
      "3"
    ]
  ]
}
]]></artwork>
          <t keepWithNext="true">
                Request (and response) to activate a script:
          </t>
          <artwork name="" type="" align="left" alt=""><![CDATA[
{
  "using": [ "urn:ietf:params:jmap:core",
             "urn:ietf:params:jmap:sieve" ],
  "methodCalls": [
    ["SieveScript/set", {
      "accountId": "ken",
      "onSuccessActivateScript": "dd1b164f-8cdc-448c-9f54"
    }, "4"]
  ]
}

{
  "methodResponses": [
    [
      "SieveScript/set",
      {
        "oldState": "1603742967.852315428-4096",
        "newState": "1603744460.316617118-4096",
        "created": null,
        "updated": {
          "dd1b164f-8cdc-448c-9f54": {
            "isActive": true
          }
        },
        "destroyed": null,
        "notCreated": null,
        "notUpdated": null,
        "notDestroyed": null,
        "accountId": "ken"
      },
      "4"
    ]
  ]
}
]]></artwork>
          <t keepWithNext="true">
                Requests (and responses) to deactivate and destroy the
                active script:
          </t>
          <artwork name="" type="" align="left" alt=""><![CDATA[
{
  "using": [ "urn:ietf:params:jmap:core",
             "urn:ietf:params:jmap:sieve" ],
  "methodCalls": [
    ["SieveScript/set", {
      "accountId": "ken",
      "onSuccessActivateScript": null
    }, "5"],
    ["SieveScript/set", {
      "accountId": "ken",
      "destroy": [ "dd1b164f-8cdc-448c-9f54" ]
    }, "6"]
  ]
}

{
  "methodResponses": [
    [
      "SieveScript/set",
      {
        "oldState": "1603744460.316617118-4096",
        "newState": "1603744637.575375572-4096",
        "created": null,
        "updated": {
          "dd1b164f-8cdc-448c-9f54": {
            "isActive": false
          }
        },
        "destroyed": null,
        "notCreated": null,
        "notUpdated": null,
        "notDestroyed": null,
        "accountId": "ken"
      },
      "5"
    ],
    [
      "SieveScript/set",
      {
        "oldState": "1603744637.575375572-4096",
        "newState": "1603744637.854390875-4096",
        "created": null,
        "updated": null,
        "destroyed": [
          "dd1b164f-8cdc-448c-9f54"
        ],
        "notCreated": null,
        "notUpdated": null,
        "notDestroyed": null,
        "accountId": "ken"
      },
      "6"
    ]
  ]
}
]]></artwork>
        </section>
      </section>
      <!-- /set -->

      <section numbered="true" toc="default">
        <name>SieveScript/query</name>
        <t>This is a standard "/query" method as described in
        <xref target="RFC8620" format="default"/>, Section 5.5.

        A <em>FilterCondition</em> object has the
        following properties, either of which may be omitted:

        </t>
        <ul spacing="normal">
          <li>
            <t><strong>name</strong>:
            <tt>String</tt>
            </t>
            <t>
            The SieveScript "name" property contains the given string.
            </t>
            <t/>
          </li>
          <li>
            <t><strong>isActive</strong>:
            <tt>Boolean</tt>
            </t>
            <t>
            The "isActive" property of the SieveScript must be
            identical to the value given to match the condition.
            </t>
            <t/>
          </li>
          <!--
          <t>
            <spanx style="strong">isIncluded</spanx>:
            <spanx style="verb">Boolean</spanx>
            <vspace blankLines="1"/>
            If true, the SieveScript must be included
            (see <xref target="RFC6609" />) by the content of another
            SieveScript to match the condition.
            Otherwise, the SieveScript must not be included by the
            content of another SieveScript to match the condition.
            <vspace blankLines="1"/>
          </t>
-->
        </ul>
        <t>The following SieveScript properties MUST be supported for
        sorting:

        </t>
        <ul spacing="normal">
          <li>
            <t><strong>name</strong>
            </t>
            <t/>
          </li>
          <li>
            <strong>isActive</strong>
          </li>
        </ul>
      </section>
      <section numbered="true" toc="default">
        <name>SieveScript/validate</name>
        <t>This method is used by the client to verify Sieve script
        validity without storing the script on the server,
        providing similar functionality to the
        CHECKSCRIPT command in <xref target="RFC5804" format="default"/>.
        </t>
        <t>The method takes the following arguments: 

        </t>
        <ul spacing="normal">
          <li>
            <t><strong>accountId</strong>:
              <tt>Id</tt>
            </t>
            <t>
              The id of the account to use.
            </t>
            <t/>
          </li>
          <li>
            <t><strong>blobId</strong>:
              <tt>Id</tt>
            </t>
            <t>
              The id of the blob containing the raw octets of the
              script to validate,
              subject to the same requirements in
              <xref target="object" format="default"/>.
            </t>
            <t/>
          </li>
        </ul>
        <t>The response has the following arguments: 

        </t>
        <ul spacing="normal">
          <li>
            <t><strong>accountId</strong>:
              <tt>Id</tt>
            </t>
            <t>
              The id of the account used for this call.
            </t>
            <t/>
          </li>
          <li>
            <t><strong>error</strong>:
              <tt>SetError|null</tt>
            </t>
            <t>
              A "invalidScript" SetError object if the script content
              is invalid (see <xref target="set" format="default"/>),
              or <tt>null</tt> if the
              script content is valid.
            </t>
            <t/>
          </li>
        </ul>
        <t>As with the
        <xref target="set" format="default">SieveScript/set</xref> method,
        script content must first be uploaded as a blob using either
        the standard upload mechanism
        (see <xref target="RFC8620" format="default"/>
        Section 6.1) or the JMAP Blob management extension
        (see <xref target="I-D.ietf-jmap-blob" format="default"/> Section 3.1).
        </t>
      </section>
      <!-- /validate -->

    </section>
    <section anchor="vacation" numbered="true" toc="default">
      <name>Compatibility with JMAP Vacation Response</name>
      <t>Section 8 of <xref target="RFC8621" format="default"/> defines a
      VacationResponse object to represent an autoresponder to
      incoming email messages.
      Servers that implement the VacationResponse as a Sieve script
      that resides amongst other user scripts are subject to the
      following requirements:

      </t>
      <ul spacing="normal">
        <li>MUST allow the VacationResponse Sieve script to be fetched
        by the <xref target="get" format="default">SieveScript/get</xref>
        method.
        </li>
        <li>MUST allow the VacationResponse Sieve script to be
        [de]activated via the "onSuccessActivateScript" argument to
        the <xref target="set" format="default">SieveScript/set</xref> method. 
        </li>
        <li>MUST NOT allow the VacationResponse Sieve script to be
        destroyed or have its content updated by the
        <xref target="set" format="default">SieveScript/set</xref> method.
        Any such request MUST be rejected with a "forbidden" SetError.
        A "description" property MAY be present with an explanation
        that the script can only be modified by a VacationResponse/set
        method.
        </li>
      </ul>
    </section>
    <section anchor="security" numbered="true" toc="default">
      <name>Security Considerations</name>
      <t>All security considerations of
      <xref target="RFC8620" format="default">JMAP</xref>
      and <xref target="RFC5228" format="default">Sieve</xref>
      apply to this specification.
      </t>
    </section>
    <section numbered="true" toc="default">
      <name>IANA Considerations</name>
      <section numbered="true" toc="default">
        <name>JMAP Capability Registration for "sieve"</name>
        <t>IANA will register the "sieve" JMAP Capability as follows:
        </t>
        <t>Capability Name:
        <tt>urn:ietf:params:jmap:sieve</tt>
        </t>
        <t>Specification document: this document
        </t>
        <t>Intended use: common
        </t>
        <t>Change Controller: IETF
        </t>
        <t>Security and privacy considerations: this document,
        <xref target="security" format="default"/>
        </t>
      </section>
      <section numbered="true" toc="default">
        <name>JMAP Error Codes Registry</name>
        <t>
          The following sub-sections register two new error codes in the
          JMAP Error Codes registry, as defined in
          <xref target="RFC8620" format="default"/>.
        </t>
        <section numbered="true" toc="default">
          <name>invalidScript</name>
          <t>JMAP Error Code: invalidScript </t>
          <t>Intended use: common </t>
          <t>Change controller: IETF </t>
          <t>Reference: This document, <xref target="set" format="default"/> </t>
          <t>Description: The SieveScript violates the
          <xref target="RFC5228" format="default">Sieve grammar</xref> and/or one
          or more extensions mentioned in the script's "require"
          statement(s) are not supported by the Sieve interpreter.</t>
        </section>
        <section numbered="true" toc="default">
          <name>scriptIsActive</name>
          <t>JMAP Error Code: scriptIsActive </t>
          <t>Intended use: common </t>
          <t>Change controller: IETF </t>
          <t>Reference: This document, <xref target="set" format="default"/> </t>
          <t>Description: The client tried to destroy the active
          SieveScript.</t>
        </section>
      </section>
    </section>
    <section numbered="true" toc="default">
      <name>Acknowledgments</name>
      <t>The concepts in this document are based largely on those in
      <xref target="RFC5804" format="default"/>. 
      The author would like to thank the authors of that document for
      providing both inspiration and some borrowed text for this
      document.</t>
      <t>The author would also like to thank the following
      individuals for contributing their ideas and support for
      writing this specification: Bron Gondwana, Neil Jenkins, Alexey
      Melnikov, and Ricardo Signes.</t>
    </section>
  </middle>
  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8620.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8621.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5228.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3986.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5435.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6134.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3629.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5198.xml"/>
      </references>
      <references>
        <name>Informative References</name>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5232.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5463.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5804.xml"/>
        <!--      <?rfc
     include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6609.xml"?> -->
      <xi:include href="https://datatracker.ietf.org/doc/bibxml3/draft-ietf-jmap-blob.xml"/>
      </references>
    </references>
    <section numbered="true" toc="default">
      <name>Change History
      (To be removed by RFC Editor before publication)</name>
      <t>Changes since ietf-11:
      </t>
      <ul spacing="normal">
        <li>Fixed examples to be proper JSON and JMAP.</li>
      </ul>
      <t>Changes since ietf-10:
      </t>
      <ul spacing="normal">
        <li>Fixed SieveScript/set response deactivating script example.</li>
        <li>Fixed line line nit in Blob/get request.</li>
        <li>Removed unused references.</li>
      </ul>
      <t>Changes since ietf-09:
      </t>
      <ul spacing="normal">
        <li>Fixed Blob/upload request in example.</li>
      </ul>
      <t>Changes since ietf-08:
      </t>
      <ul spacing="normal">
        <li>Fixed Blob/upload response in example.</li>
        <li>Removed SieveScript/test method (to be written as an
        extension document).</li>
      </ul>
      <t>Changes since ietf-07:
      </t>
      <ul spacing="normal">
        <li>Updated example to use Blob/upload rather than Blob/set.</li>
      </ul>
      <t>Changes since ietf-06:
      </t>
      <ul spacing="normal">
        <li>None (refreshed to avoid expiration).</li>
      </ul>
      <t>Changes since ietf-05:
      </t>
      <ul spacing="normal">
        <li>Converted source from xml2rfc v2 to v3.</li>
        <li>Added examples for SieveScript/get.</li>
        <li>Miscellaneous editorial changes.</li>
      </ul>
      <t>Changes since ietf-04:
      </t>
      <ul spacing="normal">
        <li>SieveScript/test: Switched from using a JSON array for each
        completed action and its args to a JSON object.</li>
        <li>Switched to referencing draft-ietf-jmap-blob.</li>
        <li>Miscellaneous editorial changes.</li>
      </ul>
      <t>Changes since ietf-03:
      </t>
      <ul spacing="normal">
        <li>SieveScript/test: Moved positional arguments into their own
        array (because the specfications don't use a consistent method for
        defining the action syntax or naming of positional arguments).</li>
      </ul>
      <t>Changes since ietf-02:
      </t>
      <ul spacing="normal">
        <li>Removed open issues.</li>
        <li>Reverted back to using only blob ids for script content.</li>
        <li>Added "rateLimit" and "requestTooLarge" to the list of
        possible error codes for /set method.</li>
        <li>Added Compatibility with JMAP Vacation Response
        section.</li>
        <li>Added RFC5228 to Security Considerations.</li>
        <li>Miscellaneous editorial changes.</li>
      </ul>
      <t>Changes since ietf-01:
      </t>
      <ul spacing="normal">
        <li>Removed normative references to ManageSieve (RFC 5804).</li>
        <li>Added the 'maxSizeScriptName' capability.</li>
        <li>Made the 'name' property in the SieveScript object
        optional.</li>
        <li>Added requirements for the 'name' property in the
        SieveScript object.</li>
        <li>Removed the 'blobId' property from the SieveScript
        object.</li>
        <li>Removed the 'replaceOnCreate' argument from the /set
        method.</li>
        <li>Removed the 'blobId' argument from the /validate method.</li>
        <li>Removed the 'scriptBlobId' argument from, and added the
        'scriptContent' argument to, the /test method.</li>
        <li>Editorial fixes from Neil Jenkins and Ricardo Signes.</li>
        <li>Other miscellaneous text reorganization and editorial fixes.</li>
      </ul>
      <t>Changes since ietf-00:
      </t>
      <ul spacing="normal">
        <li>Specified that changes made by onSuccessActivateScript MUST
        be reported in the /set response as created and/or updated as
        appropriate.</li>
        <li>Reworked and specified more of the /test response based on
        implementation experience.</li>
      </ul>
      <t>Changes since murchison-01:
      </t>
      <ul spacing="normal">
        <li>Explicitly stated that Sieve capability strings are
        case-sensitive.</li>
        <li>errorDescription is now String|null.</li>
        <li>Added /query method.</li>
        <li>Added /test method.</li>
      </ul>
      <t>Changes since murchison-00:
      </t>
      <ul spacing="normal">
        <li>Added IANA registration for "scriptIsActive" JMAP error code.</li>
        <li>Added open issue about /set{create} with an existing script name.</li>
      </ul>
    </section>
  </back>
</rfc>
