Comparing version 1.0.1 to 1.0.2
13
index.js
@@ -53,6 +53,6 @@ const Validator = require('./Validator'); | ||
* @param {string} [authorizePath] - the authorization path as set up by | ||
* caccl-token-manager. Only valid if disableAuthorizeOnLaunch is falsy | ||
* caccl-authorizer. Only valid if disableAuthorizeOnLaunch is falsy | ||
* @param {boolean} [disableAuthorizeOnLaunch] - if falsy, redirects to | ||
* authorizePath after launch is validated and parsed (and includes | ||
* redirectToAfterLaunch) as the 'next' link so that caccl-token-manager | ||
* redirectToAfterLaunch) as the 'next' link so that caccl-authorizer | ||
* redirects to redirectToAfterLaunch after finishing authorization | ||
@@ -67,4 +67,9 @@ */ | ||
// Required credentials weren't included | ||
throw new Error('CACCL LTI Manager can\'t be initialized without installationCredentials of the form: { consumer_key, consumer_secret }!'); | ||
throw new Error('CACCL LTI can\'t be initialized without installationCredentials of the form: { consumer_key, consumer_secret }!'); | ||
} | ||
if (!config.app) { | ||
throw new Error('CACCL LTI can\'t be initialized without an express app.'); | ||
} | ||
// Create validator | ||
@@ -146,3 +151,3 @@ const validator = new Validator({ | ||
// Save current user id for caccl-token-manager | ||
// Save current user id for caccl-authorizer | ||
req.session.currentUserCanvasId = req.session.launchInfo.userId; | ||
@@ -149,0 +154,0 @@ |
{ | ||
"name": "caccl-lti", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "LTI launch validator for IMS-LTI standard launches.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,4 +0,6 @@ | ||
# caccl-lti-manager | ||
# caccl-lti | ||
Validates and parses LTI launch requests. | ||
With caccl-lti, it's easy to enable LTI launches from Canvas. We'll take care of parsing and verifying the validity of launch requests. | ||
## Part of the CACCL library | ||
@@ -10,1 +12,88 @@ **C**anvas | ||
**L**ibrary | ||
## Quickstart | ||
Quickstart: | ||
```js | ||
const initLTI = require('caccl-lti'); | ||
initLTI({ | ||
app: /* express app with express-sessions enabled */, | ||
installationCredentials: /* { consumer_key, consume_secret }*/, | ||
}); | ||
``` | ||
The app will now be set up to accept LTI launches at `/launch`. See "Launch Parsing" below to find info on parsed launches. | ||
## Configuration Options | ||
When initializing caccl-lti, you can pass in many different configuration options to customize caccl-lti's behavior or turn on/off certain functionality. | ||
**Note:** configuration options are _optional_ unless otherwise stated | ||
Config Option | Type | Description | Default/Required | ||
:--- | :--- | :--- | :--- | ||
app | express app | express app to add routes to | **Required** | ||
installationCredentials | object | LTI consumer credentials of form: `{ consumer_key, consumer_secret }` | **Required** | ||
launchPath | string | path to accept launches at (new express POST route added) | /launch | ||
redirectToAfterLaunch | string | path to redirect to after successful launch | same as launchPath | ||
nonceStore | NonceStore (see `/docs`) | a nonce store to use for keeping track of used nonces | memory store | ||
disableAuthorizeOnLaunch | boolean | if false, redirects to authorizePath after launch is validated and parsed (and includes redirectToAfterLaunch) as the 'next link so that caccl-authorizer redirects to redirectToAfterLaunch after finishing authorization | false | ||
authorizePath | string | the authorization path (as set up by caccl-authorizer, required if disableAUthorizeOnLaunch is true | null | ||
## Launch Parsing | ||
Launches are automatically parsed and added to session. To retrieve launch info, see the `req.session.launchInfo` variable, which has the following properties: | ||
For more detailed information, see [Canvas' LTI documentation](https://canvas.instructure.com/doc/api/file.tools_intro.html). | ||
### User Info | ||
Property | Type | Description | ||
:--- | :--- | :--- | ||
userId | number | Canvas user id of the person who launched the app | ||
userLoginId | string | Canvas login id (e.g., university id) | ||
userEmail | string | the user's primary Canvas email (changeable in user's profile) | ||
userFirstName | string | the user's first name | ||
userLastName | string | the user's last name | ||
userFullName | string | the user's full name | ||
userImage | string | link to user's image | ||
isInstructor | boolean | true if the user is an instructor in the launch course | ||
isTA | boolean | true if the user is a teaching assistant in the launch course | ||
isDesigner | boolean | true if the user is a designer in the launch course | ||
isCreditLearner | boolean | true if the user is a for-credit learner (student) in the launch course | ||
isNonCreditLearner | boolean | true if the user is a not-for-credit learner (student) in the launch course | ||
isLearner | boolean | true if the user any type of learner (student) in the launch course | ||
extRoles | string[] | list of extended Canvas roles | ||
roles | string[] | list of basic Canvas roles (outdated) | ||
locale | string | user locale (e.g., "en") | ||
#### Launch Info | ||
Property | Type | Description | ||
:--- | :--- | :--- | ||
timestamp | number | launch timestamp (ms) | ||
contextId | string | LTI launch context | ||
launchPresentationTarget | string | LTI launch presentation target (e.g., "iframe") | ||
iframeWidth | number | iframe width (if applicable) | ||
iframeHeight | number | iframe height (if applicable) | ||
returnURL | string | LTI return URL | ||
launchAppTitle | string | the title of the resource link (app title) | ||
customParams | object | mapping (key => value) listing all custom launch parameters and their values | ||
#### Course Info | ||
Property | Type | Description | ||
:--- | :--- | :--- | ||
courseId | number | Canvas course id of the launch course | ||
enrollmentState | string | Canvas enrollment state (e.g., "active") | ||
#### Canvas Info | ||
Property | Type | Description | ||
:--- | :--- | :--- | ||
contextLabel | string | the name of the launch context (e.g., course name) | ||
canvasHost | string | host of the launch Canvas instance | ||
workflowState | string | Canvas workflow status (e.g., "active") |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164817
17
3868
98