File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33All notable changes to this project will be documented in this file.
44
5+ ## [ 1.0.42] - 09/28/19
6+
7+ Added support for authenticity tokens (for requests sent directly from Canvas pages)
8+
59## [ 1.0.39] - 09/27/19
610
711Fixed batch Gradebook Column entry update endpoint.
Original file line number Diff line number Diff line change @@ -60,6 +60,8 @@ class EndpointCategory {
6060 * @param {function } [uncache=create new uncache function] - A function that
6161 * takes paths and a response object, uncaches those paths, then resolves
6262 * to the response object
63+ * @param {string } [config.authenticityToken] - An authenticity token
64+ * to add to all requests no matter what (cannot be overridden)
6365 */
6466 constructor ( oldConfig = { } , Subclass ) {
6567 const config = this . _preProcessParams ( oldConfig ) ;
@@ -89,6 +91,7 @@ class EndpointCategory {
8991 cache : config . cache ,
9092 uncache : config . uncache ,
9193 api : config . api ,
94+ authenticityToken : config . authenticityToken ,
9295 defaults : {
9396 accessToken : config . accessToken ,
9497 itemsPerPage : config . itemsPerPage ,
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ const preProcessParams = require('./helpers/preProcessParams');
2626 * method is GET and cache is included
2727 * @param {function } [sendRequest=caccl-send-request instance] - a custom
2828 * function that sends https requests (we recommend not including this)
29+ * @param {string } [authenticityToken] - An authenticity token
30+ * to add to all requests no matter what (cannot be overridden)
2931 * @param {string }
3032 */
3133module . exports = ( config = { } ) => {
@@ -40,6 +42,7 @@ module.exports = (config = {}) => {
4042 numRetries,
4143 cache,
4244 uncache,
45+ authenticityToken,
4346 } = config ;
4447
4548 // Set up sendRequest
@@ -88,6 +91,7 @@ module.exports = (config = {}) => {
8891 params,
8992 itemsPerPage,
9093 accessToken,
94+ authenticityToken,
9195 } ) ;
9296
9397 // We are using the cached value. Keep note of this
Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ const _recursivelyExcludeParams = (obj) => {
4949 * @param {number } itemsPerPage - the number of items per page. Only valid for
5050 * GET requests
5151 * @param {string } [accessToken] - the Canvas access token to add to params
52+ * @param {string } [authenticityToken] - An authenticity token
53+ * to add to all requests no matter what (cannot be overridden)
5254 * @param {object } [params={}] - the original https parameters of the request
5355 * @return {object } pre-processed request parameters
5456 */
@@ -63,6 +65,11 @@ module.exports = (config) => {
6365 newParams . access_token = config . accessToken ;
6466 }
6567
68+ // Add authenticity token
69+ if ( config . authenticityToken ) {
70+ newParams . authenticity_token = config . authenticityToken ;
71+ }
72+
6673 // Set up number of entries per page
6774 if ( config . method === 'GET' && ! newParams . per_page ) {
6875 newParams . per_page = config . itemsPerPage ;
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ const genVisitEndpoint = require('./genVisitEndpoint');
2727 * passes through a response, or just passes through a response if not caching
2828 * @param {object } api - Top level instance of endpoints/Endpoints.js that
2929 * the EndpointCategory we're adding an endpoint to is an ancestor of
30+ * @param {string } [authenticityToken] - An authenticity token
31+ * to add to all requests no matter what (cannot be overridden)
3032 * @param {string } [defaults.accessToken] - a default access token to apply to
3133 * all requests
3234 * @param {number } [defaults.itemsPerPage=100] - the default number of pages to
@@ -47,6 +49,7 @@ module.exports = (config = {}) => {
4749 uncache,
4850 action,
4951 requiredParams,
52+ authenticityToken,
5053 } = config ;
5154 const defaults = ( config . defaults || { } ) ;
5255
@@ -85,6 +88,7 @@ module.exports = (config = {}) => {
8588 cache,
8689 uncache,
8790 canvasHost,
91+ authenticityToken,
8892 accessToken : (
8993 options . accessToken
9094 || defaults . accessToken
Original file line number Diff line number Diff line change @@ -34,5 +34,7 @@ const API = require('./endpoints/API');
3434 * @param {number } [config.itemsPerPage=100] - Number of items to
3535 * request on a get request. Can be overridden for an individual request by
3636 * including numPerPage option
37+ * @param {string } [config.authenticityToken] - An authenticity token
38+ * to add to all requests no matter what (cannot be overridden)
3739 */
3840module . exports = API ;
You can’t perform that action at this time.
0 commit comments