npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

caccl-canvas-partial-simulator

v2.2.17

Published

Partially simulates a Canvas instance, handling OAuth token exchanges and forwarding API requests

Downloads

120

Readme

caccl-canvas-partial-simulator

Partially simulates a Canvas instance, handling OAuth token exchanges and forwarding API requests.

As an LTI app developer, you want to be able to test your app, simulating the process of launching your app and running through the oauth2 handshake to approve your Canvas app and get a Canvas access token on behalf of the user. In many settings, Canvas is managed by central IT and is surrounded by protocol and policy. This often makes it slow or difficult to add test apps to the list of approved Canvas integrations. Usually, you'll need to get every single development instance of your app approved to interact with Canvas. Finally, when developing on localhost, for your app to go through the oauth2 handshake, Canvas would need to have localhost set as an approved integration. This is obviously a terrible idea.

To remedy this situation, we've created this partial Canvas simulator. It simulates the oauth endpoints and makes it easy to simulate LTI course navigation launches. For all other Canvas requests (API, for example), we just forward those requests to your actual Canvas instance. In this way, you can test your LTI app on a real Canvas instance, without needing credentials and approval for your app.

All you need to get started is an accessToken (that will be returned from the oauth2 handshake) and a real canvasHost (the real Canvas instance we will forward non-oauth requests to).

1. Set up /config/devEnvironment.js

Create a file /config/devEnvironment.js and add it to your .gitignore. The /config folder should be placed in the root directory of your project.

Required: add basic parameters

module.exports = {
    canvasHost: 'canvas.harvard.edu', // The hostname for your Canvas instance
    courseId: 473829, // The Canvas courseId for your sandbox course
    instructorAccessToken: '1589~30ma90294...', // An access token for an instructor in the sandbox
}

Optional: add students and/or TAs

With just the basic parameters, you can only simulate LTI launches as an instructor. To launch as students or TAs, add additional parameters:

module.exports = {
    ...
    taAccessTokens: [
        '1589~n85029kr83...', // An access token for a TA in the sandbox
        '1589~66735hjs08...', // An access token for a TA in the sandbox
        '1589~pbhsd8tha0...', // An access token for a TA in the sandbox
    ],
    studentAccessTokens: [
        '1589~0bn485039x...', // An access token for a student in the sandbox
        '1589~phha0527nd...', // An access token for a student in the sandbox
        '1589~mxaq28df9s...', // An access token for a student in the sandbox
    ],
};

You can include tas, students, or both. Each list can have as many access tokens in it as you want.

Optional: add the app title

To make everything work, we add a test LTI app to your sandbox course. This app won't visibly show up anywhere in your sandbox. Usually, we call that "CACCL Simulated App," but if you want the test app to have a different name in the Canvas app list, add it as a parameter:

module.exports = {
    ...
    appName: 'My App Name',
};

Optional: add custom launch parameters

To include specific launch parameters in every LTI launch request, include a customParams map in your devEnvironment.json file:

module.exports = {
    ...
    customParams: {
        "name": "value",
        "anotherName": "anotherValue"
    },
};

Optional: add custom launch paths

Some apps don't get launched via the / path. This is an unusual case, but nevertheless, it is supported by caccl. To include custom launch paths, simply include them in a list:

module.exports = {
    ...
    customLaunchPaths: [
        {
            "name": "Cat Video Player",
            "path": "/videos/cats"
        },
        {
            "name": "Desserts Video Player",
            "path": "/videos/desserts"
        }
    ],
};

2. Start the Simulated Canvas Instance

If your app was created using npm init caccl...

From the root folder of your project, just run:

npm run dev:canvas

Follow instructions in terminal.

Otherwise...

  1. Set your app's client id to client_id and its client secret to client_secret. These are your app's developerCredentials, not installationCredentials.

  2. Set your app's consumer key to consumer_key and its consumer secret to consumer_secret. These are your app's installationCredentials.

  3. Set your app's canvasHost to localhost:8088.

  4. Write a script to start the simulator, then run your script:

    require('caccl-canvas-partial-simulator');
  5. Follow instructions in terminal.