Middleware function for wrapping a window.Request object with Brightspace (D2L) authentication for use with d2l-fetch. Current stable version is 1.9.1. This package is specifically designed for D2L/Brightspace ecosystems, providing seamless integration with their authentication system for fetch requests. It offers two variants: a standard auth middleware and a framed version for iFramed Free Range Applications (iFRA). Release cadence follows semantic-release, triggered by `fix:` and `feat:` prefixed commits. Key differentiators: handles D2L-specific auth tokens and headers, works with both top-level and iframed contexts.
npm install d2l-fetch-authVerified import paths — ran on the pinned version, not inferred.
Shows how to import and use the auth middleware with d2l-fetch to make authenticated requests.
If your app runs in an iframe, use `'d2l-fetch-auth/d2l-fetch-auth-framed.js'`.
Call `d2lfetch.use({name: 'auth', fn: auth})` after importing.Upgrade to version 1.0.0 or later.
Ensure d2l-fetch is installed and imported before using d2l-fetch-auth.
Update HTML script tags to use `type="module"` and the new import paths.
Use `import auth from 'd2l-fetch-auth/d2l-fetch-auth.js';`
Use the full path ending with '.js': `import auth from 'd2l-fetch-auth/d2l-fetch-auth.js';`
Import d2l-fetch first: `import d2lfetch from 'd2l-fetch';`
Call `d2lfetch.use({name: 'auth', fn: auth});` after importing the correct auth middleware for your context.