node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

158
server/node_modules/koa-passport/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,158 @@
# Changelog
## 6.0.0
Potentially breaking change:
- change `logout` signature from `(options, callback) => void` to `(options) => Promise<void>` #188
## 5.0.0
- upgrade `passport` to 0.6
## 4.1.4
- add `ip` to the Koa `ctx` delegates #157
## 4.1.3
- add `set` to `req` to imporve compatibility with more passport strategies #128
## 4.1.1
- add `protocol` to the Koa `ctx` delegates #121
## 4.1.0
- add `res` to `req` #114
- add `send()` method to `req` #114
## 4.0.1
- add `params` to `req` #110
## 4.0.0
- upgrade `passport` to 0.4
- add `ctx` getter to `req` #89
## 3.0.0
- remove `ctx.passport` and save state variables (like `_passport` and `user`) in `ctx.state` instead
- prevent `passport` from monkey patching `http.IncomingMessage`
- change arguments from custom authentication callbacks from `user, info, status` to `err, user, info, status` (`err` added) to be consistent with passport
- add support for `assignProperty` option (#86)
## 2.2.2
- remove `ctx.req.user` deprecation warning for now #66
## 2.2.1
- fix middleware to properly catch promise errors #63
## 2.2.0
- move `user` into `ctx.state`
- user in `ctx.req.user` is deprecated and will removed eventually
## 2.1.0
- export KoaPassport as an alternative to the by default exported singleton
## 2.0.1
- use strict
## 2.0.0
- use promises rather than generators for `koa@2.x` compatibility
- use some es6 features
## 1.3.0
- export KoaPassport as an alternative to the by default exported singleton
## 1.2.0
- upgrade `passport` to `^0.3.0`
## 1.1.5
- fix to not throw if `req.user` is already defined
- upgrade dependencies
## 1.1.4
- add `status` argument to authentication callback
## 1.1.3
- make internal `req` mock less error-prone
## 1.1.2
- redirect `req.app.get('trust proxy')` to Koa's `app.proxy` (#22)
## 1.1.1
- add `authInfo` to request mock
## 1.1.0
Make the `req` mock to inherit from Koa's `request` object before adding delegates for Node's request and Koa's context to it. This makes custom properties/methods added to Koa's request available to passport and its authentication strategies.
## 1.0.1
- add `flash` to the `req` mock
## 1.0.0
Using ES6 Proxy currently breaks debugging (see #17). Until this is fixed, the Proxy approach got replace by delegating a whitelist of possible used properties/methods to either Node's request, Koa's context or Koa's request.
Note: There is nothing special about this being `1.0.0`. The major version bump is just because the update could possible break something.
## 0.5.1
- re-add authenticated user to `req.user`
## 0.5.0
- internal improvements (neither modify Node's request nor Koa's request object by mocking the `req` object with a proxy that forwards reads to either Node's request object, Koa's request object or Koa's context)
- `--harmony-proxies` has to enabled now
## 0.4.0
- Add support for custom authentication methods, e.g.:
```js
public.post('/login', function*(next) {
var ctx = this
yield* passport.authenticate('local', function*(err, user, info) {
if (err) throw err
if (user === false) {
ctx.status = 401
ctx.body = { success: false }
} else {
yield ctx.login(user)
ctx.body = { success: true }
}
}).call(this, next)
})
```
## 0.3.2
- add generator function names for Koa debugging purposes
## 0.3.1
- make ctx.login() yieldable
## 0.3.0
- adapt recent Koa API changes
## 0.2.0
- `passport 0.2.x compatibility

20
server/node_modules/koa-passport/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2014 Markus Ast
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

51
server/node_modules/koa-passport/README.md generated vendored Normal file
View File

@@ -0,0 +1,51 @@
# koa-passport
[Passport](https://github.com/jaredhanson/passport) middleware for Koa
[![NPM][npm]](https://npmjs.org/package/koa-passport)
koa-passport version | passport version | koa version | branch
--------------------- | ---------------- | ------------| ------
6.x, 5.x | 6.x, 5.x | 2.x | main
4.x | 4.x | 2.x | v3.x
3.x, 2.x | 2.x | 2.x | v2.x
1.x | 1.x | 1.x | v1.x
## Usage
```js
// body parser
const bodyParser = require('koa-bodyparser')
app.use(bodyParser())
// Sessions
const session = require('koa-session')
app.keys = ['secret']
app.use(session({}, app))
const passport = require('koa-passport')
app.use(passport.initialize())
app.use(passport.session())
```
[Example Application](https://github.com/rkusa/koa-passport-example)
Passport's values and methods are exposed as follows:
```js
app.use(async ctx => {
ctx.isAuthenticated()
ctx.isUnauthenticated()
await ctx.login()
ctx.logout()
ctx.state.user
})
```
## License
[MIT](LICENSE)
[npm]: http://img.shields.io/npm/v/koa-passport.svg
[dependencies]: http://img.shields.io/david/rkusa/koa-passport.svg
[travis]: https://travis-ci.org/rkusa/koa-passport.svg?branch=master

210
server/node_modules/koa-passport/lib/framework/koa.js generated vendored Normal file
View File

@@ -0,0 +1,210 @@
'use strict'
/**
* Module dependencies.
*/
const passport = require('passport')
/**
* Passport's default/connect middleware.
*/
const _initialize = require('passport/lib/middleware/initialize')
const _authenticate = require('passport/lib/middleware/authenticate')
const createReqMock = require('./request').create
/**
* Passport's initialization middleware for Koa.
*
* @return {GeneratorFunction}
* @api private
*/
function initialize(passport) {
const middleware = promisify(_initialize(passport))
return function passportInitialize(ctx, next) {
// koa <-> connect compatibility:
const userProperty = passport._userProperty || 'user'
// check ctx.req has the userProperty
if (!ctx.req.hasOwnProperty(userProperty)) {
Object.defineProperty(ctx.req, userProperty, {
enumerable: true,
get: function() {
return ctx.state[userProperty]
},
set: function(val) {
ctx.state[userProperty] = val
}
})
}
// create mock object for express' req object
const req = createReqMock(ctx, userProperty)
// add Promise-based login method
const login = req.login
ctx.login = ctx.logIn = function(user, options) {
return new Promise((resolve, reject) => {
login.call(req, user, options, err => {
if (err) reject(err)
else resolve()
})
})
}
// add Promise-based logout method
const logout = req.logout
ctx.logout = ctx.logOut = function(options) {
return new Promise((resolve, reject) => {
logout.call(req, options, err => {
if (err) reject(err)
else resolve()
})
})
}
// add aliases for passport's request extensions to Koa's context
ctx.isAuthenticated = req.isAuthenticated.bind(req)
ctx.isUnauthenticated = req.isUnauthenticated.bind(req)
return middleware(req, ctx).then(function() {
return next()
})
}
}
/**
* Passport's authenticate middleware for Koa.
*
* @param {String|Array} name
* @param {Object} options
* @param {GeneratorFunction} callback
* @return {GeneratorFunction}
* @api private
*/
function authenticate(passport, name, options, callback) {
// normalize arguments
if (typeof options === 'function') {
callback = options
options = {}
}
options = options || {}
if (callback) {
// When the callback is set, neither `next`, `res.redirect` or `res.end`
// are called. That is, a workaround to catch the `callback` is required.
// The `passportAuthenticate()` method below will therefore set
// `callback.resolve` and `callback.reject`. Then, once the authentication
// finishes, the modified callback calls the original one and afterwards
// triggers either `callback.resolve` or `callback.reject` to inform
// `passportAuthenticate()` that we are ready.
const _callback = callback
callback = function(err, user, info, status) {
try {
Promise.resolve(_callback(err, user, info, status))
.then(() => callback.resolve(false))
.catch(err => callback.reject(err))
} catch (err) {
callback.reject(err)
}
}
}
const middleware = promisify(_authenticate(passport, name, options, callback))
return function passportAuthenticate(ctx, next) {
// this functions wraps the connect middleware
// to catch `next`, `res.redirect` and `res.end` calls
const p = new Promise((resolve, reject) => {
// mock the `req` object
const req = createReqMock(ctx, options.assignProperty || passport._userProperty || 'user')
function setBodyAndResolve(content) {
if (content) ctx.body = content
resolve(false)
}
// mock the `res` object
const res = {
redirect: function(url) {
ctx.redirect(url)
resolve(false)
},
set: ctx.set.bind(ctx),
setHeader: ctx.set.bind(ctx),
end: setBodyAndResolve,
send: setBodyAndResolve,
set statusCode(status) {
ctx.status = status
},
get statusCode() {
return ctx.status
}
}
req.res = res
// update the custom callback above
if (callback) {
callback.resolve = resolve
callback.reject = reject
}
// call the connect middleware
middleware(req, res).then(resolve, reject)
})
return p.then(cont => {
// cont equals `false` when `res.redirect` or `res.end` got called
// in this case, call next to continue through Koa's middleware stack
if (cont !== false) {
return next()
}
})
}
}
/**
* Passport's authorize middleware for Koa.
*
* @param {String|Array} name
* @param {Object} options
* @param {GeneratorFunction} callback
* @return {GeneratorFunction}
* @api private
*/
function authorize(passport, name, options, callback) {
options = options || {}
options.assignProperty = 'account'
return authenticate(passport, name, options, callback)
}
/**
* Framework support for Koa.
*
* This module provides support for using Passport with Koa. It exposes
* middleware that conform to the `fn*(next)` signature and extends
* Node's built-in HTTP request object with useful authentication-related
* functions.
*
* @return {Object}
* @api protected
*/
module.exports = function() {
return {
initialize: initialize,
authenticate: authenticate,
authorize: authorize
}
}
function promisify(expressMiddleware) {
return function(req, res) {
return new Promise(function(resolve, reject) {
expressMiddleware(req, res, function(err, result) {
if (err) reject(err)
else resolve(result)
})
})
}
}

View File

@@ -0,0 +1,166 @@
// Koa and Express are fundamental different in how they deal with extensions
// to the incoming request.
// Express pollutes Node's IncomingRequest directly, while Koa keeps Node's
// IncomingRequest untouched and adds is own high-level request object.
// These both approaches are not directly compatible with each other, since
// properties/methods found in Express' `req` object are now spread between
// Koa's context, Koa's request object and the original incoming request.
// This makes moking the Express `req` object an ugly task. With ES6 we could
// simply use a Proxy, e.g.:
//
// function createReqMock(ctx) {
// // Use a proxy that forwards `req` reads to either `ctx.passport`,
// // Node's request, Koa's request or Koa's context. Writes are persistet
// // into `ctx.passport`.
// return Proxy.create(handler(ctx.passport, {
// get: function(receiver, key) {
// return ctx.passport[key] || ctx.req[key] || ctx.request[key] || ctx[key]
// }
// }))
// }
//
// However, the current Proxy implementation does not allow debugging.
// See: https://github.com/rkusa/koa-passport/issues/17
//
// Until this is fixed, koa-passport tries to properly delegate every possible
// used property/method.
'use strict'
// Property/Method names to be delegated
let keys = [
// passport
'_passport',
'authInfo',
// http.IncomingMessage
'httpVersion',
'headers',
'trailers',
'setTimeout',
'method',
'url',
'statusCode',
'socket',
'connection',
'protocol',
// Koa's context
'cookies',
'throw',
'ip',
// Others. Are not supported directly - require proper plugins/middlewares.
'param',
'params',
'route',
'xhr',
'baseUrl',
'session',
'body',
'flash'
]
// remove duplicates
keys = keys.filter(function(key, i, self) {
return self.indexOf(key) === i
})
// create a delegate for each key
const properties = {
// mock express' .get('trust proxy')
app: {
// getter returning a mock for `req.app` containing
// the `.get()` method
get: function() {
const ctx = this.ctx
return {
get: function(key) {
if (key === 'trust proxy') {
return ctx.app.proxy
}
return undefined
}
}
}
}
}
keys.forEach(function(key) {
properties[key] = {
get: function() {
const obj = getObject(this.ctx, key)
if (!obj) return undefined
// if its a function, call with the proper context
if (typeof obj[key] === 'function') {
return function() {
return obj[key].apply(obj, arguments)
}
}
// otherwise, simply return it
return obj[key]
},
set: function(value) {
const obj = getObject(this.ctx, key) || this.ctx.state
obj[key] = value
}
}
})
// test where the key is available, either in `ctx.state`, Node's request,
// Koa's request or Koa's context
function getObject(ctx, key) {
if (ctx.state && (key in ctx.state)) {
return ctx.state
}
if (key in ctx.request) {
return ctx.request
}
if (key in ctx.req) {
return ctx.req
}
if (key in ctx) {
return ctx
}
return undefined
}
const IncomingMessageExt = require('passport/lib/http/request')
exports.create = function(ctx, userProperty) {
const req = Object.create(ctx.request, properties)
Object.defineProperty(req, userProperty, {
enumerable: true,
get: function() {
return ctx.state[userProperty]
},
set: function(val) {
ctx.state[userProperty] = val
}
})
Object.defineProperty(req, 'ctx', {
enumerable: true,
get: function() {
return ctx
}
})
// add passport http.IncomingMessage extensions
req.login = IncomingMessageExt.logIn
req.logIn = IncomingMessageExt.logIn
req.logout = IncomingMessageExt.logOut
req.logOut = IncomingMessageExt.logOut
req.isAuthenticated = IncomingMessageExt.isAuthenticated
req.isUnauthenticated = IncomingMessageExt.isUnauthenticated
return req
}

25
server/node_modules/koa-passport/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
'use strict'
// prevent passport from monkey patching
const connect = require('passport/lib/framework/connect')
connect.__monkeypatchNode = function() {}
// load passport and add the koa framework
const passport = require('passport')
const Passport = require('passport').Passport
const framework = require('./framework/koa')()
passport.framework(framework)
class KoaPassport extends Passport {
constructor() {
super()
this.framework(framework)
}
}
// Export default singleton.
module.exports = passport
// Expose constructor
module.exports.KoaPassport = KoaPassport

41
server/node_modules/koa-passport/package.json generated vendored Normal file
View File

@@ -0,0 +1,41 @@
{
"name": "koa-passport",
"author": {
"name": "Markus Ast",
"email": "npm.m@rkusa.st"
},
"version": "6.0.0",
"description": "Passport middleware for Koa",
"keywords": [
"koa",
"passport",
"auth",
"authentication",
"authorization"
],
"homepage": "https://github.com/rkusa/koa-passport",
"license": "MIT",
"main": "./lib",
"dependencies": {
"passport": "^0.6.0"
},
"devDependencies": {
"jest": "^29.4.1",
"koa": "^2.6.2",
"koa-bodyparser": "^4.2.1",
"koa-route": "^3.2",
"passport-local": "^1.0",
"supertest": "^6.1.3"
},
"bugs": "https://github.com/rkusa/koa-passport/issues",
"repository": {
"type": "git",
"url": "git://github.com/rkusa/koa-passport.git"
},
"scripts": {
"test": "jest --testMatch '**/test/*.js'"
},
"engines": {
"node": ">= 4"
}
}