idnits 2.17.1 draft-ietf-jmap-sieve-06.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (8 November 2021) is 899 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Outdated reference: A later version (-18) exists of draft-ietf-jmap-blob-05 Summary: 0 errors (**), 0 flaws (~~), 2 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 JMAP K. Murchison 3 Internet-Draft Fastmail 4 Intended status: Standards Track 8 November 2021 5 Expires: 12 May 2022 7 JMAP for Sieve Scripts 8 draft-ietf-jmap-sieve-06 10 Abstract 12 This document specifies a data model for managing Sieve scripts on a 13 server using the JSON Meta Application Protocol (JMAP). 15 Status of This Memo 17 This Internet-Draft is submitted in full conformance with the 18 provisions of BCP 78 and BCP 79. 20 Internet-Drafts are working documents of the Internet Engineering 21 Task Force (IETF). Note that other groups may also distribute 22 working documents as Internet-Drafts. The list of current Internet- 23 Drafts is at https://datatracker.ietf.org/drafts/current/. 25 Internet-Drafts are draft documents valid for a maximum of six months 26 and may be updated, replaced, or obsoleted by other documents at any 27 time. It is inappropriate to use Internet-Drafts as reference 28 material or to cite them other than as "work in progress." 30 This Internet-Draft will expire on 12 May 2022. 32 Copyright Notice 34 Copyright (c) 2021 IETF Trust and the persons identified as the 35 document authors. All rights reserved. 37 This document is subject to BCP 78 and the IETF Trust's Legal 38 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 39 license-info) in effect on the date of publication of this document. 40 Please review these documents carefully, as they describe your rights 41 and restrictions with respect to this document. Code Components 42 extracted from this document must include Simplified BSD License text 43 as described in Section 4.e of the Trust Legal Provisions and are 44 provided without warranty as described in the Simplified BSD License. 46 Table of Contents 48 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 49 1.1. Notational Conventions . . . . . . . . . . . . . . . . . 3 50 1.2. Terminology . . . . . . . . . . . . . . . . . . . . . . . 3 51 1.3. Addition to the Capabilities Object . . . . . . . . . . . 3 52 1.3.1. urn:ietf:params:jmap:sieve . . . . . . . . . . . . . 3 53 2. Sieve Scripts . . . . . . . . . . . . . . . . . . . . . . . . 4 54 2.1. SieveScript/get . . . . . . . . . . . . . . . . . . . . . 5 55 2.1.1. Examples . . . . . . . . . . . . . . . . . . . . . . 5 56 2.2. SieveScript/set . . . . . . . . . . . . . . . . . . . . . 8 57 2.2.1. Examples . . . . . . . . . . . . . . . . . . . . . . 10 58 2.3. SieveScript/query . . . . . . . . . . . . . . . . . . . . 17 59 2.4. SieveScript/validate . . . . . . . . . . . . . . . . . . 17 60 2.5. SieveScript/test . . . . . . . . . . . . . . . . . . . . 18 61 2.5.1. Example . . . . . . . . . . . . . . . . . . . . . . . 21 62 3. Compatibility with JMAP Vacation Response . . . . . . . . . . 24 63 4. Security Considerations . . . . . . . . . . . . . . . . . . . 24 64 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 24 65 5.1. JMAP Capability Registration for "sieve" . . . . . . . . 24 66 5.2. JMAP Error Codes Registry . . . . . . . . . . . . . . . . 24 67 5.2.1. invalidScript . . . . . . . . . . . . . . . . . . . . 25 68 5.2.2. scriptIsActive . . . . . . . . . . . . . . . . . . . 25 69 6. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 25 70 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 25 71 7.1. Normative References . . . . . . . . . . . . . . . . . . 25 72 7.2. Informative References . . . . . . . . . . . . . . . . . 26 73 Appendix A. Change History (To be removed by RFC Editor before 74 publication) . . . . . . . . . . . . . . . . . . . . . . 27 75 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 29 77 1. Introduction 79 JMAP [RFC8620] (JSON Meta Application Protocol) is a generic protocol 80 for synchronizing data, such as mail, calendars or contacts, between 81 a client and a server. It is optimized for mobile and web 82 environments, and aims to provide a consistent interface to different 83 data types. 85 This specification defines a data model for managing Sieve [RFC5228] 86 scripts on a server using JMAP. The data model is designed to allow 87 a server to provide consistent access to the same scripts via 88 ManageSieve [RFC5804] as well as JMAP, however the functionality 89 offered over the two protocols may differ. 91 1.1. Notational Conventions 93 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 94 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 95 "OPTIONAL" in this document are to be interpreted as described in BCP 96 14 [RFC2119] [RFC8174] when, and only when, they appear in all 97 capitals, as shown here. 99 Type signatures, examples, and property descriptions in this document 100 follow the conventions established in Section 1.1 of [RFC8620]. Data 101 types defined in the core specification are also used in this 102 document. 104 Servers MUST support all properties specified for the new data type 105 defined in this document. 107 For compatibility with publishing requirements, line breaks have been 108 inserted inside long JSON strings, with the following continuation 109 lines indented. To form the valid JSON example, any line breaks 110 inside a string must be replaced with a space and any other white 111 space after the line break removed. 113 1.2. Terminology 115 The same terminology is used in this document as in the core JMAP 116 specification, see [RFC8620], Section 1.6. 118 The term SieveScript (with this specific capitalization) is used to 119 refer to the data type defined in this document and instances of 120 those data types. 122 1.3. Addition to the Capabilities Object 124 The capabilities object is returned as part of the JMAP Session 125 object; see [RFC8620], Section 2. This document defines one 126 additional capability URI. 128 1.3.1. urn:ietf:params:jmap:sieve 130 This represents support for the SieveScript data type and associated 131 API methods. The value of this property in the JMAP Session 132 capabilities property is an empty object. 134 The value of this property in an account's accountCapabilities 135 property is an object that MUST contain the following information on 136 server capabilities: 138 * *maxSizeScriptName*: UnsignedInt 139 The maximum length, in (UTF-8) octets, allowed for the name of a 140 SieveScript. For compatibility with ManageSieve, this MUST be at 141 least 512 (up to 128 Unicode characters). 143 * *maxSizeScript*: UnsignedInt|null 145 The maximum size (in octets) of a Sieve script the server is 146 willing to store for the user, or null for no limit. 148 * *maxNumberScripts*: UnsignedInt|null 150 The maximum number of Sieve scripts the server is willing to store 151 for the user, or null for no limit. 153 * *maxNumberRedirects*: UnsignedInt|null 155 The maximum number of Sieve "redirect" actions a script can 156 perform during a single evaluation or null for no limit. Note 157 that this is different from the total number of "redirect" actions 158 a script can contain. 160 * *sieveExtensions*: String[] 162 A list of case-sensitive Sieve capability strings (as listed in 163 Sieve "require" action; see [RFC5228], Section 3.2) indicating the 164 extensions supported by the Sieve engine. 166 * *notificationMethods*: String[]|null 168 A list of URI schema parts [RFC3986] for notification methods 169 supported by the Sieve "enotify" [RFC5435] extension, or null if 170 the extension is not supported by the Sieve engine. 172 * *externalLists*: String[]|null 174 A list of URI schema parts [RFC3986] for externally stored list 175 types supported by the Sieve "extlists" [RFC6134] extension, or 176 null if the extension is not supported by the Sieve engine. 178 * *supportsTest*: Boolean 180 If true, the server supports the SieveScript/test (Section 2.5) 181 method. 183 2. Sieve Scripts 185 A *SieveScript* object represents a single Sieve [RFC5228] script for 186 filtering email messages at time of final delivery. 188 A *SieveScript* object has the following properties: 190 * *id*: Id (immutable; server-set) 192 The id of the script. 194 * *name*: String|null (optional; default is server-dependent) 196 User-visible name for the SieveScript. If non-null, this MUST be 197 a Net-Unicode [RFC5198] string of at least 1 character in length, 198 subject to the maximum size given in the capability object. For 199 compatibility with ManageSieve, servers MUST reject names that 200 contain control characters. Servers MAY reject names that violate 201 server policy (e.g., names containing slash (/)). The name MUST 202 be unique among all SieveScripts within an account. 204 * *blobId*: Id 206 The id of the blob containing the raw octets of the script. 208 The script MUST be UTF-8 [RFC3629] content of at least 1 character 209 in length, subject to the syntax of Sieve [RFC5228]. The script 210 MUST NOT contain any "require" statement(s) mentioning Sieve 211 capabiltity strings not present in the capability (Section 1.3.1) 212 object. Note that if the Sieve "ihave" [RFC5463] capability 213 string is present in the capability object, the script MAY mention 214 unrecognized/unsupported extensions in the "ihave" test. 216 * *isActive*: Boolean (server-set; default: false) 218 A user may have multiple SieveScripts on the server, yet only one 219 script may be used for filtering of incoming messages. This is 220 the active script. Users may have zero or one active script. The 221 SieveScript/set (Section 2.2) method is used for changing the 222 active script or disabling Sieve processing. 224 2.1. SieveScript/get 226 This is a standard "/get" method as described in [RFC8620], 227 Section 5.1. The _ids_ argument may be null to fetch all at once. 229 This method provides similar functionality to the GETSCRIPT and 230 LISTSCRIPTS commands in [RFC5804]. 232 2.1.1. Examples 234 Request (and response) to list all scripts: 236 { 237 "using": [ "urn:ietf:params:jmap:core", 238 "urn:ietf:params:jmap:sieve" ], 239 "methodCalls": [ 240 ["SieveScript/get", { 241 "accountId": "ken", 242 }, "0"] 243 ] 244 } 246 { 247 "methodResponses": [ 248 [ 249 "SieveScript/get", 250 { 251 "state": "1634915373.240633104-120", 252 "list": [ 253 { 254 "id": "2d647053-dded-418d-917a-63eda3ac8f7b", 255 "name": "test1", 256 "isActive": true, 257 "blobId": "S123" 258 } 259 ], 260 "notFound": [], 261 "accountId": "ken" 262 }, 263 "0" 264 ] 265 ] 266 } 268 Request (and response) to download the script (assuming that the JMAP 269 Download URL has been advertised in the JMAP Session object as having 270 a path of "/jmap/ 271 download/{accountId}/{blobId}/{name}?accept={type}"). Note that the 272 request-line has been wrapped for presentation purposes only. 274 GET 275 /jmap/download/ken/S123/test1.siv?accept=application/sieve 276 HTTP/1.1 277 Host: jmap.example.com 278 Authorization: Basic a2VuOnBhc3N3b3Jk 280 HTTP/1.1 200 OK 281 Date: Fri, 22 Oct 2021 15:27:38 GMT 282 Content-Type: application/sieve; charset=utf-8 283 Content-Disposition: attachment; filename="test1.siv" 284 Content-Length: 49 286 require ["fileinto"]; 287 fileinto "INBOX.target"; 289 Request (and response) to fetch the content of a single script: 291 { 292 "using": [ "urn:ietf:params:jmap:core", 293 "urn:ietf:params:jmap:blob", 294 "urn:ietf:params:jmap:sieve" ], 295 "methodCalls": [ 296 ["SieveScript/get", { 297 "accountId": "ken", 298 "ids": [ "2d647053-dded-418d-917a-63eda3ac8f7b" ], 299 }, "0"], 300 ["Blob/get", { 301 "accountId": "ken", 302 "#ids": { 303 "resultOf": "0", 304 "name": "SieveScript/get", 305 "path": "/list/*/blobId" 306 } 307 }, "1"] 308 ] 309 } 311 { 312 "methodResponses": [ 313 [ 314 "SieveScript/get", 315 { 316 "state": "1634915373.240633104-120", 317 "list": [ 318 { 319 "id": "2d647053-dded-418d-917a-63eda3ac8f7b", 320 "name": "test1", 321 "isActive": true, 322 "blobId": "S123" 323 } 324 ], 325 "notFound": [], 326 "accountId": "ken" 327 }, 328 "0" 329 ], 330 [ 331 "Blob/get", 332 { 333 "list": [ 334 { 335 "id": "S123", 336 "data:asText": 337 "require [\\"fileinto\\"];\\r\\nfileinto \\"INBOX.target\\";\\r\\n", 338 "size": 49 339 } 340 ], 341 "notFound": [], 342 "accountId": "ken" 343 }, 344 "1" 345 ] 346 ] 347 } 349 2.2. SieveScript/set 351 This is a standard "/set" method as described in [RFC8620], 352 Section 5.3 but with the following additional request argument, which 353 may be omitted: 355 * *onSuccessActivateScript*: Id|null (optional) 357 If null, the currently active SieveScript (if any) will be 358 deactivated if and only if all of the creations, modifications, 359 and destructions (if any) succeed. Otherwise, the id of the 360 SieveScript to activate if and only if all of the creations, 361 modifications, and destructions (if any) succeed. (For references 362 to SieveScript creations, this is equivalent to a creation- 363 reference, so the id will be the creation id prefixed with a "#".) 364 If this argument is not present in the request, the currently 365 active SieveScript (if any) will remain as such. 367 The id of any activated SieveScript MUST be reported in either the 368 "created" or "updated" argument in the response as appropriate. 369 The id of any deactivated SieveScript MUST be reported in the 370 "updated" argument in the response. 372 This method provides similar functionality to the PUTSCRIPT, 373 DELETESCRIPT, RENAMESCRIPT, and SETACTIVE commands in [RFC5804]. 375 Script content must first be uploaded as a blob using either the 376 standard upload mechanism (see [RFC8620] Section 6.1) or the JMAP 377 Blob management extension (see [I-D.ietf-jmap-blob] Section 3.1). 379 If the SieveScript can not be created or updated because it would 380 result in two SieveScripts with the same name, the server MUST reject 381 the request with an "alreadyExists" SetError. An "existingId" 382 property of type "Id" MUST be included on the SetError object with 383 the id of the existing SieveScript. 385 If the SieveScript can not be created or updated because its size 386 exceeds the "maxSizeScript" limit, the server MUST reject the request 387 with a "tooLarge" SetError. 389 If the Sieve Script can not be created because it would exceed the 390 "maxNumberScripts" limit, the server MUST reject the request with an 391 "overQuota" SetError. 393 The active SieveScript MUST NOT be destroyed unless it is first 394 deactivated in a separate SieveScript/set method call. 396 The following extra SetError types are defined: 398 For "create" and "update": 400 * *invalidScript*: 402 The SieveScript content violates the Sieve [RFC5228] grammar and/ 403 or one or more extensions mentioned in the script's "require" 404 statement(s) are not supported by the Sieve interpreter. The 405 _description_ property on the SetError object SHOULD contain a 406 specific error message giving at least the line number of the 407 first error. 409 For "destroy": 411 * *scriptIsActive*: 413 The SieveScript is active. 415 2.2.1. Examples 417 Request (and response) to upload a script requiring the Imap4Flags 418 [RFC5232] Extension (assuming that the JMAP Upload URL has been 419 advertised in the JMAP Session object as having a path of "/jmap/ 420 upload/{accountId}/"): 422 POST /jmap/upload/ken/ HTTP/1.1 423 Host: jmap.example.com 424 Authorization: Basic a2VuOnBhc3N3b3Jk 425 Content-Type: application/sieve 426 Content-Length: 98 428 require "imapflags"; 430 if address :is ["To", "Cc"] "jmap@ietf.org" { 431 setflag "\\Flagged"; 432 } 434 HTTP/1.1 201 Created 435 Date: Thu, 10 Dec 2020 17:14:31 GMT 436 Content-Type: application/json; charset=utf-8 437 Content-Length: 171 439 { 440 "accountId": "ken", 441 "blobId": "Gabcc83e44a6e19991c4568d0b94e1767c83dd123", 442 "type": "application/sieve" 443 "size": 98 444 } 446 Request (and response) to create and activate a script using the 447 uploaded blob: 449 { 450 "using": [ "urn:ietf:params:jmap:core", 451 "urn:ietf:params:jmap:sieve" ], 452 "methodCalls": [ 453 ["SieveScript/set", { 454 "accountId": "ken", 455 "create": { "A": { 456 "name": null, 457 "blobId": "Gabcc83e44a6e19991c4568d0b94e1767c83dd123" 458 }, 459 "onSuccessActivateScript": "#A" 460 }, "0"] 461 ] 462 } 464 { 465 "methodResponses": [ 466 [ 467 "SieveScript/set", 468 { 469 "oldState": "1603741717.50737918-4096", 470 "newState": "1603741751.227268529-4096", 471 "created": { 472 "A": { 473 "id": "dd1b164f-8cdc-448c-9f54", 474 "name": "ken-20201210T171432-0", 475 "blobId": "Sdd1b164f-8cdc-448c-9f54", 476 "isActive": true 477 } 478 }, 479 "updated": null, 480 "destroyed": null, 481 "notCreated": null, 482 "notUpdated": null, 483 "notDestroyed": null, 484 "accountId": "ken" 485 }, 486 "0" 487 ] 488 ] 489 } 491 Request (and response) to update script content using the JMAP Blob 492 management extension [I-D.ietf-jmap-blob]: 494 { 495 "using": [ "urn:ietf:params:jmap:core", 496 "urn:ietf:params:jmap:blob", 497 "urn:ietf:params:jmap:sieve" ], 498 "methodCalls": [ 499 ["Blob/set", { 500 "accountId": "ken", 501 "create": { "B": { 502 "data:asText": "redirect \"ken@example.com\"\r\n;", 503 "type": "application/sieve" 504 } 505 }, "1"], 506 ["SieveScript/set", { 507 "accountId": "ken", 508 "update": { "dd1b164f-8cdc-448c-9f54": { 509 "blobId": "#B" 510 } 511 } 512 }, "2"] 513 ] 514 } 516 { 517 "methodResponses": [ 518 [ 519 "Blob/set", 520 { 521 "oldState": null, 522 "newState": "1603741700.309607123-0128", 523 "created": { 524 "B": { 525 "id": "G969c83e44a6e10871c4568d0b94e1767c83ddeae", 526 "blobId": "G969c83e44a6e10871c4568d0b94e1767c83ddeae", 527 "type": "application/sieve", 528 "size": 29 529 } 530 }, 531 "updated": null, 532 "destroyed": null, 533 "notCreated": null, 534 "notUpdated": null, 535 "notDestroyed": null, 536 "accountId": "ken" 537 }, 538 "1" 539 ], 540 [ 541 "SieveScript/set", 542 { 543 "oldState": "1603741751.227268529-4096", 544 "newState": "1603742603.309607868-4096", 545 "created": null, 546 "updated": { 547 "dd1b164f-8cdc-448c-9f54": null 548 }, 549 "destroyed": null, 550 "notCreated": null, 551 "notUpdated": null, 552 "notDestroyed": null, 553 "accountId": "ken" 554 }, 555 "2" 556 ] 557 ] 558 } 560 Request (and response) to update script name and deactivate: 562 { 563 "using": [ "urn:ietf:params:jmap:core", 564 "urn:ietf:params:jmap:sieve" ], 565 "methodCalls": [ 566 ["SieveScript/set", { 567 "accountId": "ken", 568 "update": { "dd1b164f-8cdc-448c-9f54": { 569 "name": "myscript" 570 } 571 }, 572 "onSuccessActivateScript": null 573 }, "3"] 574 ] 575 } 577 { 578 "methodResponses": [ 579 [ 580 "SieveScript/set", 581 { 582 "oldState": "1603742603.309607868-4096", 583 "newState": "1603742967.852315428-4096", 584 "created": null, 585 "updated": { 586 "dd1b164f-8cdc-448c-9f54": { 587 "isActive": false 588 } 589 }, 590 "destroyed": null, 591 "notCreated": null, 592 "notUpdated": null, 593 "notDestroyed": null, 594 "accountId": "ken" 595 }, 596 "3" 597 ] 598 ] 599 } 601 Request (and response) to activate a script: 603 { 604 "using": [ "urn:ietf:params:jmap:core", 605 "urn:ietf:params:jmap:sieve" ], 606 "methodCalls": [ 607 ["SieveScript/set", { 608 "accountId": "ken", 609 "onSuccessActivateScript": "dd1b164f-8cdc-448c-9f54" 610 }, "4"] 611 ] 612 } 614 { 615 "methodResponses": [ 616 [ 617 "SieveScript/set", 618 { 619 "oldState": "1603742967.852315428-4096", 620 "newState": "1603744460.316617118-4096", 621 "created": null, 622 "updated": { 623 "dd1b164f-8cdc-448c-9f54": { 624 "isActive": true 625 } 626 }, 627 "destroyed": null, 628 "notCreated": null, 629 "notUpdated": null, 630 "notDestroyed": null, 631 "accountId": "ken" 632 }, 633 "4" 634 ] 635 ] 636 } 638 Requests (and responses) to deactivate and destroy the active script: 640 { 641 "using": [ "urn:ietf:params:jmap:core", 642 "urn:ietf:params:jmap:sieve" ], 643 "methodCalls": [ 644 ["SieveScript/set", { 645 "accountId": "ken", 646 "onSuccessActivateScript": null 647 }, "5"], 648 ["SieveScript/set", { 649 "accountId": "ken", 650 "destroy": [ "dd1b164f-8cdc-448c-9f54" ] 652 }, "6"] 653 ] 654 } 656 { 657 "methodResponses": [ 658 [ 659 "SieveScript/set", 660 { 661 "oldState": "1603744460.316617118-4096", 662 "newState": "1603744637.575375572-4096", 663 "created": null, 664 "updated": null, 665 "updated": { 666 "dd1b164f-8cdc-448c-9f54": { 667 "isActive": false 668 } 669 }, 670 "destroyed": null, 671 "notCreated": null, 672 "notUpdated": null, 673 "notDestroyed": null, 674 "accountId": "ken" 675 }, 676 "5" 677 ], 678 [ 679 "SieveScript/set", 680 { 681 "oldState": "1603744637.575375572-4096", 682 "newState": "1603744637.854390875-4096", 683 "created": null, 684 "updated": null, 685 "destroyed": [ 686 "dd1b164f-8cdc-448c-9f54" 687 ], 688 "notCreated": null, 689 "notUpdated": null, 690 "notDestroyed": null, 691 "accountId": "ken" 692 }, 693 "6" 694 ] 695 ] 696 } 698 2.3. SieveScript/query 700 This is a standard "/query" method as described in [RFC8620], 701 Section 5.5. A _FilterCondition_ object has the following 702 properties, either of which may be omitted: 704 * *name*: String 706 The SieveScript "name" property contains the given string. 708 * *isActive*: Boolean 710 The "isActive" property of the SieveScript must be identical to 711 the value given to match the condition. 713 The following SieveScript properties MUST be supported for sorting: 715 * *name* 717 * *isActive* 719 2.4. SieveScript/validate 721 This method is used by the client to verify Sieve script validity 722 without storing the script on the server, providing similar 723 functionality to the CHECKSCRIPT command in [RFC5804]. 725 The method takes the following arguments: 727 * *accountId*: Id 729 The id of the account to use. 731 * *blobId*: Id 733 The id of the blob containing the raw octets of the script to 734 validate, subject to the same requirements in Section 2. 736 The response has the following arguments: 738 * *accountId*: Id 740 The id of the account used for this call. 742 * *error*: SetError|null 744 A "invalidScript" SetError object if the script content is invalid 745 (see Section 2.2), or null if the script content is valid. 747 As with the SieveScript/set (Section 2.2) method, script content must 748 first be uploaded as a blob using either the standard upload 749 mechanism (see [RFC8620] Section 6.1) or the JMAP Blob management 750 extension (see [I-D.ietf-jmap-blob] Section 3.1). 752 2.5. SieveScript/test 754 This method is used by the client to ask the Sieve interpreter to 755 evaluate a Sieve script against a set of emails and report the 756 actions that would be performed for each. 758 When calling this method the "using" property of the Request object 759 MUST contain the capabilities "urn:ietf:params:jmap:sieve" and 760 "urn:ietf:params:jmap:mail". The latter is required due to the use 761 of blob ids which may reference Email objects and the use of the 762 Envelope object, as described below. 764 The *SieveScript/test* method takes the following arguments: 766 * *accountId*: Id 768 The id of the account to use. 770 * *scriptBlobId*: String 772 The id of the blob containing the raw octets of the script to 773 validate, subject to the same requirements in Section 2. 775 * *emailBlobIds*: Id[] 777 The ids representing the raw octets of the [RFC5322] messages to 778 test against. 780 * *envelope*: Envelope|null 782 Information that the Sieve interpreter should assume was present 783 in the SMTP transaction that delivered the message when evaluating 784 "envelope" tests. If null, all "envelope" tests MUST evaluate to 785 false. See Section 7 of [RFC8621] for the contents of the 786 Envelope object. 788 * *lastVacationResponse*: UTCDate|null 790 The UTC date-time at which the Sieve interpreter should assume 791 that it last auto-replied to the sender of the message, or null if 792 the Sieve interpreter should assume that it has not auto-replied 793 to the sender. 795 The response has the following arguments: 797 * *accountId*: Id 799 The id of the account used for this call. 801 * *completed*: Id[Action[]]|null 803 A map of the blob id to a set of _Action_ objects for each message 804 successfully processed by the script, or null if none. The 805 _Action_ object has the following properties: 807 - *action*: String 809 The name of the Sieve action (e.g., "keep"). 811 - *taggedArgs*: String[*] 813 An object containing any named (tagged) arguments for the 814 action. The name MUST be the tag for the argument as given in 815 the specification of the action (e.g., ":flags"). This may be 816 an empty object if the action does not have any tagged 817 arguments, or none were specified in the Sieve script (e.g., 818 discard [RFC5228] or ereject [RFC5429] action). 820 - *positionalArgs*: *[] 822 An array containing any positional arguments for the action in 823 the order as given in the specification of the action. This 824 may be an empty array if the action does not have any 825 positional arguments (e.g., discard [RFC5228] or keep [RFC5228] 826 action). 828 * *notCompleted*: Id[SetError]|null 830 A map of the blob id to a SetError object for each message that 831 was not successfully processed by the script, or null if none. A 832 "serverFail" SetError (see Section 3.6.2 of [RFC8620]) MUST be 833 used to indicate a Sieve interpreter run-time error. 835 The JSON data type to use for each argument value is a direct mapping 836 from its Sieve data type, per the following table: 838 +===================+================+ 839 | Sieve Type | JSON Type | 840 +===================+================+ 841 | Number | Number | 842 +-------------------+----------------+ 843 | String | String | 844 +-------------------+----------------+ 845 | String List | String[] | 846 +-------------------+----------------+ 847 | tag with no value | Boolean (true) | 848 +-------------------+----------------+ 850 Table 1 852 Recommendations for constructing the list of arguments are as 853 follows: 855 * Optional arguments in which the value is supplied by the Sieve 856 interpreter SHOULD be included (e.g., ":from" and ":subject" 857 arguments to the "vacation" [RFC5230] action). 859 * Optional arguments in which the value is implicitly supplied by a 860 Sieve variable SHOULD be included (e.g., "keep" or "fileinto" 861 actions without an explicit ":flags" argument, but "imap4flags" 862 [RFC5232] have been set on the internal variable). 864 * Optional arguments in which the value is the specfied default MAY 865 be omitted. 867 * Tagged arguments that are only used to determine whether the 868 action will be executed and have no impact on the result of the 869 action MAY be omitted (e.g., ":days" and ":addresses" arguments to 870 the vacation action). 872 The following additional errors may be returned instead of the 873 "SieveScript/test" response: 875 * "invalidScript": The script content is invalid (see Section 2.2). 877 * "notFound": The script referenced by the id could not be found. 879 * "rateLimit": The number of recent test method calls has reached a 880 server-defined limit. 882 * "requestTooLarge": The total number of emailBlobIds exceeds the 883 maximum number the server is willing to process in a single test 884 method call. 886 * "serverFail": The script failed preparation to be executed for 887 some other reason. 889 2.5.1. Example 891 Assume that the following script has been created and has blob id 892 "S123". 894 require [ "imapflags", "editheader", "vacation", "fcc" ]; 895 setflag "$SieveFiltered"; 896 addheader :last "X-Sieve-Filtered" "yes"; 897 vacation :days 3 :fcc "INBOX.Sent" :flags "\\Answered" text: 898 Gone fishing. 899 . 900 ; 902 Assume that the following email has been uploaded and assigned blob 903 id "B456". 905 From: "Some Example Sender" 906 To: ken@example.com 907 Subject: test email 908 Date: Wed, 23 Sep 2020 12:11:11 -0500 909 Content-Type: text/plain; charset="UTF-8" 910 MIME-Version: 1.0 912 This is a test email. 914 The following request executes the script against the email and 915 provides envelope information for use by the "vacation" action. 917 { 918 "using": [ 919 "urn:ietf:params:jmap:core", 920 "urn:ietf:params:jmap:sieve", 921 "urn:ietf:params:jmap:mail" 922 ], 923 "methodCalls": [ 924 [ 925 "SieveScript/test", 926 { 927 "accountId": "ken", 928 "scriptBlobId": "S123", 929 "emailBlobIds": [ 930 "B456" 931 ], 932 "envelope": { 933 "mailFrom": { 934 "email": "example@example.net", 935 "parameters": null 936 }, 937 "rcptTo": [ 938 { 939 "email": "ken@example.com", 940 "parameters": null 941 } 942 ] 943 }, 944 "lastVacationResponse": null 945 }, 946 "R1" 947 ] 948 ] 949 } 951 The following response lists the actions that would be performed by 952 the script. 954 { 955 "methodResponses": [ 956 [ 957 "SieveScript/test", 958 { 959 "completed": { 960 "B456": [ 961 { 962 "action": "addheader", 963 "taggedArgs": { 964 ":last": true 965 }, 966 "positionalArgs": [ "X-Sieve-Filtered", "yes" ] 967 }, 968 { 969 "action": "vacation", 970 "taggedArgs": { 971 ":fcc": "INBOX.Sent", 972 ":flags": [ 973 "\\answered" 974 ], 975 ":subject": "Auto: test email", 976 ":from": "ken@example.com" 977 }, 978 "positionalArgs": [ "Gone fishing." ] 979 }, 980 { 981 "action": "keep", 982 "taggedArgs": { 983 ":flags": [ 984 "$SieveFiltered" 985 ] 986 }, 987 "positionalArgs": [ ] 988 } 989 ] 990 }, 991 "notCompleted": null, 992 "accountId": "ken", 993 }, 994 "R1" 995 ] 996 ] 997 } 999 3. Compatibility with JMAP Vacation Response 1001 Section 8 of [RFC8621] defines a VacationResponse object to represent 1002 an autoresponder to incoming email messages. Servers that implement 1003 the VacationResponse as a Sieve script that resides amongst other 1004 user scripts are subject to the following requirements: 1006 * MUST allow the VacationResponse Sieve script to be fetched by the 1007 SieveScript/get (Section 2.1) method. 1009 * MUST allow the VacationResponse Sieve script to be [de]activated 1010 via the "onSuccessActivateScript" argument to the SieveScript/set 1011 (Section 2.2) method. 1013 * MUST NOT allow the VacationResponse Sieve script to be destroyed 1014 or have its content updated by the SieveScript/set (Section 2.2) 1015 method. Any such request MUST be rejected with a "forbidden" 1016 SetError. A "description" property MAY be present with an 1017 explanation that the script can only be modified by a 1018 VacationResponse/set method. 1020 4. Security Considerations 1022 All security considerations of JMAP [RFC8620] and Sieve [RFC5228] 1023 apply to this specification. 1025 5. IANA Considerations 1027 5.1. JMAP Capability Registration for "sieve" 1029 IANA will register the "sieve" JMAP Capability as follows: 1031 Capability Name: urn:ietf:params:jmap:sieve 1033 Specification document: this document 1035 Intended use: common 1037 Change Controller: IETF 1039 Security and privacy considerations: this document, Section 4 1041 5.2. JMAP Error Codes Registry 1043 The following sub-sections register two new error codes in the JMAP 1044 Error Codes registry, as defined in [RFC8620]. 1046 5.2.1. invalidScript 1048 JMAP Error Code: invalidScript 1050 Intended use: common 1052 Change controller: IETF 1054 Reference: This document, Section 2.2 1056 Description: The SieveScript violates the Sieve grammar [RFC5228] 1057 and/or one or more extensions mentioned in the script's "require" 1058 statement(s) are not supported by the Sieve interpreter. 1060 5.2.2. scriptIsActive 1062 JMAP Error Code: scriptIsActive 1064 Intended use: common 1066 Change controller: IETF 1068 Reference: This document, Section 2.2 1070 Description: The client tried to destroy the active SieveScript. 1072 6. Acknowledgments 1074 The concepts in this document are based largely on those in 1075 [RFC5804]. The author would like to thank the authors of that 1076 document for providing both inspiration and some borrowed text for 1077 this document. 1079 The author would also like to thank the following individuals for 1080 contributing their ideas and support for writing this specification: 1081 Bron Gondwana, Neil Jenkins, Alexey Melnikov, and Ricardo Signes. 1083 7. References 1085 7.1. Normative References 1087 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1088 Requirement Levels", BCP 14, RFC 2119, 1089 DOI 10.17487/RFC2119, March 1997, 1090 . 1092 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 1093 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 1094 2003, . 1096 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1097 Resource Identifier (URI): Generic Syntax", STD 66, 1098 RFC 3986, DOI 10.17487/RFC3986, January 2005, 1099 . 1101 [RFC5198] Klensin, J. and M. Padlipsky, "Unicode Format for Network 1102 Interchange", RFC 5198, DOI 10.17487/RFC5198, March 2008, 1103 . 1105 [RFC5228] Guenther, P., Ed. and T. Showalter, Ed., "Sieve: An Email 1106 Filtering Language", RFC 5228, DOI 10.17487/RFC5228, 1107 January 2008, . 1109 [RFC5322] Resnick, P., Ed., "Internet Message Format", RFC 5322, 1110 DOI 10.17487/RFC5322, October 2008, 1111 . 1113 [RFC5435] Melnikov, A., Ed., Leiba, B., Ed., Segmuller, W., and T. 1114 Martin, "Sieve Email Filtering: Extension for 1115 Notifications", RFC 5435, DOI 10.17487/RFC5435, January 1116 2009, . 1118 [RFC6134] Melnikov, A. and B. Leiba, "Sieve Extension: Externally 1119 Stored Lists", RFC 6134, DOI 10.17487/RFC6134, July 2011, 1120 . 1122 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1123 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1124 May 2017, . 1126 [RFC8620] Jenkins, N. and C. Newman, "The JSON Meta Application 1127 Protocol (JMAP)", RFC 8620, DOI 10.17487/RFC8620, July 1128 2019, . 1130 [RFC8621] Jenkins, N. and C. Newman, "The JSON Meta Application 1131 Protocol (JMAP) for Mail", RFC 8621, DOI 10.17487/RFC8621, 1132 August 2019, . 1134 7.2. Informative References 1136 [I-D.ietf-jmap-blob] 1137 Gondwana, B., "JMAP Blob management extension", Work in 1138 Progress, Internet-Draft, draft-ietf-jmap-blob-05, 28 1139 October 2021, . 1142 [RFC5230] Showalter, T. and N. Freed, Ed., "Sieve Email Filtering: 1143 Vacation Extension", RFC 5230, DOI 10.17487/RFC5230, 1144 January 2008, . 1146 [RFC5232] Melnikov, A., "Sieve Email Filtering: Imap4flags 1147 Extension", RFC 5232, DOI 10.17487/RFC5232, January 2008, 1148 . 1150 [RFC5429] Stone, A., Ed., "Sieve Email Filtering: Reject and 1151 Extended Reject Extensions", RFC 5429, 1152 DOI 10.17487/RFC5429, March 2009, 1153 . 1155 [RFC5463] Freed, N., "Sieve Email Filtering: Ihave Extension", 1156 RFC 5463, DOI 10.17487/RFC5463, March 2009, 1157 . 1159 [RFC5804] Melnikov, A., Ed. and T. Martin, "A Protocol for Remotely 1160 Managing Sieve Scripts", RFC 5804, DOI 10.17487/RFC5804, 1161 July 2010, . 1163 Appendix A. Change History (To be removed by RFC Editor before 1164 publication) 1166 Changes since ietf-05: 1168 * Converted source from xml2rfc v2 to v3. 1170 * Added examples for SieveScript/get. 1172 * Miscellaneous editorial changes. 1174 Changes since ietf-04: 1176 * SieveScript/test: Switched from using a JSON array for each 1177 completed action and its args to a JSON object. 1179 * Switched to referencing draft-ietf-jmap-blob. 1181 * Miscellaneous editorial changes. 1183 Changes since ietf-03: 1185 * SieveScript/test: Moved positional arguments into their own array 1186 (because the specfications don't use a consistent method for 1187 defining the action syntax or naming of positional arguments). 1189 Changes since ietf-02: 1191 * Removed open issues. 1193 * Reverted back to using only blob ids for script content. 1195 * Added "rateLimit" and "requestTooLarge" to the list of possible 1196 error codes for /set method. 1198 * Added Compatibility with JMAP Vacation Response section. 1200 * Added RFC5228 to Security Considerations. 1202 * Miscellaneous editorial changes. 1204 Changes since ietf-01: 1206 * Removed normative references to ManageSieve (RFC 5804). 1208 * Added the 'maxSizeScriptName' capability. 1210 * Made the 'name' property in the SieveScript object optional. 1212 * Added requirements for the 'name' property in the SieveScript 1213 object. 1215 * Removed the 'blobId' property from the SieveScript object. 1217 * Removed the 'replaceOnCreate' argument from the /set method. 1219 * Removed the 'blobId' argument from the /validate method. 1221 * Removed the 'scriptBlobId' argument from, and added the 1222 'scriptContent' argument to, the /test method. 1224 * Editorial fixes from Neil Jenkins and Ricardo Signes. 1226 * Other miscellaneous text reorganization and editorial fixes. 1228 Changes since ietf-00: 1230 * Specified that changes made by onSuccessActivateScript MUST be 1231 reported in the /set response as created and/or updated as 1232 appropriate. 1234 * Reworked and specified more of the /test response based on 1235 implementation experience. 1237 Changes since murchison-01: 1239 * Explicitly stated that Sieve capability strings are case- 1240 sensitive. 1242 * errorDescription is now String|null. 1244 * Added /query method. 1246 * Added /test method. 1248 Changes since murchison-00: 1250 * Added IANA registration for "scriptIsActive" JMAP error code. 1252 * Added open issue about /set{create} with an existing script name. 1254 Author's Address 1256 Kenneth Murchison 1257 Fastmail US LLC 1258 1429 Walnut Street - Suite 1201 1259 Philadelphia, PA 19102 1260 United States of America 1262 Email: murch@fastmailteam.com