Skip to content

Commit

Permalink
feat(oidc-http-server-pages): generate JSON templates COMPASS-7646 (#246
Browse files Browse the repository at this point in the history
)

Co-authored-by: Anna Henningsen <[email protected]>
  • Loading branch information
paula-stacho and addaleax authored Mar 1, 2024
1 parent 351d213 commit 1c8b46f
Show file tree
Hide file tree
Showing 14 changed files with 474 additions and 253 deletions.
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/devtools-connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@mongodb-js/oidc-http-server-pages": "0.1.1",
"@mongodb-js/oidc-http-server-pages": "1.0.0",
"lodash.merge": "^4.6.2",
"mongodb-connection-string-url": "^3.0.0",
"socks": "^2.7.3",
Expand Down
29 changes: 23 additions & 6 deletions packages/devtools-connect/src/oidc/handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { RedirectServerRequestInfo } from '@mongodb-js/oidc-plugin';
import type { DevtoolsConnectOptions } from '../connect';
import {
OIDCAcceptedPage,
OIDCNotFoundPage,
OIDCErrorPage,
getStaticPage,
HttpServerPage,
} from '@mongodb-js/oidc-http-server-pages';

export function oidcServerRequestHandler(
Expand Down Expand Up @@ -31,13 +30,31 @@ export function oidcServerRequestHandler(

switch (result) {
case 'accepted':
res.end(OIDCAcceptedPage({ productDocsLink, productName }));
res.end(
getStaticPage(HttpServerPage.OIDCAcceptedPage, {
productDocsLink,
productName,
})
);
break;
case 'rejected':
res.end(OIDCErrorPage({ productDocsLink, productName, ...info }));
res.end(
getStaticPage(HttpServerPage.OIDCErrorPage, {
productDocsLink,
productName,
error: info.error,
errorDescription: info.errorDescription,
errorURI: info.errorURI,
})
);
break;
default:
res.end(OIDCNotFoundPage({ productDocsLink, productName }));
res.end(
getStaticPage(HttpServerPage.OIDCNotFoundPage, {
productDocsLink,
productName,
})
);
break;
}
}
9 changes: 3 additions & 6 deletions packages/oidc-http-server-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"email": "[email protected]"
},
"homepage": "https://github.com/mongodb-js/devtools-shared",
"version": "0.1.1",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
Expand All @@ -31,15 +31,15 @@
"scripts": {
"bootstrap": "npm run compile",
"prepublishOnly": "npm run compile",
"compile": "tsc -p tsconfig.json && node dist/create-static-pages.js > dist/static-pages.js && gen-esm-wrapper . ./dist/.esm-wrapper.mjs",
"compile": "tsc -p tsconfig.json && node dist/create-templates.js && gen-esm-wrapper . ./dist/.esm-wrapper.mjs",
"typecheck": "tsc --noEmit",
"eslint": "eslint",
"prettier": "prettier",
"lint": "npm run eslint . && npm run prettier -- --check .",
"depcheck": "depcheck",
"check": "npm run typecheck && npm run lint && npm run depcheck",
"check-ci": "npm run check",
"test": "mocha",
"test": "npm run compile && mocha",
"test-cov": "nyc -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test",
"test-watch": "npm run test -- --watch",
"test-ci": "npm run test-cov",
Expand All @@ -55,7 +55,6 @@
"@leafygreen-ui/emotion": "^4.0.7",
"@types/chai": "^4.2.21",
"@types/mocha": "^9.1.1",
"@types/node": "^17.0.35",
"@types/react": "^17.0.53",
"@types/react-dom": "^17.0.19",
"@types/sinon-chai": "^3.2.5",
Expand All @@ -68,8 +67,6 @@
"prettier": "^2.3.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"sinon-chai": "^3.7.0",
"ts-sinon": "^2.0.1",
"typescript": "^5.0.4"
}
}
71 changes: 0 additions & 71 deletions packages/oidc-http-server-pages/src/create-static-pages.spec.tsx

This file was deleted.

146 changes: 0 additions & 146 deletions packages/oidc-http-server-pages/src/create-static-pages.ts

This file was deleted.

Loading

0 comments on commit 1c8b46f

Please sign in to comment.