From dfa3a2fded22ce82695255dfde3d2634967878ab Mon Sep 17 00:00:00 2001 From: cvm Date: Wed, 1 May 2024 13:20:02 -0300 Subject: [PATCH] release(5.9.5): Dynamic registration improvements --- docs/changelog.md | 7 +++++++ docs/dynamicregistration.md | 27 +++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index 75cc499..68bd5dc 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -9,6 +9,13 @@ ### CHANGELOG +#### V5.9.5 +> 2024-05-01 +> - A few improvements to dynamic registration. +> - Fixed the regular LTI launch message type. This was not causing any issues, as the regular launch is always implied when performing dynamic registration. +> - Added ability to modify dynamic registration options when creating a custom handler. Thank you @pfgray for the contribution! + + #### V5.9.4 > 2024-04-10 > - Updated dependencies. diff --git a/docs/dynamicregistration.md b/docs/dynamicregistration.md index c731191..96d2b11 100644 --- a/docs/dynamicregistration.md +++ b/docs/dynamicregistration.md @@ -123,6 +123,7 @@ The registration can be finalized by calling the `lti.DynamicRegistration.regist The following example is a representation of the default Dynamic Registration flow: + ```javascript lti.onDynamicRegistration(async (req, res, next) => { try { @@ -138,6 +139,32 @@ lti.onDynamicRegistration(async (req, res, next) => { ``` +You can also pass a third parameter to `lti.DynamicRegistration.register` containing overrides for the default dynamic registration options. + +The following example is a representation of the default Dynamic Registration flow with added custom parameters: + + +```javascript +lti.onDynamicRegistration(async (req, res, next) => { + try { + if (!req.query.openid_configuration) return res.status(400).send({ status: 400, error: 'Bad Request', details: { message: 'Missing parameter: "openid_configuration".' } }) + const message = await lti.DynamicRegistration.register(req.query.openid_configuration, req.query.registration_token, { + 'https://purl.imsglobal.org/spec/lti-tool-configuration': { + custom_parameters: { + 'custom1': 'value1', + 'custom2': 'value2' + } + } + }) + res.setHeader('Content-type', 'text/html') + res.send(message) + } catch (err) { + if (err.message === 'PLATFORM_ALREADY_REGISTERED') return res.status(403).send({ status: 403, error: 'Forbidden', details: { message: 'Platform already registered.' } }) + return res.status(500).send({ status: 500, error: 'Internal Server Error', details: { message: err.message } }) + } +}) +``` + ### Moodle LMS Follow the steps bellow to use the Dynamic Registration Service with the Moodle LMS: diff --git a/package.json b/package.json index c20f8b1..4fcb13a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ltijs", - "version": "5.9.4", + "version": "5.9.5", "description": "Easily turn your web application into a LTI 1.3 Learning Tool.", "main": "index.js", "engineStrict": true,