404
15 |An error occurred. But we caught it.
16 |{error.stack}20 |
├── .dockerignore
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .prettierrc
├── .vscode
├── extensions.json
└── settings.json
├── Dockerfile
├── LICENSE.txt
├── README.md
├── azure-pipelines.yml
├── npm-shrinkwrap.json
├── package.json
├── rollup.config.js
├── src
├── client.ts
├── components
│ ├── CloseIcon.svelte
│ ├── ErrorUi.svelte
│ ├── HandshakeLogoIcon.svelte
│ └── TextInput.svelte
├── config.ts
├── hns.ts
├── node_modules
│ └── images
│ │ └── successkid.jpg
├── oidc.ts
├── providers
│ └── AnnouncementContextProvider
│ │ ├── AnnouncementContextProvider.svelte
│ │ └── types.ts
├── redis-adapter.ts
├── redis-client.ts
├── routes
│ ├── _error.svelte
│ ├── _layout.svelte
│ ├── login
│ │ ├── [uid]
│ │ │ └── challenge.svelte
│ │ └── index.svelte
│ ├── oidc-provider.ts
│ └── validate.ts
├── server.ts
├── skip-policy.ts
├── startup.ts
└── template.html
├── static
├── RobotoMono-regular.woff
├── RobotoVariable-subset.woff2
├── favicon.png
└── global.css
└── tsconfig.json
/.dockerignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | yarn-error.log
4 | /__sapper__/
5 | Dockerfile
6 | .vscode
7 | README
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | rollup.config.js
3 | svelte.config.js
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | parser: "@typescript-eslint/parser",
4 | parserOptions: {
5 | ecmaVersion: 2017,
6 | tsconfigRootDir: __dirname,
7 | project: "./tsconfig.json",
8 | },
9 | rules: {
10 | "import/no-mutable-exports": 0,
11 | "no-labels": 0,
12 | "no-restricted-syntax": 0,
13 | "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "_" }]
14 | },
15 | plugins: ["@typescript-eslint", "svelte3"],
16 | extends: [
17 | "plugin:@typescript-eslint/recommended",
18 | "plugin:eslint-comments/recommended",
19 | "plugin:promise/recommended",
20 | "prettier",
21 | "prettier/@typescript-eslint",
22 | ],
23 | overrides: [
24 | {
25 | files: ["**/*.svelte"],
26 | processor: "svelte3/svelte3",
27 | },
28 | ],
29 | env: {
30 | es6: true
31 | }
32 | };
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /node_modules/
3 | /src/node_modules/@sapper/
4 | yarn-error.log
5 | /__sapper__/
6 |
7 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "trailingComma": "all",
4 | "useTabs": false,
5 | "tabWidth": 2,
6 | "printWidth": 100,
7 | "overrides": [
8 | {
9 | "files": "*.ts",
10 | "options": {
11 | "parser": "typescript"
12 | }
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {"recommendations": ["svelte.svelte-vscode"]}
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "workbench.colorCustomizations": {
3 | "titleBar.activeBackground": "#ff69b4",
4 | "titleBar.activeForeground": "#660033",
5 | "titleBar.inactiveBackground": "#ff99cc"
6 | },
7 |
8 | "eslint.format.enable": true,
9 | "files.insertFinalNewline": true,
10 |
11 | "editor.tabSize": 2,
12 | "editor.insertSpaces": true,
13 | "editor.formatOnSave": true,
14 | "editor.defaultFormatter": "esbenp.prettier-vscode",
15 | "editor.codeActionsOnSave": {
16 | "source.fixAll.eslint": true,
17 | "source.organizeImports": true
18 | },
19 |
20 | "[ts]": {
21 | "editor.defaultFormatter": "esbenp.prettier-vscode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:15-alpine as base
2 |
3 | ARG NODE_ENV=production
4 | ENV NODE_ENV $NODE_ENV
5 | ARG PORT=8080
6 | ENV PORT $PORT
7 |
8 | WORKDIR /opt/node_app
9 |
10 | FROM base as deps
11 | RUN apk --no-cache --update --virtual build-dependencies add \
12 | python \
13 | make \
14 | g++
15 |
16 | COPY --chown=node:node ./package.json ./
17 | COPY --chown=node:node ./npm-shrinkwrap.json ./
18 | RUN npm ci --also=dev \
19 | && npm cache clean --force
20 |
21 | COPY --chown=node:node ./ ./
22 | RUN npm run build
23 |
24 | FROM base as release
25 | RUN apk add --no-cache tini
26 | USER node
27 | WORKDIR /opt/node_app/
28 | COPY --chown=node:node --from=deps /opt/node_app/__sapper__/build ./__sapper__/build
29 | COPY --chown=node:node --from=deps /opt/node_app/node_modules ./node_modules
30 | COPY --chown=node:node --from=deps /opt/node_app/static ./static
31 |
32 |
33 | CMD [ "/sbin/tini", "node", "./__sapper__/build" ]
34 |
35 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright 2021 namebase
2 |
3 | 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:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | 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.
8 |
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Handshake OIDC Provider
2 |
3 | ## Requirements
4 |
5 | NodeJS 15+
6 |
7 | ```
8 | nvm install 15.8.0
9 | nvm use 15.8.0
10 | ```
11 |
12 | ## Running the web app
13 |
14 | ```
15 | npm run dev
16 | ```
17 |
18 | ## Route
19 |
20 | [src/routes/oidc-provider.ts](src/routes/oidc-provider.ts)
21 |
22 | ## Config
23 |
24 | [src/oidc.ts](src/oidc.ts)
25 |
26 | ## Crypto
27 |
28 | [src/hns.ts](src/hns.ts)
29 |
30 | ## Sources
31 |
32 | Visit https://github.com/panva/node-oidc-provider/blob/master/docs/README.md for more details on OIDC Provider concepts and user flow.
33 |
--------------------------------------------------------------------------------
/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | # Node.js
2 | # Build a general Node.js project with npm.
3 | # Add steps that analyze code, save build artifacts, deploy, and more:
4 | # https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
5 | resources:
6 | repositories:
7 | - repository: repoDeploy
8 | type: git
9 | name: namernews/deploy
10 |
11 | trigger:
12 | branches:
13 | include:
14 | - '*'
15 | batch: true
16 |
17 | pool:
18 | vmImage: ubuntu-16.04
19 |
20 | stages:
21 | - stage: build
22 | displayName: Build
23 | jobs:
24 | - job: Build
25 | pool:
26 | vmImage: ubuntu-16.04
27 | steps:
28 | - template: docker.yml@repoDeploy
29 | parameters:
30 | imagename: 'hs-id-provider'
31 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "handshake-oidc",
3 | "description": "OIDC provider using handshake name resolution",
4 | "version": "0.0.1",
5 | "config": {
6 | "deploymentName": "oidc",
7 | "namespace": "oidc"
8 | },
9 | "scripts": {
10 | "dev": "NODE_ENV=development PORT=8080 sapper dev",
11 | "build": "sapper build --legacy",
12 | "export": "sapper export --legacy",
13 | "start": "node __sapper__/build",
14 | "validate": "svelte-check --ignore src/node_modules/@sapper",
15 | "dev:remote": "npm run dev:remote:shell -- --run npm run dev",
16 | "dev:remote:shell": "telepresence --swap-deployment $npm_package_config_deploymentName --namespace $npm_package_config_namespace --logfile /dev/null"
17 | },
18 | "dependencies": {
19 | "@sentry/integrations": "^6.1.0",
20 | "@sentry/node": "^6.1.0",
21 | "compression": "^1.7.4",
22 | "connect-redis": "^5.1.0",
23 | "cookie-parser": "^1.4.5",
24 | "cors": "^2.8.5",
25 | "dotenv": "^8.2.0",
26 | "express": "^4.17.1",
27 | "express-rate-limit": "^5.2.5",
28 | "express-session": "^1.17.1",
29 | "hdns": "^0.7.0",
30 | "helmet": "^4.4.1",
31 | "ioredis": "^4.22.0",
32 | "morgan": "^1.10.0",
33 | "oidc-provider": "^6.31.0",
34 | "polka": "next",
35 | "sirv": "^1.0.11"
36 | },
37 | "devDependencies": {
38 | "@babel/core": "^7.12.13",
39 | "@babel/plugin-syntax-dynamic-import": "^7.8.3",
40 | "@babel/plugin-transform-runtime": "^7.12.15",
41 | "@babel/preset-env": "^7.12.13",
42 | "@babel/runtime": "^7.12.13",
43 | "@rollup/plugin-babel": "^5.2.3",
44 | "@rollup/plugin-commonjs": "^17.1.0",
45 | "@rollup/plugin-node-resolve": "^11.1.1",
46 | "@rollup/plugin-replace": "^2.3.4",
47 | "@rollup/plugin-typescript": "^8.1.1",
48 | "@rollup/plugin-url": "^6.0.0",
49 | "@tsconfig/svelte": "^1.0.10",
50 | "@types/compression": "^1.7.0",
51 | "@types/express-session": "^1.17.3",
52 | "@types/ioredis": "^4.22.0",
53 | "@types/node": "^14.14.25",
54 | "@types/polka": "^0.5.2",
55 | "rollup": "^2.38.5",
56 | "rollup-plugin-svelte": "^7.1.0",
57 | "rollup-plugin-terser": "^7.0.2",
58 | "sapper": "^0.28.10",
59 | "svelte": "^3.32.3",
60 | "svelte-check": "^1.1.34",
61 | "svelte-preprocess": "^4.6.1",
62 | "tslib": "^2.1.0",
63 | "typescript": "^4.1.5"
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import babel from '@rollup/plugin-babel';
2 | import commonjs from '@rollup/plugin-commonjs';
3 | import resolve from '@rollup/plugin-node-resolve';
4 | import replace from '@rollup/plugin-replace';
5 | import typescript from '@rollup/plugin-typescript';
6 | import url from '@rollup/plugin-url';
7 | import path from 'path';
8 | import svelte from 'rollup-plugin-svelte';
9 | import { terser } from 'rollup-plugin-terser';
10 | import config from 'sapper/config/rollup.js';
11 | import sveltePreprocess from 'svelte-preprocess';
12 | import pkg from './package.json';
13 |
14 | const mode = process.env.NODE_ENV;
15 | const dev = mode === 'development';
16 | const legacy = !!process.env.SAPPER_LEGACY_BUILD;
17 |
18 | const onwarn = (warning, onwarn) =>
19 | (warning.code === 'MISSING_EXPORT' && /'preload'/.test(warning.message)) ||
20 | (warning.code === 'CIRCULAR_DEPENDENCY' && /[/\\]@sapper[/\\]/.test(warning.message)) ||
21 | warning.code === 'THIS_IS_UNDEFINED' ||
22 | onwarn(warning);
23 |
24 | export default {
25 | client: {
26 | input: config.client.input().replace(/\.js$/, '.ts'),
27 | output: config.client.output(),
28 | plugins: [
29 | replace({
30 | 'process.browser': true,
31 | 'process.env.NODE_ENV': JSON.stringify(mode),
32 | }),
33 | svelte({
34 | preprocess: sveltePreprocess({ sourceMap: dev }),
35 | compilerOptions: {
36 | dev,
37 | hydratable: true,
38 | },
39 | }),
40 | url({
41 | sourceDir: path.resolve(__dirname, 'src/node_modules/images'),
42 | publicPath: '/client/',
43 | }),
44 | resolve({
45 | browser: true,
46 | dedupe: ['svelte'],
47 | }),
48 | commonjs(),
49 | typescript({ sourceMap: dev }),
50 |
51 | legacy &&
52 | babel({
53 | extensions: ['.js', '.mjs', '.html', '.svelte'],
54 | babelHelpers: 'runtime',
55 | exclude: ['node_modules/@babel/**'],
56 | presets: [
57 | [
58 | '@babel/preset-env',
59 | {
60 | targets: '> 0.25%, not dead',
61 | },
62 | ],
63 | ],
64 | plugins: [
65 | '@babel/plugin-syntax-dynamic-import',
66 | [
67 | '@babel/plugin-transform-runtime',
68 | {
69 | useESModules: true,
70 | },
71 | ],
72 | ],
73 | }),
74 |
75 | !dev &&
76 | terser({
77 | module: true,
78 | }),
79 | ],
80 |
81 | preserveEntrySignatures: false,
82 | onwarn,
83 | },
84 |
85 | server: {
86 | input: { server: config.server.input().server.replace(/\.js$/, '.ts') },
87 | output: config.server.output(),
88 | plugins: [
89 | replace({
90 | 'process.browser': false,
91 | 'process.env.NODE_ENV': JSON.stringify(mode),
92 | }),
93 | svelte({
94 | preprocess: sveltePreprocess({ sourceMap: dev }),
95 | compilerOptions: {
96 | dev,
97 | generate: 'ssr',
98 | hydratable: true,
99 | },
100 | emitCss: false,
101 | }),
102 | url({
103 | sourceDir: path.resolve(__dirname, 'src/node_modules/images'),
104 | publicPath: '/client/',
105 | emitFiles: false, // already emitted by client build
106 | }),
107 | resolve({
108 | dedupe: ['svelte'],
109 | }),
110 | commonjs(),
111 | typescript({ sourceMap: dev }),
112 | ],
113 | external: Object.keys(pkg.dependencies).concat(require('module').builtinModules),
114 |
115 | preserveEntrySignatures: 'strict',
116 | onwarn,
117 | },
118 | };
119 |
--------------------------------------------------------------------------------
/src/client.ts:
--------------------------------------------------------------------------------
1 | import * as sapper from '@sapper/app';
2 | sapper.start({ target: document.querySelector('#sapper') });
3 |
--------------------------------------------------------------------------------
/src/components/CloseIcon.svelte:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/components/ErrorUi.svelte:
--------------------------------------------------------------------------------
1 |
4 |
5 |
8 |
9 |
{error.stack}20 |