UNPKG

@strongnguyen/oidc-provider

Version:

OAuth 2.0 Authorization Server implementation for Node.js with OpenID Connect

28 lines (20 loc) 605 B
const { strict: assert } = require('assert'); const omitBy = require('./_/omit_by'); const cache = new WeakMap(); module.exports = function getParams(allowList) { if (!cache.has(allowList)) { assert(allowList, 'allowList must be present'); const klass = class Params { constructor(params) { allowList.forEach((prop) => { this[prop] = params[prop] || undefined; }); } toPlainObject() { return omitBy({ ...this }, (val) => typeof val === 'undefined'); } }; cache.set(allowList, klass); } return cache.get(allowList); };