superagent-d2l-session-auth is a JavaScript plugin designed to integrate D2L (Brightspace) session authentication with `superagent` HTTP requests. It acts as a `superagent` middleware, automatically adding the necessary D2L authentication headers to outbound requests by leveraging the `frau-jwt` library internally. The current stable version is 2.0.1, which includes a fix for `trustedHost` casing sensitivity. While specific release cadence is not explicitly stated, the project appears to be actively maintained by Brightspace, with updates addressing functionality and compatibility. Its primary differentiator is its specialized function within the Brightspace ecosystem, providing a streamlined way to handle D2L session-based authentication for applications using `superagent`, particularly within iframed contexts.
npm install superagent-d2l-session-authVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize the `superagent-d2l-session-auth` plugin and attach it to a `superagent` request for D2L API interaction.
Ensure `superagent` is installed as a direct dependency in your project: `npm install superagent` or `yarn add superagent`.
Transition to using the standard D2L session authentication flow provided by the plugin, which leverages `frau-jwt` for token management.
Upgrade to version `1.0.1` or newer. If upgrading is not possible, ensure the `trustedHost` option exactly matches the case of the target D2L host.
For CommonJS environments, use `const auth = require('superagent-d2l-session-auth')()`. For ESM, ensure your project is configured for `type: module` in `package.json` or use a bundler.Run `npm install superagent` or `yarn add superagent` to add `superagent` to your project's dependencies.
Call the imported `auth` function to get the plugin instance: `const auth = require('superagent-d2l-session-auth')()` or `import createAuth from 'superagent-d2l-session-auth'; const auth = createAuth();`.Use ESM `import` syntax: `import createAuth from 'superagent-d2l-session-auth'; const auth = createAuth();`.
Use CommonJS `require()` syntax: `const auth = require('superagent-d2l-session-auth')();`.