idnits 2.17.1 draft-ietf-jmap-sieve-05.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 (2 August 2021) is 988 days in the past. Is this intentional? 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-00 Summary: 0 errors (**), 0 flaws (~~), 2 warnings (==), 1 comment (--). 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 2 August 2021 5 Expires: 3 February 2022 7 JMAP for Sieve Scripts 8 draft-ietf-jmap-sieve-05 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 3 February 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 . . . . . . . . . . . . . . . . . 2 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.2. SieveScript/set . . . . . . . . . . . . . . . . . . . . . 5 56 2.2.1. Examples . . . . . . . . . . . . . . . . . . . . . . 7 57 2.3. SieveScript/query . . . . . . . . . . . . . . . . . . . . 14 58 2.4. SieveScript/validate . . . . . . . . . . . . . . . . . . 14 59 2.5. SieveScript/test . . . . . . . . . . . . . . . . . . . . 15 60 2.5.1. Example . . . . . . . . . . . . . . . . . . . . . . . 18 61 3. Compatibility with JMAP Vacation Response . . . . . . . . . . 21 62 4. Security Considerations . . . . . . . . . . . . . . . . . . . 21 63 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 21 64 5.1. JMAP Capability Registration for "sieve" . . . . . . . . 21 65 5.2. JMAP Error Codes Registry . . . . . . . . . . . . . . . . 21 66 5.2.1. invalidScript . . . . . . . . . . . . . . . . . . . . 22 67 5.2.2. scriptIsActive . . . . . . . . . . . . . . . . . . . 22 68 6. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 22 69 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 22 70 7.1. Normative References . . . . . . . . . . . . . . . . . . 22 71 7.2. Informative References . . . . . . . . . . . . . . . . . 23 72 Appendix A. Change History (To be removed by RFC Editor before 73 publication) . . . . . . . . . . . . . . . . . . . . . . 24 74 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 26 76 1. Introduction 78 JMAP [RFC8620] (JSON Meta Application Protocol) is a generic protocol 79 for synchronizing data, such as mail, calendars or contacts, between 80 a client and a server. It is optimized for mobile and web 81 environments, and aims to provide a consistent interface to different 82 data types. 84 This specification defines a data model for managing Sieve [RFC5228] 85 scripts on a server using JMAP. The data model is designed to allow 86 a server to provide consistent access to the same scripts via 87 ManageSieve [RFC5804] as well as JMAP, however the functionality 88 offered over the two protocols may differ. 90 1.1. Notational Conventions 92 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 93 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 94 "OPTIONAL" in this document are to be interpreted as described in BCP 95 14 [RFC2119] [RFC8174] when, and only when, they appear in all 96 capitals, as shown here. 98 Type signatures, examples, and property descriptions in this document 99 follow the conventions established in Section 1.1 of [RFC8620]. Data 100 types defined in the core specification are also used in this 101 document. 103 Servers MUST support all properties specified for the new data type 104 defined in this document. 106 For compatibility with publishing requirements, line breaks have been 107 inserted inside long JSON strings, with the following continuation 108 lines indented. To form the valid JSON example, any line breaks 109 inside a string must be replaced with a space and any other white 110 space after the line break removed. 112 1.2. Terminology 114 The same terminology is used in this document as in the core JMAP 115 specification, see [RFC8620], Section 1.6. 117 The term SieveScript (with this specific capitalization) is used to 118 refer to the data type defined in this document and instances of 119 those data types. 121 1.3. Addition to the Capabilities Object 123 The capabilities object is returned as part of the JMAP Session 124 object; see [RFC8620], Section 2. This document defines one 125 additional capability URI. 127 1.3.1. urn:ietf:params:jmap:sieve 129 This represents support for the SieveScript data type and associated 130 API methods. The value of this property in the JMAP Session 131 capabilities property is an empty object. 133 The value of this property in an account's accountCapabilities 134 property is an object that MUST contain the following information on 135 server capabilities: 137 * *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" 144 The maximum size (in octets) of a Sieve script the server is 145 willing to store for the user, or "null" for no limit. 147 * *maxNumberScripts*: "UnsignedInt|null" 149 The maximum number of Sieve scripts the server is willing to store 150 for the user, or "null" for no limit. 152 * *maxNumberRedirects*: "UnsignedInt|null" 154 The maximum number of Sieve "redirect" actions a script can 155 perform during a single evaluation or "null" for no limit. Note 156 that this is different from the total number of "redirect" actions 157 a script can contain. 159 * *sieveExtensions*: "String[]" 161 A list of case-sensitive Sieve capability strings (as listed in 162 Sieve "require" action; see [RFC5228], Section 3.2) indicating the 163 extensions supported by the Sieve engine. 165 * *notificationMethods*: "String[]|null" 167 A list of URI schema parts [RFC3986] for notification methods 168 supported by the Sieve "enotify" [RFC5435] extension, or "null" if 169 the extension is not supported by the Sieve engine. 171 * *externalLists*: "String[]|null" 173 A list of URI schema parts [RFC3986] for externally stored list 174 types supported by the Sieve "extlists" [RFC6134] extension, or 175 "null" if the extension is not supported by the Sieve engine. 177 * *supportsTest*: "Boolean" 179 If true, the server supports the SieveScript/test (Section 2.5) 180 method. 182 2. Sieve Scripts 184 A *SieveScript* object represents a single Sieve [RFC5228] script for 185 filtering email messages at time of final delivery. 187 A *SieveScript* object has the following properties: 189 * *id*: "Id" (immutable; server-set) 191 The id of the script. 193 * *name*: "String|null" (optional; default is server-dependent) 195 User-visible name for the SieveScript. If non-null, this MUST be 196 a Net-Unicode [RFC5198] string of at least 1 character in length, 197 subject to the maximum size given in the capability object. For 198 compatibility with ManageSieve, servers MUST reject names that 199 contain control characters. Servers MAY reject names that violate 200 server policy (e.g., names containing slash (/)). The name MUST 201 be unique among all SieveScripts within an account. 203 * *blobId*: "Id" 205 The id of the blob containing the raw octets of the script. 207 The script MUST be UTF-8 [RFC3629] content of at least 1 character 208 in length, subject to the syntax of Sieve [RFC5228]. The script 209 MUST NOT contain any "require" statement(s) mentioning Sieve 210 capabiltity strings not present in the capability (Section 1.3.1) 211 object. Note that if the Sieve "ihave" [RFC5463] capability 212 string is present in the capability object, the script MAY mention 213 unrecognized/unsupported extensions in the "ihave" test. 215 * *isActive*: "Boolean" (server-set; default: false) 217 A user may have multiple SieveScripts on the server, yet only one 218 script may be used for filtering of incoming messages. This is 219 the active script. Users may have zero or one active script. The 220 SieveScript/set (Section 2.2) method is used for changing the 221 active script or disabling Sieve processing. 223 2.1. SieveScript/get 225 This is a standard "/get" method as described in [RFC8620], 226 Section 5.1. The _ids_ argument may be "null" to fetch all at once. 228 This method provides similar functionality to the GETSCRIPT and 229 LISTSCRIPTS commands in [RFC5804]. 231 2.2. SieveScript/set 233 This is a standard "/set" method as described in [RFC8620], 234 Section 5.3 but with the following additional request argument, which 235 may be omitted: 237 * *onSuccessActivateScript*: "Id|null" (optional) 238 If "null", the currently active SieveScript (if any) will be 239 deactivated if and only if all of the creations, modifications, 240 and destructions (if any) succeed. Otherwise, the id of the 241 SieveScript to activate if and only if all of the creations, 242 modifications, and destructions (if any) succeed. (For references 243 to SieveScript creations, this is equivalent to a creation- 244 reference, so the id will be the creation id prefixed with a "#".) 245 If this argument is not present in the request, the currently 246 active SieveScript (if any) will remain as such. 248 The id of any activated SieveScript MUST be reported in either the 249 "created" or "updated" argument in the response as appropriate. 250 The id of any deactivated SieveScript MUST be reported in the 251 "updated" argument in the response. 253 This method provides similar functionality to the PUTSCRIPT, 254 DELETESCRIPT, RENAMESCRIPT, and SETACTIVE commands in [RFC5804]. 256 Script content must first be uploaded as a blob using either the 257 standard upload mechanism (see [RFC8620] Section 6.1) or the JMAP 258 Blob management extension (see [I-D.ietf-jmap-blob] Section 3.1). 260 If the SieveScript can not be created or updated because it would 261 result in two SieveScripts with the same name, the server MUST reject 262 the request with an "alreadyExists" SetError. An "existingId" 263 property of type "Id" MUST be included on the SetError object with 264 the id of the existing SieveScript. 266 If the SieveScript can not be created or updated because its size 267 exceeds the "maxSizeScript" limit, the server MUST reject the request 268 with a "tooLarge" SetError. 270 If the Sieve Script can not be created because it would exceed the 271 "maxNumberScripts" limit, the server MUST reject the request with an 272 "overQuota" SetError. 274 The active SieveScript MUST NOT be destroyed unless it is first 275 deactivated in a separate SieveScript/set method call. 277 The following extra SetError types are defined: 279 For "create" and "update": 281 * *invalidScript*: 283 The SieveScript content violates the Sieve [RFC5228] grammar and/ 284 or one or more extensions mentioned in the script's "require" 285 statement(s) are not supported by the Sieve interpreter. The 286 _description_ property on the SetError object SHOULD contain a 287 specific error message giving at least the line number of the 288 first error. 290 For "destroy": 292 * *scriptIsActive*: 294 The SieveScript is active. 296 2.2.1. Examples 298 Request (and response) to upload a script requiring the Imap4Flags 299 [RFC5232] Extension (assuming that the JMAP Upload URL has been 300 advertised in the JMAP Session object as having a path of "/jmap/ 301 upload/{accountId}/"): 303 POST /jmap/upload/ken/ HTTP/1.1 304 Host: jmap.example.com 305 Authorization: Basic a2VuOnBhc3N3b3Jk 306 Content-Type: application/sieve 307 Content-Length: 98 309 require "imapflags"; 311 if address :is ["To", "Cc"] "jmap@ietf.org" { 312 setflag "\\Flagged"; 313 } 315 HTTP/1.1 201 Created 316 Date: Thu, 10 Dec 2020 17:14:31 GMT 317 Content-Type: application/json; charset=utf-8 318 Content-Length: 171 320 { 321 "accountId": "ken", 322 "blobId": "Gabcc83e44a6e19991c4568d0b94e1767c83dd123", 323 "type": "application/sieve" 324 "size": 98 325 } 327 Request (and response) to create and activate a script using the 328 uploaded blob: 330 { 331 "using": [ "urn:ietf:params:jmap:core", 332 "urn:ietf:params:jmap:sieve" ], 333 "methodCalls": [ 334 ["SieveScript/set", { 335 "accountId": "ken", 336 "create": { "A": { 337 "name": null, 338 "blobId": "Gabcc83e44a6e19991c4568d0b94e1767c83dd123" 339 }, 340 "onSuccessActivateScript": "#A" 341 }, "0"] 342 ] 343 } 345 { 346 "methodResponses": [ 347 [ 348 "SieveScript/set", 349 { 350 "oldState": "1603741717.50737918-4096", 351 "newState": "1603741751.227268529-4096", 352 "created": { 353 "A": { 354 "id": "dd1b164f-8cdc-448c-9f54-60210b5f14ae", 355 "name": "ken-20201210T171432-0", 356 "blobId": "Sdd1b164f-8cdc-448c-9f54-60210b5f14ae", 357 "isActive": true 358 } 359 }, 360 "updated": null, 361 "destroyed": null, 362 "notCreated": null, 363 "notUpdated": null, 364 "notDestroyed": null, 365 "accountId": "ken" 366 }, 367 "0" 368 ] 369 ] 370 } 372 Request (and response) to update script content using the JMAP Blob 373 management extension [I-D.ietf-jmap-blob]: 375 { 376 "using": [ "urn:ietf:params:jmap:core", 377 "urn:ietf:params:jmap:sieve", 378 "urn:ietf:params:jmap:blob" ], 379 "methodCalls": [ 380 ["Blob/set", { 381 "accountId": "ken", 382 "create": { "B": { 383 "data:asText": "redirect \"ken@example.com\"\r\n;", 384 "type": "application/sieve" 385 } 386 }, "1"], 387 ["SieveScript/set", { 388 "accountId": "ken", 389 "update": { "dd1b164f-8cdc-448c-9f54-60210b5f14ae": { 390 "blobId": "#B" 391 } 392 } 393 }, "2"] 394 ] 395 } 397 { 398 "methodResponses": [ 399 [ 400 "Blob/set", 401 { 402 "oldState": null, 403 "newState": "1603741700.309607123-0128", 404 "created": { 405 "B": { 406 "id": "G969c83e44a6e10871c4568d0b94e1767c83ddeae", 407 "blobId": "G969c83e44a6e10871c4568d0b94e1767c83ddeae", 408 "type": "application/sieve", 409 "size": 29 410 } 411 }, 412 "updated": null, 413 "destroyed": null, 414 "notCreated": null, 415 "notUpdated": null, 416 "notDestroyed": null, 417 "accountId": "ken" 418 }, 419 "1" 420 ], 421 [ 422 "SieveScript/set", 423 { 424 "oldState": "1603741751.227268529-4096", 425 "newState": "1603742603.309607868-4096", 426 "created": null, 427 "updated": { 428 "dd1b164f-8cdc-448c-9f54-60210b5f14ae": null 429 }, 430 "destroyed": null, 431 "notCreated": null, 432 "notUpdated": null, 433 "notDestroyed": null, 434 "accountId": "ken" 435 }, 436 "2" 437 ] 438 ] 439 } 441 Request (and response) to update script name and deactivate: 443 { 444 "using": [ "urn:ietf:params:jmap:core", 445 "urn:ietf:params:jmap:sieve" ], 446 "methodCalls": [ 447 ["SieveScript/set", { 448 "accountId": "ken", 449 "update": { "dd1b164f-8cdc-448c-9f54-60210b5f14ae": { 450 "name": "myscript" 451 } 452 }, 453 "onSuccessActivateScript": null 454 }, "3"] 455 ] 456 } 458 { 459 "methodResponses": [ 460 [ 461 "SieveScript/set", 462 { 463 "oldState": "1603742603.309607868-4096", 464 "newState": "1603742967.852315428-4096", 465 "created": null, 466 "updated": { 467 "dd1b164f-8cdc-448c-9f54-60210b5f14ae": { 468 "isActive": false 469 } 470 }, 471 "destroyed": null, 472 "notCreated": null, 473 "notUpdated": null, 474 "notDestroyed": null, 475 "accountId": "ken" 476 }, 477 "3" 478 ] 479 ] 480 } 482 Request (and response) to activate a script: 484 { 485 "using": [ "urn:ietf:params:jmap:core", 486 "urn:ietf:params:jmap:sieve" ], 487 "methodCalls": [ 488 ["SieveScript/set", { 489 "accountId": "ken", 490 "onSuccessActivateScript": "dd1b164f-8cdc-448c-9f54-60210b5f14ae" 491 }, "4"] 492 ] 493 } 495 { 496 "methodResponses": [ 497 [ 498 "SieveScript/set", 499 { 500 "oldState": "1603742967.852315428-4096", 501 "newState": "1603744460.316617118-4096", 502 "created": null, 503 "updated": { 504 "dd1b164f-8cdc-448c-9f54-60210b5f14ae": { 505 "isActive": true 506 } 507 }, 508 "destroyed": null, 509 "notCreated": null, 510 "notUpdated": null, 511 "notDestroyed": null, 512 "accountId": "ken" 513 }, 514 "4" 515 ] 516 ] 517 } 519 Requests (and responses) to deactivate and destroy the active script: 521 { 522 "using": [ "urn:ietf:params:jmap:core", 523 "urn:ietf:params:jmap:sieve" ], 524 "methodCalls": [ 525 ["SieveScript/set", { 526 "accountId": "ken", 527 "onSuccessActivateScript": null 528 }, "5"], 529 ["SieveScript/set", { 530 "accountId": "ken", 531 "destroy": [ "dd1b164f-8cdc-448c-9f54-60210b5f14ae" ] 533 }, "6"] 534 ] 535 } 537 { 538 "methodResponses": [ 539 [ 540 "SieveScript/set", 541 { 542 "oldState": "1603744460.316617118-4096", 543 "newState": "1603744637.575375572-4096", 544 "created": null, 545 "updated": null, 546 "updated": { 547 "dd1b164f-8cdc-448c-9f54-60210b5f14ae": { 548 "isActive": false 549 } 550 }, 551 "destroyed": null, 552 "notCreated": null, 553 "notUpdated": null, 554 "notDestroyed": null, 555 "accountId": "ken" 556 }, 557 "5" 558 ], 559 [ 560 "SieveScript/set", 561 { 562 "oldState": "1603744637.575375572-4096", 563 "newState": "1603744637.854390875-4096", 564 "created": null, 565 "updated": null, 566 "destroyed": [ 567 "dd1b164f-8cdc-448c-9f54-60210b5f14ae" 568 ], 569 "notCreated": null, 570 "notUpdated": null, 571 "notDestroyed": null, 572 "accountId": "ken" 573 }, 574 "6" 575 ] 576 ] 577 } 579 2.3. SieveScript/query 581 This is a standard "/query" method as described in [RFC8620], 582 Section 5.5. A _FilterCondition_ object has the following 583 properties, either of which may be omitted: 585 * *name*: "String" 587 The SieveScript "name" property contains the given string. 589 * *isActive*: "Boolean" 591 The "isActive" property of the SieveScript must be identical to 592 the value given to match the condition. 594 The following SieveScript properties MUST be supported for sorting: 596 * *name* 598 * *isActive* 600 2.4. SieveScript/validate 602 This method is used by the client to verify Sieve script validity 603 without storing the script on the server, providing similar 604 functionality to the CHECKSCRIPT command in [RFC5804]. 606 The method takes the following arguments: 608 * *accountId*: "Id" 610 The id of the account to use. 612 * *blobId*: "Id" 614 The id of the blob containing the raw octets of the script to 615 validate, subject to the same requirements in Section 2. 617 The response has the following arguments: 619 * *accountId*: "Id" 621 The id of the account used for this call. 623 * *error*: "SetError|null" 625 A "invalidScript" SetError object if the script content is invalid 626 (see Section 2.2), or "null" if the script content is valid. 628 As with the SieveScript/set (Section 2.2) method, script content must 629 first be uploaded as a blob using either the standard upload 630 mechanism (see [RFC8620] Section 6.1) or the JMAP Blob management 631 extension (see [I-D.ietf-jmap-blob] Section 3.1). 633 2.5. SieveScript/test 635 This method is used by the client to ask the Sieve interpreter to 636 evaluate a Sieve script against a set of emails and report the 637 actions that would be performed for each. 639 When calling this method the "using" property of the Request object 640 MUST contain the capabilities "urn:ietf:params:jmap:sieve" and 641 "urn:ietf:params:jmap:mail". The latter is required due to the use 642 of blob ids which may reference Email objects and the use of the 643 Envelope object, as described below. 645 The *SieveScript/test* method takes the following arguments: 647 * *accountId*: "Id" 649 The id of the account to use. 651 * *scriptBlobId*: "String" 653 The id of the blob containing the raw octets of the script to 654 validate, subject to the same requirements in Section 2. 656 * *emailBlobIds*: "Id[]" 658 The ids representing the raw octets of the [RFC5322] messages to 659 test against. 661 * *envelope*: "Envelope|null" 663 Information that the Sieve interpreter should assume was present 664 in the SMTP transaction that delivered the message when evaluating 665 "envelope" tests. If "null", all "envelope" tests MUST evaluate 666 to false. See Section 7 of [RFC8621] for the contents of the 667 Envelope object. 669 * *lastVacationResponse*: "UTCDate|null" 671 The UTC date-time at which the Sieve interpreter should assume 672 that it last auto-replied to the sender of the message, or "null" 673 if the Sieve interpreter should assume that it has not auto- 674 replied to the sender. 676 The response has the following arguments: 678 * *accountId*: "Id" 680 The id of the account used for this call. 682 * *completed*: "Id[Action[]]|null" 684 A map of the blob id to a set of _Action_ objects for each message 685 successfully processed by the script, or "null" if none. The 686 _Action_ object has the following properties: 688 - *action*: "String" 690 The name of the Sieve action (e.g., "keep"). 692 - *taggedArgs*: "String[*]" 694 An object containing any named (tagged) arguments for the 695 action. The name MUST be the tag for the argument as given in 696 the specification of the action (e.g., ":flags"). This may be 697 an empty object if the action does not have any tagged 698 arguments, or none were specified in the Sieve script (e.g., 699 discard [RFC5228] or ereject [RFC5429] action). 701 - *positionalArgs*: "*[]" 703 An array containing any positional arguments for the action in 704 the order as given in the specification of the action. This 705 may be an empty array if the action does not have any 706 positional arguments (e.g., discard [RFC5228] or keep [RFC5228] 707 action). 709 * *notCompleted*: "Id[SetError]|null" 711 A map of the blob id to a SetError object for each message that 712 was not successfully processed by the script, or "null" if none. 713 A "serverFail" SetError (see Section 3.6.2 of [RFC8620]) MUST be 714 used to indicate a Sieve interpreter run-time error. 716 The JSON data type to use for each argument value is a direct mapping 717 from its Sieve data type, per the following table: 719 +===================+================+ 720 | Sieve Type | JSON Type | 721 +===================+================+ 722 | Number | Number | 723 +-------------------+----------------+ 724 | String | String | 725 +-------------------+----------------+ 726 | String List | String[] | 727 +-------------------+----------------+ 728 | tag with no value | Boolean (true) | 729 +-------------------+----------------+ 731 Table 1 733 Recommendations for constructing the list of arguments are as 734 follows: 736 * Optional arguments in which the value is supplied by the Sieve 737 interpreter SHOULD be included (e.g., ":from" and ":subject" 738 arguments to the "vacation" [RFC5230] action). 740 * Optional arguments in which the value is implicitly supplied by a 741 Sieve variable SHOULD be included (e.g., "keep" or "fileinto" 742 actions without an explicit ":flags" argument, but "imap4flags" 743 [RFC5232] have been set on the internal variable). 745 * Optional arguments in which the value is the specfied default MAY 746 be omitted. 748 * Tagged arguments that are only used to determine whether the 749 action will be executed and have no impact on the result of the 750 action MAY be omitted (e.g., ":days" and ":addresses" arguments to 751 the vacation action). 753 The following additional errors may be returned instead of the 754 "SieveScript/test" response: 756 * "invalidScript": The script content is invalid (see Section 2.2). 758 * "notFound": The script referenced by the id could not be found. 760 * "rateLimit": The number of recent test method calls has reached a 761 server-defined limit. 763 * "requestTooLarge": The total number of emailBlobIds exceeds the 764 maximum number the server is willing to process in a single test 765 method call. 767 * "serverFail": The script failed preparation to be executed for 768 some other reason. 770 2.5.1. Example 772 Assume that the following script has been created and has blob id 773 "S123". 775 require [ "imapflags", "editheader", "vacation", "fcc" ]; 776 setflag "$SieveFiltered"; 777 addheader :last "X-Sieve-Filtered" "yes"; 778 vacation :days 3 :fcc "INBOX.Sent" :flags "\\Answered" text: 779 Gone fishing. 780 . 781 ; 783 Assume that the following email has been uploaded and assigned blob 784 id "B456". 786 From: "Some Example Sender" 787 To: ken@example.com 788 Subject: test email 789 Date: Wed, 23 Sep 2020 12:11:11 -0500 790 Content-Type: text/plain; charset="UTF-8" 791 MIME-Version: 1.0 793 This is a test email. 795 The following request executes the script against the email and 796 provides envelope information for use by the "vacation" action. 798 { 799 "using": [ 800 "urn:ietf:params:jmap:core", 801 "urn:ietf:params:jmap:sieve", 802 "urn:ietf:params:jmap:mail" 803 ], 804 "methodCalls": [ 805 [ 806 "SieveScript/test", 807 { 808 "accountId": "ken", 809 "scriptBlobId": "S123", 810 "emailBlobIds": [ 811 "B456" 812 ], 813 "envelope": { 814 "mailFrom": { 815 "email": "example@example.net", 816 "parameters": null 817 }, 818 "rcptTo": [ 819 { 820 "email": "ken@example.com", 821 "parameters": null 822 } 823 ] 824 }, 825 "lastVacationResponse": null 826 }, 827 "R1" 828 ] 829 ] 830 } 832 The following response lists the actions that would be performed by 833 the script. 835 { 836 "methodResponses": [ 837 [ 838 "SieveScript/test", 839 { 840 "completed": { 841 "B456": [ 842 { 843 "action": "addheader", 844 "taggedArgs": { 845 ":last": true 846 }, 847 "positionalArgs": [ "X-Sieve-Filtered", "yes" ] 848 }, 849 { 850 "action": "vacation", 851 "taggedArgs": { 852 ":fcc": "INBOX.Sent", 853 ":flags": [ 854 "\\answered" 855 ], 856 ":subject": "Auto: test email", 857 ":from": "ken@example.com" 858 }, 859 "positionalArgs": [ "Gone fishing." ] 860 }, 861 { 862 "action": "keep", 863 "taggedArgs": { 864 ":flags": [ 865 "$SieveFiltered" 866 ] 867 }, 868 "positionalArgs": [ ] 869 } 870 ] 871 }, 872 "notCompleted": null, 873 "accountId": "ken", 874 }, 875 "R1" 876 ] 877 ] 878 } 880 3. Compatibility with JMAP Vacation Response 882 Section 8 of [RFC8621] defines a VacationResponse object to represent 883 an autoresponder to incoming email messages. Servers that implement 884 the VacationResponse as a Sieve script that resides amongst other 885 user scripts are subject to the following requirements: 887 * MUST allow the VacationResponse Sieve script to be fetched by the 888 SieveScript/get (Section 2.1) method. 890 * MUST allow the VacationResponse Sieve script to be [de]activated 891 via the "onSuccessActivateScript" argument to the SieveScript/set 892 (Section 2.2) method. 894 * MUST NOT allow the VacationResponse Sieve script to be destroyed 895 or have its content updated by the SieveScript/set (Section 2.2) 896 method. Any such request MUST be rejected with a "forbidden" 897 SetError. A "description" property MAY be present with an 898 explanation that the script can only be modified by a 899 VacationResponse/set method. 901 4. Security Considerations 903 All security considerations of JMAP [RFC8620] and Sieve [RFC5228] 904 apply to this specification. 906 5. IANA Considerations 908 5.1. JMAP Capability Registration for "sieve" 910 IANA will register the "sieve" JMAP Capability as follows: 912 Capability Name: "urn:ietf:params:jmap:sieve" 914 Specification document: this document 916 Intended use: common 918 Change Controller: IETF 920 Security and privacy considerations: this document, Section 4 922 5.2. JMAP Error Codes Registry 924 The following sub-sections register two new error codes in the JMAP 925 Error Codes registry, as defined in [RFC8620]. 927 5.2.1. invalidScript 929 JMAP Error Code: invalidScript 931 Intended use: common 933 Change controller: IETF 935 Reference: This document, Section 2.2 937 Description: The SieveScript violates the Sieve grammar [RFC5228] 938 and/or one or more extensions mentioned in the script's "require" 939 statement(s) are not supported by the Sieve interpreter. 941 5.2.2. scriptIsActive 943 JMAP Error Code: scriptIsActive 945 Intended use: common 947 Change controller: IETF 949 Reference: This document, Section 2.2 951 Description: The client tried to destroy the active SieveScript. 953 6. Acknowledgments 955 The concepts in this document are based largely on those in 956 [RFC5804]. The author would like to thank the authors of that 957 document for providing both inspiration and some borrowed text for 958 this document. 960 The author would also like to thank the following individuals for 961 contributing their ideas and support for writing this specification: 962 Bron Gondwana, Neil Jenkins, Alexey Melnikov, and Ricardo Signes. 964 7. References 966 7.1. Normative References 968 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 969 Requirement Levels", BCP 14, RFC 2119, 970 DOI 10.17487/RFC2119, March 1997, 971 . 973 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 974 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 975 2003, . 977 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 978 Resource Identifier (URI): Generic Syntax", STD 66, 979 RFC 3986, DOI 10.17487/RFC3986, January 2005, 980 . 982 [RFC5198] Klensin, J. and M. Padlipsky, "Unicode Format for Network 983 Interchange", RFC 5198, DOI 10.17487/RFC5198, March 2008, 984 . 986 [RFC5228] Guenther, P., Ed. and T. Showalter, Ed., "Sieve: An Email 987 Filtering Language", RFC 5228, DOI 10.17487/RFC5228, 988 January 2008, . 990 [RFC5322] Resnick, P., Ed., "Internet Message Format", RFC 5322, 991 DOI 10.17487/RFC5322, October 2008, 992 . 994 [RFC5435] Melnikov, A., Ed., Leiba, B., Ed., Segmuller, W., and T. 995 Martin, "Sieve Email Filtering: Extension for 996 Notifications", RFC 5435, DOI 10.17487/RFC5435, January 997 2009, . 999 [RFC6134] Melnikov, A. and B. Leiba, "Sieve Extension: Externally 1000 Stored Lists", RFC 6134, DOI 10.17487/RFC6134, July 2011, 1001 . 1003 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1004 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1005 May 2017, . 1007 [RFC8620] Jenkins, N. and C. Newman, "The JSON Meta Application 1008 Protocol (JMAP)", RFC 8620, DOI 10.17487/RFC8620, July 1009 2019, . 1011 [RFC8621] Jenkins, N. and C. Newman, "The JSON Meta Application 1012 Protocol (JMAP) for Mail", RFC 8621, DOI 10.17487/RFC8621, 1013 August 2019, . 1015 7.2. Informative References 1017 [I-D.ietf-jmap-blob] 1018 Gondwana, B., "JMAP Blob management extension", Work in 1019 Progress, Internet-Draft, draft-ietf-jmap-blob-00, 11 July 1020 2021, . 1023 [RFC5230] Showalter, T. and N. Freed, Ed., "Sieve Email Filtering: 1024 Vacation Extension", RFC 5230, DOI 10.17487/RFC5230, 1025 January 2008, . 1027 [RFC5232] Melnikov, A., "Sieve Email Filtering: Imap4flags 1028 Extension", RFC 5232, DOI 10.17487/RFC5232, January 2008, 1029 . 1031 [RFC5429] Stone, A., Ed., "Sieve Email Filtering: Reject and 1032 Extended Reject Extensions", RFC 5429, 1033 DOI 10.17487/RFC5429, March 2009, 1034 . 1036 [RFC5463] Freed, N., "Sieve Email Filtering: Ihave Extension", 1037 RFC 5463, DOI 10.17487/RFC5463, March 2009, 1038 . 1040 [RFC5804] Melnikov, A., Ed. and T. Martin, "A Protocol for Remotely 1041 Managing Sieve Scripts", RFC 5804, DOI 10.17487/RFC5804, 1042 July 2010, . 1044 Appendix A. Change History (To be removed by RFC Editor before 1045 publication) 1047 Changes since ietf-04: 1049 * SieveScript/test: Switched from using a JSON array for each 1050 completed action and its args to a JSON object. 1052 * Switched to referencing draft-ietf-jmap-blob. 1054 * Miscellaneous editorial changes. 1056 Changes since ietf-03: 1058 * SieveScript/test: Moved positional arguments into their own array 1059 (because the specfications don't use a consistent method for 1060 defining the action syntax or naming of positional arguments). 1062 Changes since ietf-02: 1064 * Removed open issues. 1066 * Reverted back to using only blob ids for script content. 1068 * Added "rateLimit" and "requestTooLarge" to the list of possible 1069 error codes for /set method. 1071 * Added Compatibility with JMAP Vacation Response section. 1073 * Added RFC5228 to Security Considerations. 1075 * Miscellaneous editorial changes. 1077 Changes since ietf-01: 1079 * Removed normative references to ManageSieve (RFC 5804). 1081 * Added the 'maxSizeScriptName' capability. 1083 * Made the 'name' property in the SieveScript object optional. 1085 * Added requirements for the 'name' property in the SieveScript 1086 object. 1088 * Removed the 'blobId' property from the SieveScript object. 1090 * Removed the 'replaceOnCreate' argument from the /set method. 1092 * Removed the 'blobId' argument from the /validate method. 1094 * Removed the 'scriptBlobId' argument from, and added the 1095 'scriptContent' argument to, the /test method. 1097 * Editorial fixes from Neil Jenkins and Ricardo Signes. 1099 * Other miscellaneous text reorganization and editorial fixes. 1101 Changes since ietf-00: 1103 * Specified that changes made by onSuccessActivateScript MUST be 1104 reported in the /set response as created and/or updated as 1105 appropriate. 1107 * Reworked and specified more of the /test response based on 1108 implementation experience. 1110 Changes since murchison-01: 1112 * Explicitly stated that Sieve capability strings are case- 1113 sensitive. 1115 * errorDescription is now String|null. 1117 * Added /query method. 1119 * Added /test method. 1121 Changes since murchison-00: 1123 * Added IANA registration for "scriptIsActive" JMAP error code. 1125 * Added open issue about /set{create} with an existing script name. 1127 Author's Address 1129 Kenneth Murchison 1130 Fastmail US LLC 1131 1429 Walnut Street - Suite 1201 1132 Philadelphia, PA 19102 1133 United States of America 1135 Email: murch@fastmailteam.com