{"id":26164710,"url":"https://github.com/optum/openid-client-server","last_synced_at":"2025-04-14T15:22:10.930Z","repository":{"id":37752513,"uuid":"281127681","full_name":"Optum/openid-client-server","owner":"Optum","description":"An OpenId Relying Party (RP, Client) application server.","archived":false,"fork":false,"pushed_at":"2023-07-18T23:17:02.000Z","size":2770,"stargazers_count":5,"open_issues_count":3,"forks_count":1,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-02T09:04:40.942Z","etag":null,"topics":["oauth2","openid","openid-connect"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Optum.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS.md","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-20T13:43:25.000Z","updated_at":"2024-11-11T13:34:40.000Z","dependencies_parsed_at":"2024-10-23T11:26:36.577Z","dependency_job_id":null,"html_url":"https://github.com/Optum/openid-client-server","commit_stats":{"total_commits":67,"total_committers":8,"mean_commits":8.375,"dds":0.6417910447761195,"last_synced_commit":"c078e2ef11abff85e9ab46f9a792cbeb14a7ad8b"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Optum%2Fopenid-client-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Optum%2Fopenid-client-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Optum%2Fopenid-client-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Optum%2Fopenid-client-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Optum","download_url":"https://codeload.github.com/Optum/openid-client-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665157,"owners_count":21142118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["oauth2","openid","openid-connect"],"created_at":"2025-03-11T15:39:49.588Z","updated_at":"2025-04-14T15:22:10.911Z","avatar_url":"https://github.com/Optum.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp\u003e\n    \u003ch2 align=\"center\"\u003eopenid-client-server\u003c/h2\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    An OpenId Relying Party (RP, Client) application server.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://openid.net/\"\u003e\n        \u003cimg src=\".github/assets/oidc-client-server.svg\" title=\"openid\" width=\"100%\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    This module leverages the \u003ca href=\"https://www.npmjs.com/package/openid-client\"\u003eopenid-client\u003c/a\u003e module to implement a web server that secures any Web UI framework that can be hosted by \u003ca href=\"https://nodejs.org/en/\"\u003eNode.js\u003c/a\u003e with Authorization Code Flow (optional \u003ca href=\"https://tools.ietf.org/html/rfc7636\"\u003eProof Key\u003c/a\u003e), Implicit Flow or Hybrid Flow. The module also provides configurable proxy endpoints that include the user token automatically in requests to API endpoints, as well a session management making it easier to create Web UI's that are \"secure by default\".\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.typescriptlang.org/\"\u003e\n        \u003cimg src=\"https://badgen.net/badge/icon/typescript?icon=typescript\u0026label\" title=\"Built with TypeScript\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/xojs/xo\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/code_style-XO-5ed9c7.svg\" title=\"XO code style\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n## Install\n\nwith npm\n\n```console\n$ npm install @optum/openid-client-server\n```\n\nwith yarn\n\n```console\n$ yarn add @optum/openid-client-server\n```\n\n## Usage\n\n### Options\n\nThe `resolveOptions` function will leverage environmental variables to auto-build all options with defaults. It can be required in the server setup module via `import {resolveOptions} from '@optum/openid-client-server`.\n\n\u003e For more info see the [.env.example](.env.example) file\n\n### clientServer\n\nUse the `clientServer` function to create a `http` server with an integrated [openid-client](https://www.npmjs.com/package/openid-client) and all features in [@optum/openid-client-server](https://www.npmjs.com/package/@optum/openid-client-server).\n\n\u003e With a Promise\n\n```ts\nimport {IncomingMessage, ServerResponse} from 'http'\nimport {clientServer} from '@optum/openid-client-server'\n\nimport handle from 'serve-handler'\n\nconst port = parseInt(process.env.NEXT_SERVER_PORT ?? '8080', 10)\n\nconst serveHandler = async (\n    req: IncomingMessage,\n    res: ServerResponse\n): Promise\u003cvoid\u003e =\u003e {\n    handle(req, res, {\n        headers: [\n            {\n                source: '**/*.*',\n                headers: [\n                    {\n                        key: 'Cache-Control',\n                        value: 'max-age=0'\n                    }\n                ]\n            }\n        ]\n    })\n}\n\nclientServer({\n    contentHandler: serveHandler\n})\n    .then(server =\u003e\n        server.listen(port, () =\u003e {\n            console.log(`\u003e Ready on http://localhost:${port}`)\n        })\n    )\n    .catch(error =\u003e {\n        console.log('Static content server failed to start')\n        console.error(error)\n    })\n```\n\n\u003e With a Async Await\n\n```ts\nimport {IncomingMessage, ServerResponse} from 'http'\nimport {clientServer} from '@optum/openid-client-server'\n\nimport handle from 'serve-handler'\n\nconst port = parseInt(process.env.NEXT_SERVER_PORT ?? '8080', 10)\n\n;(async (): Promise\u003cvoid\u003e =\u003e {\n    try {\n        const serveHandler = async (\n            req: IncomingMessage,\n            res: ServerResponse\n        ): Promise\u003cvoid\u003e =\u003e {\n            handle(req, res, {\n                headers: [\n                    {\n                        source: '**/*.*',\n                        headers: [\n                            {\n                                key: 'Cache-Control',\n                                value: 'max-age=0'\n                            }\n                        ]\n                    }\n                ]\n            })\n        }\n\n        const server = await clientServer({contentHandler: serveHandler})\n\n        server.listen(port, () =\u003e {\n            console.log(`\u003e Ready on http://localhost:${port}`)\n        })\n    } catch (error) {\n        console.log('Static content server failed to start')\n        console.error(error)\n    }\n})()\n```\n\n\u003e For a [Next.js](https://nextjs.org/) example, see: [examples/nextjs](./examples/nextjs) file\n\n## Background\n\nThe original goal of this module was to provide as easy way to implement OpenID flows with [Next.js](https://nextjs.org/) applications via a [custom Next.js](https://nextjs.org/docs/advanced-features/custom-server) server. There were issues leveraging frameworks like [Koa.js](https://koajs.com/) for \"easy wins\" in session management and out-of-the-box middleware, so tides turned to using Node's core [`http`](https://nodejs.org/api/http.html) module. The result ended up working for any Web UI that could be served by Node.js, so here we are.\n\n## Development\n\n### Environment\n\n\u003cp\u003e\n  \u003cul\u003e\n    \u003cli\u003e\n        Node.js is required to develop this module. Please install the latest \u003ca href=\"https://nodejs.org/en/\"\u003eLTS\u003c/a\u003e version if you haven't already.\n    \u003c/li\u003e\n    \u003cli\u003e\n        Module dependencies are managed with Yarn. Please install it if you haven't already.\n        \u003cpre\u003e$ npm i -g yarn\u003c/pre\u003e\n    \u003c/li\u003e\n  \u003c/ul\u003e\n\u003c/p\u003e\n\n### Editors\n\n**VS Code**\n\n-   [Prettier - Code Formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)\n\n**IntelliJ**\n\n-   [Prettier](https://www.jetbrains.com/help/idea/prettier.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptum%2Fopenid-client-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foptum%2Fopenid-client-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptum%2Fopenid-client-server/lists"}