idnits 2.17.1 draft-snell-activitystreams-actions-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 seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). -- The document date (May 1, 2014) is 3620 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) == Unused Reference: 'RFC2119' is defined on line 1115, but no explicit reference was found in the text == Outdated reference: A later version (-09) exists of draft-snell-activitystreams-07 Summary: 0 errors (**), 0 flaws (~~), 4 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Activity Streams (http://activitystrea.ms) J. Snell 3 Internet-Draft IBM 4 Intended status: Standards Track M. Marum 5 Expires: November 2, 2014 SugarCRM 6 May 1, 2014 8 JSON Activity Streams 2.0 - Action Handlers 9 draft-snell-activitystreams-actions-05 11 Abstract 13 This specification defines Action Handlers for use with the Activity 14 Streams 2.0 format. 16 Author's Note 18 Note that this document is a work-in-progress draft specification 19 that does not yet represent a "standard". It is the intention of 20 this specification to propose a few new ideas and openly solicit 21 feedback on their definition and use. While this document might 22 eventually evolve into an RFC the ideas described herein have not yet 23 been broadly implemented and have definitions that will evolve 24 through successive iterations of this draft. 26 Status of This Memo 28 This Internet-Draft is submitted in full conformance with the 29 provisions of BCP 78 and BCP 79. 31 Internet-Drafts are working documents of the Internet Engineering 32 Task Force (IETF). Note that other groups may also distribute 33 working documents as Internet-Drafts. The list of current Internet- 34 Drafts is at http://datatracker.ietf.org/drafts/current/. 36 Internet-Drafts are draft documents valid for a maximum of six months 37 and may be updated, replaced, or obsoleted by other documents at any 38 time. It is inappropriate to use Internet-Drafts as reference 39 material or to cite them other than as "work in progress." 41 This Internet-Draft will expire on November 2, 2014. 43 Copyright Notice 45 Copyright (c) 2014 IETF Trust and the persons identified as the 46 document authors. All rights reserved. 48 This document is subject to BCP 78 and the IETF Trust's Legal 49 Provisions Relating to IETF Documents 50 (http://trustee.ietf.org/license-info) in effect on the date of 51 publication of this document. Please review these documents 52 carefully, as they describe your rights and restrictions with respect 53 to this document. Code Components extracted from this document must 54 include Simplified BSD License text as described in Section 4.e of 55 the Trust Legal Provisions and are provided without warranty as 56 described in the Simplified BSD License. 58 Table of Contents 60 1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 2 61 2. Action Handlers . . . . . . . . . . . . . . . . . . . . . . . 3 62 3. HTTP Action Handler . . . . . . . . . . . . . . . . . . . . . 6 63 4. Embed Action Handler . . . . . . . . . . . . . . . . . . . . 10 64 5. Intent Action Handler . . . . . . . . . . . . . . . . . . . . 12 65 6. Using "service" and "application" objects as action handlers 13 66 7. HTML Form Objects . . . . . . . . . . . . . . . . . . . . . . 14 67 8. Typed Payload Objects . . . . . . . . . . . . . . . . . . . . 15 68 9. URL Template Objects . . . . . . . . . . . . . . . . . . . . 16 69 10. Parameters Object . . . . . . . . . . . . . . . . . . . . . . 17 70 10.1. The Parameter Object . . . . . . . . . . . . . . . . . . 18 71 10.2. Using UrlTemplate and TypedPayload objects as parameter 72 descriptions . . . . . . . . . . . . . . . . . . . . . . 22 73 11. Authentication Object . . . . . . . . . . . . . . . . . . . . 23 74 12. Styles Object . . . . . . . . . . . . . . . . . . . . . . . . 24 75 13. Security Considerations . . . . . . . . . . . . . . . . . . . 26 76 14. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 26 77 15. Normative References . . . . . . . . . . . . . . . . . . . . 26 78 Appendix A. Using Action Handlers From Other Vocabularies . . . 26 79 A.1. Schema.org Actions Proposal . . . . . . . . . . . . . . . 26 80 A.2. Google's "Actions in the Inbox" . . . . . . . . . . . . . 27 81 A.3. Mixing Vocabularies . . . . . . . . . . . . . . . . . . . 28 82 A.4. Example Drawing From Multiple Vocabularies . . . . . . . 29 83 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 31 85 1. Overview 87 The Activity Streams 2.0 [I-D.snell-activitystreams] specification 88 introduces the notion of "actions" that can be associated with 89 objects. Using the "actions" property described in Sections 3.6 and 90 3.6.1 of the Activity Streams 2.0 document, the producer of an object 91 can declare a specific set of verbs appropriate for the object and 92 map each of those to one or more objects ("action handlers") or 93 resources capable of "carrying out" the verb. This document expands 94 on that mechanism by defining and describing a core set of action 95 handler object types. 97 2. Action Handlers 99 An action handler is an Activity Streams 2.0 object whose objectType 100 and member properties instruct a consuming application how to carry 101 out the verb the action handler has been associated with. For 102 instance, given the following example: 104 { 105 "objectType": "note", 106 "displayName": "Title of the note", 107 "content": "This is a simple note.", 108 "actions": { 109 "share": { 110 "objectType": "HttpActionHandler", 111 "url": "http://example.org/share" 112 }, 113 "like": { 114 "objectType": "EmbedActionHandler", 115 "mediaType": "text/plain", 116 "content": "Hello World" 117 } 118 } 119 } 121 The "note" object has two declared actions, "share" and "like". Each 122 of those is associated with one action handler object. The "share" 123 action has a action handler of type "HttpActionHandler", while the 124 "like" action has an "EmbedActionHandler". 126 As illustrated in the example, action handlers are represented as 127 Activity Streams 2.0 objects. All such objects share a common set of 128 base member properties as defined in the following table: 130 +----------+-----------------------------+--------------------------+ 131 | Property | Value | Description | 132 +----------+-----------------------------+--------------------------+ 133 | confirm | Boolean | True if the consuming | 134 | | | application ought to | 135 | | | seek confirmation prior | 136 | | | to using the action | 137 | | | handler to carry out | 138 | | | it's associated action. | 139 | | | Defaults to False. | 140 | context | JSON Object | Contextual information | 141 | | | associated with the | 142 | | | action handler, | 143 | | | represented as a JSON | 144 | | | Object without any | 145 | | | particular structure. | 146 | | | How the context is used | 147 | | | is dependent entirely on | 148 | | | the action handler | 149 | | | definition and on how a | 150 | | | consuming application | 151 | | | chooses to implement the | 152 | | | action handler. | 153 | expects | Link Value | For action handlers with | 154 | | [I-D.snell-activitystreams] | a distinct input | 155 | | | requirement (e.g. | 156 | | | HttpActionHandler), the | 157 | | | expects property | 158 | | | provides a description | 159 | | | of the expected input. | 160 | | | The value is expressed | 161 | | | as either a String | 162 | | | containing a fully | 163 | | | qualified IRI, an | 164 | | | Activity Stream Object, | 165 | | | or an Array of IRI's or | 166 | | | Objects. When multiple | 167 | | | values are provided, | 168 | | | they MUST be considered | 169 | | | as mutually exclusive | 170 | | | alternatives. | 171 | returns | Link Value | For action handlers with | 172 | | [I-D.snell-activitystreams] | a distinct output, the | 173 | | | returns property | 174 | | | provides a description | 175 | | | of the expected output. | 176 | | | The value is expressed | 177 | | | as either a String | 178 | | | containing a fully | 179 | | | qualified IRI, an | 180 | | | Activity Stream Object, | 181 | | | or an Array of IRI's or | 182 | | | Objects. When multiple | 183 | | | values are provided, | 184 | | | they MUST be considered | 185 | | | as mutually exclusive | 186 | | | alternatives. | 187 | auth | Authentication Value | For action handlers with | 188 | | (Section 11) | specific authentication | 189 | | | requirements, the "auth" | 190 | | | property provides | 191 | | | information about the | 192 | | | specific authentication | 193 | | | mechanisms supported. | 194 | requires | Link Value | An optional Link Value | 195 | | [I-D.snell-activitystreams] | whose value(s) describe | 196 | | | features or behaviors an | 197 | | | implementation MUST | 198 | | | support in order to | 199 | | | carry out the action. | 200 | | | Requirements are | 201 | | | designed to be | 202 | | | intentionally open-ended | 203 | | | and will vary depending | 204 | | | on specific Action | 205 | | | Handler type. Any | 206 | | | implementation that does | 207 | | | not support any | 208 | | | specified required | 209 | | | feature MUST ignore the | 210 | | | Action Handler. | 211 | prefers | Link Value | An optional Link Value | 212 | | [I-D.snell-activitystreams] | whose value(s) describe | 213 | | | features or behaviors an | 214 | | | implementation SHOULD | 215 | | | support in order to | 216 | | | carry out the action. | 217 | | | Requirements are | 218 | | | designed to be | 219 | | | intentionally open-ended | 220 | | | and will vary depending | 221 | | | on specific Action | 222 | | | Handler type. Any | 223 | | | implementation that does | 224 | | | not support any | 225 | | | specified preferred | 226 | | | feature MAY ignore the | 227 | | | feature. | 228 +----------+-----------------------------+--------------------------+ 230 This specification defines three specific base types of action 231 handler: 233 o The HTTP Action Handler (Section 3), 235 o The Embed Action Handler (Section 4), and 237 o The Intent Action Handler (Section 5). 239 Implementations are free to use Activity Stream objects of any 240 objectType as an action handler. Consuming applications MAY ignore 241 any object it encounters that use objectTypes that are not recognized 242 or supported as action handlers. Alternatively, the consuming 243 application MAY treat such objects as implied Intent Action Handlers 244 (Section 5). 246 Multiple independent action handlers can be associated with any 247 single verb using a JSON Array. The ordering of objects within such 248 an array is not considered to be significant. 250 For example, in the following, the "share" action has two associated 251 action handlers: 253 { 254 "objectType": "event", 255 "displayName": "Party!", 256 "content": "We're going to party like it's 1999!", 257 "id": "urn:example:events:123", 258 "actions": { 259 "share": [ 260 { 261 "objectType": "HttpActionHandler", 262 "method": "POST", 263 "url": "http://example.org/share-this/123", 264 "target": "DIALOG", 265 "returns": { 266 "objectType": "TypedPayload", 267 "mediaType": "text/html" 268 } 269 }, 270 { 271 "objectType": "EmbedActionHandler", 272 "mediaType": "text/html", 273 "content": "
...
" 274 } 275 ] 276 } 277 } 279 3. HTTP Action Handler 281 An HTTP Action Handler describes an HTTP request/response flow that 282 is used to carry out an action. It is identified using an objectType 283 value of "HttpActionHandler". 285 +----------+-----------------------------------+--------------------+ 286 | Property | Value | Description | 287 +----------+-----------------------------------+--------------------+ 288 | url | Link Value | Specifies the HTTP | 289 | | | or HTTPS URL to | 290 | | | which the HTTP | 291 | | | request is | 292 | | | directed. | 293 | method | HTTP Method String (e.g. "GET", | The HTTP method to | 294 | | "POST", "PUT", etc) | use. Defaults to | 295 | | | "GET" | 296 | target | "DEFAULT" - Consumer defined | Specifies the | 297 | | default; "NONE" - No navigation | intended target of | 298 | | or UI context (e.g. a hidden HTTP | the HTTP action. | 299 | | action that does not result in | This determines | 300 | | the creation or use of a browser | whether the action | 301 | | window); "NEW" - A new navigation | results in a new | 302 | | or UI context (e.g. show the | navigation context | 303 | | results of the HTTP request in a | (e.g. new browser | 304 | | browser window or tab.); | window) or whether | 305 | | "CURRENT" - Reuse the existing | the action is | 306 | | navigation or UI context (e.g. | "hidden". When not | 307 | | show the results of the HTTP | specified, | 308 | | request in an existing browser | defaults to | 309 | | window or tab.); {Other token | "DEFAULT", meaning | 310 | | value} - Any other TOKEN value. | that the consuming | 311 | | Interpretation and support of | application is | 312 | | such extension tokens is | free to determine | 313 | | dependent on the consuming | an appropriate | 314 | | application. Unknown or | target context. | 315 | | unsupported values MUST be | | 316 | | ignored. | | 317 +----------+-----------------------------------+--------------------+ 319 For example: 321 { 322 "objectType": "note", 323 "displayName": "A simple note object", 324 "content": "This is a simple note.", 325 "actions": { 326 "view": { 327 "objectType": "HttpActionHandler", 328 "url": "http://example.org/foo", 329 "method": "GET" 330 } 331 } 332 } 334 As a shortcut, HttpActionHandlers that use the "GET" method and a 335 "DEFAULT" target can be specified using a JSON string containing the 336 absolute URL. For instance: 338 { 339 "objectType": "note", 340 "displayName": "A simple note object", 341 "content": "This is a simple note.", 342 "actions": { 343 "view": "http://example.org/foo" 344 } 345 } 347 In the Activity Streams 2.0 format, the "url" property is defined as 348 a "Link Value", this means that it is possible for the value of the 349 "url" property to be an Activity Stream object that a consuming 350 application can use to resolve the actual target URL. This 351 specification defines a new UrlTemplate (Section 9) objectType 352 specifically intended for such use. 354 The UrlTemplate object can be used within an HTTP Action Handler, for 355 instance, whenever carrying out the HTTP request requires the 356 construction of a new URL that includes variable parameters: 358 { 359 "objectType": "note", 360 "displayName": "A simple note object", 361 "content": "This is a simple note.", 362 "actions": { 363 "review": { 364 "objectType": "HttpActionHandler", 365 "url": { 366 "objectType": "UrlTemplate", 367 "template": "http://example.org/note/123{?rating}", 368 "parameters": { 369 "rating": { 370 "displayName": "Rating", 371 "maxInclusive": 5, 372 "minInclusive": 1, 373 "type": "unsignedInt" 374 } 375 } 376 }, 377 "method": "POST", 378 "target": "NEW" 379 } 380 } 381 } 383 If the intended HTTP request uses the GET method and DEFAULT target, 384 the UrlTemplate object itself can be used directly as the action 385 handler. 387 "GET" HttpActionHandler shortcut using a URL Template: 389 { 390 "objectType": "note", 391 "displayName": "A simple note object", 392 "content": "This is a simple note.", 393 "actions": { 394 "view": { 395 "objectType": "UrlTemplate", 396 "template": "http://example.org/note/{noteid}", 397 "parameters": { 398 "noteid": { 399 "type": "nonNegativeInteger", 400 "totalDigits": 5 401 } 402 } 403 } 404 } 405 } 407 If the HTTP request requires an input payload, the HttpActionHandler 408 object can contain an "expects" property. The value of "expects" is 409 an Activity Streams 2.0 "Link Value" represented either as a simple 410 JSON string containing a fully qualified IRI, an Activity Stream 411 object, or an array of IRI's or Objects. This specification defines 412 a new HtmlForm (Section 7) objectType to be used whenever the input 413 of the HTTP request is an HTML Form POST. A new TypedPayload 414 (Section 8) objectType is defined for use whenever the input is an 415 arbitrary MIME media type. 417 For example, the following describes an HTML Form post with a single 418 "foo" parameter submitted using the "application/x-www-form- 419 urlencoded" format: 421 { 422 "objectType": "note", 423 "displayName": "A simple note object", 424 "content": "This is a simple note.", 425 "actions": { 426 "share": { 427 "objectType": "HttpActionHandler", 428 "method": "POST", 429 "url": "http://example.org/foo", 430 "expects": { 431 "objectType": "HtmlForm", 432 "mediaType": "application/x-www-form-urlencoded", 433 "parameters": { 434 "foo": { 435 "type": "string", 436 "displayName": "Foo Property" 437 } 438 } 439 } 440 } 441 } 442 } 444 4. Embed Action Handler 446 An Embed Action Handler defines static or dynamic content to be 447 visually rendered to carry out an action. Examples of embeds can 448 include static HTML, images, videos, gadgets and applications. It is 449 identified using an objectType value of "EmbedActionHandler". 451 +-----------+--------------+----------------------------------------+ 452 | Property | Value | Description | 453 +-----------+--------------+----------------------------------------+ 454 | url | Link Value | The URL from which to retrieve the | 455 | | | content for this embed. | 456 | content | String | The character based "static" content | 457 | | | to be embeded. The "mediaType" | 458 | | | parameter specifies the MIME media | 459 | | | type of the content. | 460 | mediaType | MIME Media | The MIME Media Type of the embedded | 461 | | Type | content. | 462 | style | Styles | Visual CSS styling hints to apply to | 463 | | Object | the element containing the embedded | 464 | | (Section 12) | content. | 465 | preview | Link Value | A reference to a "preview" | 466 | | | representation of the embedded | 467 | | | content. Typically, this would a URL | 468 | | | to a thumbnail or screenshot image of | 469 | | | the content. | 470 | target | "DEFAULT"; | | 471 | | "INLINE"; | | 472 | | {Other token | | 473 | | value} | | 474 +-----------+--------------+----------------------------------------+ 476 In the following example, the "view" action is associated with an 477 "EmbedActionHandler" containing a static fragment of HTML markup: 479 { 480 "objectType": "note", 481 "displayName": "A simple note object", 482 "content": "This is a simple note.", 483 "actions": { 484 "view": { 485 "objectType": "EmbedActionHandler", 486 "content": "
This is some bit of embedded HTML
", 487 "mediaType": "text/html", 488 "style": { 489 "height": "100px", 490 "width": "100px", 491 "box-shadow": "10px 10px 5px #888888" 492 }, 493 "displayName": "Some embedded content", 494 "preview": "http://example.org/preview/123.jpg" 495 } 496 } 497 } 499 Alternatively, the embedded content can be referenced by URL: 501 { 502 "objectType": "note", 503 "displayName": "A simple note object", 504 "content": "This is a simple note.", 505 "actions": { 506 "view": { 507 "objectType": "EmbedActionHandler", 508 "url": "http://example.org/foo", 509 "mediaType": "text/html" 510 } 511 } 512 } 514 The mediaType parameter specifies the type of content to be embedded. 515 Consuming applications MAY ignore Embed Action Handlers that specify 516 unrecognized or unsupported mediaTypes. 518 Example: 520 { 521 "objectType": "note", 522 "displayName": "A simple note object", 523 "content": "This is a simple note.", 524 "actions": { 525 "view": { 526 "objectType": "EmbedActionHandler", 527 "url": "http://example.org/foo.mpg", 528 "mediaType": "video/mpeg" 529 } 530 } 531 } 533 5. Intent Action Handler 535 An Intent Action Handler provides a generic way for the publisher of 536 an Activity object to tell the consuming application to figure out 537 how to handle the action on it's own. The consumer can, for 538 instance, pass the object off to some other native platform 539 application. It is identified using an objectType value of 540 "IntentActionHandler". 542 For example: 544 { 545 "objectType": "note", 546 "displayName": "A simple note object", 547 "content": "This is a simple note.", 548 "actions": { 549 "share": { 550 "objectType": "IntentActionHandler", 551 "displayName": "Share This", 552 "context": { 553 "foo": "ABC", 554 "bar": 123 555 } 556 } 557 } 558 } 560 6. Using "service" and "application" objects as action handlers 562 The "service" and "application" object are existing objectTypes 563 defined by the Activity Streams 1.0 core schema. While these objects 564 were not originally designed to be used as action handlers, they can 565 be. Specifically, the "service" objectType can be used when the 566 action is to be carried out using some specific third party service 567 interface; the "application" objectType can be used when the action 568 is to be carried out by deferring some some specific native platform 569 application. 571 For example: 573 { 574 "objectType": "note", 575 "displayName": "A simple note object", 576 "content": "This is a simple note.", 577 "actions": { 578 "share": { 579 "objectType": "service", 580 "displayName": "My Sharing Service", 581 "url": "http://share.example.org/api" 582 }, 583 "save": { 584 "objectType": "application", 585 "displayName": "Read this later!", 586 "platform": "android", 587 "id": "123", 588 "url": "http://play.google.com/..." 589 } 590 } 591 } 593 7. HTML Form Objects 595 +------------+----------------+-------------------------------------+ 596 | Property | Value | Description | 597 +------------+----------------+-------------------------------------+ 598 | mediaType | MIME Media | Defaults to "application/x-www- | 599 | | Type | form-urlencoded" | 600 | parameters | Parameters | Defines the HTML form parameters. | 601 | | Object | | 602 | | (Section 10) | | 603 +------------+----------------+-------------------------------------+ 604 For example: 606 { 607 "objectType": "note", 608 "displayName": "A simple note object", 609 "content": "This is a simple note.", 610 "actions": { 611 "review": { 612 "objectType": "HttpActionHandler", 613 "method": "POST", 614 "url": "http://example.org/foo", 615 "expects": { 616 "objectType": "HtmlForm", 617 "mediaType": "application/x-www-form-urlencoded", 618 "parameters": { 619 "foo": { 620 "displayName": "Foo", 621 "type": "string", 622 "placeholder": "Foo" 623 }, 624 "bar": { 625 "type": "string", 626 "value": "Provided Value" 627 } 628 } 629 } 630 } 631 } 632 } 634 Is roughly equivalent to the following HTML form: 636
637 638 639 640 641
643 8. Typed Payload Objects 644 +-----------+-----------------------------+-------------------------+ 645 | Property | Value | Description | 646 +-----------+-----------------------------+-------------------------+ 647 | mediaType | MIME Media Type | The MIME Media Type of | 648 | | | the Payload | 649 | type | Type Value | An optional Type Value | 650 | | [I-D.snell-activitystreams] | that describes the | 651 | | | payloads semantic type. | 652 | schema | Link Value | An optional Link Value | 653 | | [I-D.snell-activitystreams] | whose value(s) describe | 654 | | | the structure of the | 655 | | | payload data. The value | 656 | | | is represented either | 657 | | | as a String with a | 658 | | | fully qualified IRI, an | 659 | | | Activity Stream object, | 660 | | | or an Array of IRIs and | 661 | | | Objects. If multiple | 662 | | | values are provided, | 663 | | | they are to be | 664 | | | considered mutually | 665 | | | exclusive alternatives. | 666 +-----------+-----------------------------+-------------------------+ 668 For example: 670 { 671 "objectType": "note", 672 "displayName": "A simple note object", 673 "content": "This is a simple note.", 674 "actions": { 675 "review": { 676 "objectType": "HttpActionHandler", 677 "method": "POST", 678 "url": "http://example.org/foo", 679 "expects": { 680 "objectType": "TypedPayload", 681 "mediaType": "text/json", 682 } 683 } 684 } 685 } 687 9. URL Template Objects 689 Objects with the "UrlTemplate" object type represent [RFC6570] URL 690 Templates. 692 +------------+-------------------------+----------------------------+ 693 | Property | Value | Description | 694 +------------+-------------------------+----------------------------+ 695 | template | URL Template | The [RFC6570] URL Template | 696 | parameters | Parameters Object | Defines the URL Template | 697 | | (Section 10) | parameters | 698 +------------+-------------------------+----------------------------+ 700 { 701 "objectType": "note", 702 "displayName": "A simple note object", 703 "content": "This is a simple note.", 704 "actions": { 705 "review": { 706 "objectType": "UrlTemplate", 707 "template": "http://example.org/notes/{noteid}", 708 "parameters": { 709 "noteid": { 710 "type": "nonNegativeInteger", 711 "totalDigits": 5 712 } 713 } 714 } 715 } 716 } 718 If the given URL template includes any parameter tokens that do not 719 appear within the "parameters" property, the parameter value type is 720 assumed to be a UTF-8 encoded xsd:string with no maximum length. 722 10. Parameters Object 724 A Parameters Object is used to provide descriptions of the variable 725 inputs of objects such as HTML Forms (Section 7) and URL Templates 726 (Section 9). The object is expressed as a JSON dictionary mapping 727 parameter names to parameter descriptions which take the form of 728 either an XML Schema type name [W3C.REC-xmlschema-2-20041028], an 729 absolute IRI, a parameter object (Section 10.1), or in some limited 730 cases, TypedPayload or UrlTemplate objects. 732 By default, all parameters are assumed to be required. When a 733 parameter is described using an object, the object MAY contain a 734 boolean "required" member. If "required" is false, use of the 735 parameter is assumed to be optional. 737 Using the Parameters Object in UrlTemplate objects: 739 { 740 "objectType": "UrlTemplate", 741 "template": "http://example.org{/foo,bar}" 742 "parameters": { 743 "foo": "string", 744 "bar": { 745 "type": "string", 746 "required": false 747 } 748 } 749 } 751 In this example, both the "foo" and "bar" parameter conform to the 752 XML Schema type "xsd:string". The "foo" parameter is required while 753 the "bar" parameter is optional. 755 Using the Parameters Object in HtmlForm objects: 757 { 758 "objectType": "HtmlForm", 759 "mediaType": "application/x-www-form-urlencoded", 760 "parameters": { 761 "foo": { 762 "displayName": "Foo", 763 "type": "string" 764 }, 765 "bar": { 766 "displayName": "Bar", 767 "type": "string", 768 "required": false 769 } 770 } 771 } 773 10.1. The Parameter Object 775 Parameter objects provide a rich description of a single parameter in 776 a manner that is aligned with the commonly used XML Schema type 777 system [W3C.REC-xmlschema-2-20041028]. 779 +-------------+--------------------------+--------------------------+ 780 | Property | Value | Description | 781 +-------------+--------------------------+--------------------------+ 782 | displayName | Natural Language Value [ | An Activity Streams 2.0 | 783 | | I-D.snell-activitystream | Natural Language Value. | 784 | | s] | | 785 | required | boolean | True if the parameter is | 786 | | | required. Defaults to | 787 | | | true. | 788 | repeated | boolean | True if the parameter | 789 | | | can be repeated zero or | 790 | | | more times. Defaults to | 791 | | | false. | 792 | value | (Any) | Provides a fixed value | 793 | | | for the parameter. When | 794 | | | specified, | 795 | | | implementations MUST use | 796 | | | the specified value. | 797 | default | (Any) | Provides a default value | 798 | | | for the parameter. When | 799 | | | specified, | 800 | | | implementations MUST use | 801 | | | the specified value if | 802 | | | no other value is not | 803 | | | supplied. | 804 | type | XSD [W3C.REC-xmlschema-2 | Identifies the value | 805 | | -20041028] type name or | type using either an XML | 806 | | IRI | Schema [W3C.REC-xmlschem | 807 | | | a-2-20041028] simple | 808 | | | type name or an absolute | 809 | | | IRI. If an | 810 | | | implementation | 811 | | | encounters a type it | 812 | | | does not recognize, the | 813 | | | property MAY be ignored. | 814 | | | When not specified, the | 815 | | | value type is assumed to | 816 | | | be a UTF-8 encoded | 817 | | | "xsd:string". | 818 | enumeration | Array of (Any) | Provides a fixed array | 819 | | | of possible values for | 820 | | | the parameter. When | 821 | | | specified, | 822 | | | implementations MUST use | 823 | | | one of the specified | 824 | | | values. | 825 | minLength | Non-Negative Integer | Specifies the minimum | 826 | | | "unit of length" for the | 827 | | | value. The "unit of | 828 | | | length" depends entirely | 829 | | | on the value type as | 830 | | | specified by the "type" | 831 | | | property. For instance, | 832 | | | For xsd:string, the | 833 | | | length is determined by | 834 | | | the number of | 835 | | | characters; for | 836 | | | xsd:hexBinary, the | 837 | | | length is determined by | 838 | | | the number of encoded | 839 | | | 8-bit octets. | 840 | maxLength | Non-Negative Integer | Specifies the maximum | 841 | | | "unit of length" for the | 842 | | | value. The "unit of | 843 | | | length" depends entirely | 844 | | | on the value type as | 845 | | | specified by the "type" | 846 | | | property. For instance, | 847 | | | For xsd:string, the | 848 | | | length is determined by | 849 | | | the number of | 850 | | | characters; for | 851 | | | xsd:hexBinary, the | 852 | | | length is determined by | 853 | | | the number of encoded | 854 | | | 8-bit octets. | 855 | maxInclusiv | (Any) | A value that is | 856 | e | | considered to be the | 857 | | | inclusive upper bound of | 858 | | | a range of possible | 859 | | | values. This would | 860 | | | typically be used only | 861 | | | with numeric parameters. | 862 | maxExclusiv | (Any) | A value that is | 863 | e | | considered to be the | 864 | | | exclusive upper bound of | 865 | | | a range of possible | 866 | | | values. This would | 867 | | | typically be used only | 868 | | | with numeric parameters. | 869 | minInclusiv | (Any) | A value that is | 870 | e | | considered to be the | 871 | | | inclusive lower bound of | 872 | | | a range of possible | 873 | | | values. This would | 874 | | | typically be used only | 875 | | | with numeric parameters. | 876 | minExclusiv | (Any) | A value that is | 877 | e | | considered to be the | 878 | | | exclusive lower bound of | 879 | | | a range of possible | 880 | | | values. This would | 881 | | | typically be used only | 882 | | | with numeric parameters. | 883 | step | Non-negative Number | Specifies the legal | 884 | | | numeric interval between | 885 | | | acceptable values for | 886 | | | the parameter. The step | 887 | | | value MUST be a number | 888 | | | and MUST conform to the | 889 | | | specified type. For | 890 | | | instance, if type is | 891 | | | "unsignedInt", then | 892 | | | step=2 would indicate | 893 | | | legal values of 0, 2, 4, | 894 | | | 6, and so on. The step | 895 | | | property MAY be ignored | 896 | | | if it's value does not | 897 | | | correspond to the | 898 | | | expected type. | 899 | totalDigits | Non-negative integer | Specifies the maximum | 900 | | | number of digits | 901 | | | (integer and fractional) | 902 | | | that can be included in | 903 | | | numeric values. The | 904 | | | totalDigits property | 905 | | | MUST be ignored if the | 906 | | | value type identified by | 907 | | | the type property is not | 908 | | | a numeric type. | 909 | fractionDig | Non-negative integer | Specifies the maximum | 910 | its | | number of fractional | 911 | | | digits that can be | 912 | | | included in numeric | 913 | | | values. The | 914 | | | fractionDigits property | 915 | | | MUST be ignored if the | 916 | | | value type identified by | 917 | | | the type property is not | 918 | | | a numeric type. | 919 | pattern | String or Array of | One or more Regular | 920 | | Strings | Expressions that | 921 | | | describe the acceptable | 922 | | | structure of the value. | 923 | | | Typically used when the | 924 | | | value is a string. | 925 | | | Multiple patterns are | 926 | | | mutually exclusive | 927 | | | options. That is, the | 928 | | | parameter value is | 929 | | | expected to conform to | 930 | | | at least one of the | 931 | | | given patterns. | 932 | placeholder | Natural Language Value [ | An optional Natural | 933 | | I-D.snell-activitystream | Language Value providing | 934 | | s] | a text hint that | 935 | | | describes the expected | 936 | | | value of the parameter. | 937 +-------------+--------------------------+--------------------------+ 939 Using the Parameter Object in HtmlForm objects: 941 { 942 "objectType": "HtmlForm", 943 "mediaType": "application/x-www-form-urlencoded", 944 "parameters": { 945 "foo": "string", 946 "bar": { 947 "displayName": "Bar", 948 "required": false, 949 "repeated": false, 950 "type": "unsignedInt", 951 "default": 3, 952 "minInclusive": 1, 953 "maxInclusive": 5 954 } 955 } 956 } 958 10.2. Using UrlTemplate and TypedPayload objects as parameter 959 descriptions 961 In certain cases, when the value of a parameter is expected to be 962 either a URI or IRI, the UrlTemplate objectType (Section 9) MAY be 963 used as the parameter description. In such cases, the "required", 964 "repeated", "default" and "placeholder" properties from the Parameter 965 objectType (Section 10.1) can be used as additional properties within 966 the UrlTemplate object. 968 For example: 970 { 971 "objectType": "HtmlForm", 972 "mediaType": "application/x-www-form-urlencoded", 973 "parameters": { 974 "foo": "http://example.org/FooProperty", 975 "bar": { 976 "objectType": "UrlTemplate", 977 "template": "http://example.org{/baz}", 978 "displayName": "Bar", 979 "required": false, 980 "repeated": false 981 } 982 } 983 } 985 Likewise, when the value of a parameter is expected to be an instance 986 of a specific MIME media type, the TypedPayload objectType 987 (Section 8) can be used. 989 { 990 "objectType": "HtmlForm", 991 "mediaType": "multipart/form-data", 992 "parameters": { 993 "file": { 994 "objectType": "TypedPayload", 995 "mediaType": "image/*", 996 "repeated": true 997 } 998 } 999 } 1001 11. Authentication Object 1003 An Authentication Object is used by Action Handlers that require 1004 specific authentication options to be supported in order to carry out 1005 the Action. The object is expresed as a JSON dictionary mapping 1006 authentication schema labels to JSON dictionaries that provide a 1007 specific description of properties and requirements specific to the 1008 scheme. 1010 Example Authentication details: 1012 { 1013 "objectType": "note", 1014 "displayName": "A simple note object", 1015 "content": "This is a simple note", 1016 "actions": { 1017 "view": { 1018 "objectType": "HttpActionHandler", 1019 "method": "GET", 1020 "url": "http://example.org/notes/1", 1021 "auth": { 1022 "basic": { 1023 "realm": "http://example.org" 1024 }, 1025 "oauth": { 1026 "scopes": [ 1027 "some.oauth.scope", 1028 "another.oauth.scope" 1029 ] 1030 } 1031 } 1032 } 1033 } 1034 } 1036 This specification does not define the authentication schemes or 1037 their associated properties. Unrecognized authentication schemes MAY 1038 be ignored. However, if an implementation fails to recognize any of 1039 the authentication schemes specified by an Action Handler, it might 1040 not be possible to successfully carry out the Action. 1042 12. Styles Object 1044 A Styles Object is used by EmbedActionHandlers to provide CSS style 1045 hints for the container within which embedded content is to be 1046 displayed. The object is expressed as either a single JSON 1047 dictionary object mapping CSS property names to appropriate CSS 1048 values, or an array of JSON dictionary objects. An optional "media" 1049 member can be included within the dictionary providing a CSS Media 1050 Query. 1052 Example style hints: 1054 { 1055 "objectType": "note", 1056 "displayName": "A simple note object", 1057 "content": "This is a simple note.", 1058 "actions": { 1059 "view": { 1060 "objectType": "EmbedActionHandler", 1061 "content": "Some plain text content", 1062 "mediaType": "text/plain", 1063 "style": { 1064 "height": "100px", 1065 "width": "100px", 1066 "box-shadow": "10px 10px 5px #888888" 1067 } 1068 } 1069 } 1070 } 1072 Multiple style hints for specific media query targets: 1074 { 1075 "objectType": "note", 1076 "displayName": "A simple note object", 1077 "content": "This is a simple note.", 1078 "actions": { 1079 "view": { 1080 "objectType": "EmbedActionHandler", 1081 "content": "Some plain text content", 1082 "mediaType": "text/plain", 1083 "style": [ 1084 { 1085 "media": "print", 1086 "height": "100px", 1087 "width": "100px", 1088 "box-shadow": "10px 10px 5px #888888" 1089 }, 1090 { 1091 "media": "screen and (orientation: landscape)", 1092 "height": "100px", 1093 "width": "100px", 1094 "box-shadow": "10px 10px 5px #888888" 1095 } 1096 ] 1097 } 1098 } 1099 } 1101 13. Security Considerations 1103 TBD 1105 14. IANA Considerations 1107 TBD 1109 15. Normative References 1111 [I-D.snell-activitystreams] 1112 Snell, J., "JSON Activity Streams 2.0", draft-snell- 1113 activitystreams-07 (work in progress), April 2014. 1115 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1116 Requirement Levels", BCP 14, RFC 2119, March 1997. 1118 [RFC6570] Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., 1119 and D. Orchard, "URI Template", RFC 6570, March 2012. 1121 [W3C.REC-xmlschema-2-20041028] 1122 Biron, P. and A. Malhotra, "XML Schema Part 2: Datatypes 1123 Second Edition", World Wide Web Consortium Recommendation 1124 REC-xmlschema-2-20041028, October 2004, 1125 . 1127 Appendix A. Using Action Handlers From Other Vocabularies 1129 The Activity Streams 2.0 Actions mechanism is specifically designed 1130 to allow Action Handlers from multiple vocabularies. 1132 A.1. Schema.org Actions Proposal 1134 Based on http://www.w3.org/wiki/images/b/b9/Actionsinschema.org.pdf: 1136 { 1137 "objectType": "video", 1138 "displayName": "A simple note object", 1139 "content": "This is a simple note.", 1140 "actions": { 1141 "watch": [ 1142 { 1143 "objectType": "http://schema.org/WebPageHandler", 1144 "url": "http://movies.example.com/player?id=123" 1145 }, 1146 { 1147 "objectType": "http://schema.org/AndroidHandler", 1148 "url": "http://movies.example.com/player?id=123", 1149 "package": "com.movies" 1150 } 1151 ] 1152 } 1153 } 1155 A.2. Google's "Actions in the Inbox" 1157 Based on https://developers.google.com/gmail/actions/reference/ 1158 review-action: 1160 { 1161 "objectType": "note", 1162 "displayName": "A simple note object", 1163 "content": "This is a simple note.", 1164 "actions": { 1165 "review": { 1166 "objectType": "http://schema.org/ReviewAction", 1167 "review": { 1168 "objectType": "http://schema.org/Review", 1169 "itemReviewed": { 1170 "objectType": "http://schema.org/FoodEstablishment", 1171 "name": "Joe's Diner" 1172 }, 1173 "reviewRating": { 1174 "objectType": "http://schema.org/Rating", 1175 "bestRating": "5", 1176 "worstRating": "1" 1177 } 1178 }, 1179 "handler": { 1180 "objectType": "http://schema.org/HttpActionHandler", 1181 "url": "http://reviews.com/review?id=123", 1182 "requiredProperty": { 1183 "objectType": "http://schema.org/Property", 1184 "name": "review.reviewRating.ratingValue" 1185 }, 1186 "method": "http://schema.org/HttpRequestMethod/POST" 1187 } 1188 } 1189 } 1190 } 1192 A.3. Mixing Vocabularies 1193 { 1194 "objectType": "video", 1195 "displayName": "A simple note object", 1196 "content": "This is a simple note.", 1197 "actions": { 1198 "watch": [ 1199 { 1200 "objectType": "HttpActionHandler", 1201 "url": "http://movies.example.com/player?id=123", 1202 "target": "NEW" 1203 }, 1204 { 1205 "objectType": "http://schema.org/AndroidHandler", 1206 "url": "http://movies.example.com/player?id=123", 1207 "package": "com.movies" 1208 } 1209 ] 1210 } 1211 } 1213 A.4. Example Drawing From Multiple Vocabularies 1215 { 1216 "objectType": "video", 1217 "displayName": "A Movie!", 1218 "displayName": "A simple note object", 1219 "content": "This is a simple note.", 1220 "actions": { 1221 "watch": [ 1222 { 1223 "objectType": "EmbedActionHandler", 1224 "displayName": "HD", 1225 "mediaType": "video/mpeg", 1226 "url": "http://cdn.example.org?id=123amp;fmt=HD", 1227 }, 1228 { 1229 "objectType": "EmbedActionHandler", 1230 "displayName": "SD", 1231 "mediaType": "video/mpeg", 1232 "url": "http://cdn.example.org?id=123&fmt=SD", 1233 }, 1234 { 1235 "objectType": "application", 1236 "displayName": "Watch on Netflix", 1237 "url": "http://netflix.com..." 1238 } 1239 ], 1240 "like": { 1241 "objectType": "EmbedActionHandler", 1242 "mediaType": "text/html", 1243 "url": "http://www.facebook.com/plugins/like.php...", 1244 "style": { 1245 "width": "150px", 1246 "height": "50px" 1247 } 1248 }, 1249 "share": [ 1250 { 1251 "objectType": "HttpActionHandler", 1252 "displayName": "Twitter", 1253 "url": "https://twitter.com/share?url=...", 1254 "target": "DIALOG" 1255 }, 1256 { 1257 "objectType": "HttpActionHandler", 1258 "displayName": "Facebook", 1259 "url": "https://www.facebook.com/sharer/sharer.php?u=...", 1260 "target": "DIALOG" 1261 } 1262 ], 1263 "save": [ 1264 { 1265 "objectType": "service", 1266 "id": "http://getpocket.com", 1267 "displayName": "Pocket", 1268 "context": { 1269 "url": "http://example.org/movie?id=123", 1270 "title": "A Movie!", 1271 "tags": "foo, bar, baz" 1272 } 1273 }, 1274 { 1275 "objectType": "service", 1276 "id": "http://instapaper.com", 1277 "displayName": "Instapaper", 1278 "context": { 1279 "url": "http://example.org/movie?id=123", 1280 "title": "A Movie!", 1281 "selection": "An action movie!" 1282 } 1283 } 1284 ], 1285 "review": { 1286 "objectType": "HttpActionHandler", 1287 "displayName": "Rate this movie!", 1288 "url": "http://review.example.org/movie?id=123", 1289 "method": "POST", 1290 "expects": { 1291 "objectType": "HtmlForm", 1292 "mediaType": "application/x-www-form-urlencoded", 1293 "parameters": { 1294 "rating": { 1295 "maxInclusive": 5, 1296 "minInclusive": 0, 1297 "fractionDigits": 2, 1298 "totalDigits": 3 1299 "type": "float", 1300 "displayName": "Rating" 1301 }, 1302 "comments": { 1303 "displayName": "Comments", 1304 "type": "string", 1305 "required": false 1306 } 1307 } 1308 } 1309 } 1310 } 1311 } 1313 Authors' Addresses 1315 James M Snell 1316 IBM 1318 Email: jasnell@gmail.com 1320 Matthew Marum 1321 SugarCRM 1323 Email: mgmarum@gmail.com