authhero 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +11 -0
  3. package/.github/workflows/release.yml +34 -0
  4. package/.prettierignore +3 -0
  5. package/.prettierrc.json +1 -0
  6. package/README.md +9 -4
  7. package/apps/react-admin/.eslintrc.js +21 -0
  8. package/apps/react-admin/README.md +50 -0
  9. package/apps/react-admin/index.html +125 -0
  10. package/apps/react-admin/package.json +45 -0
  11. package/apps/react-admin/prettier.config.js +1 -0
  12. package/apps/react-admin/public/favicon.ico +0 -0
  13. package/apps/react-admin/public/manifest.json +15 -0
  14. package/apps/react-admin/src/App.spec.tsx +39 -0
  15. package/apps/react-admin/src/App.tsx +75 -0
  16. package/apps/react-admin/src/Layout.tsx +12 -0
  17. package/apps/react-admin/src/TenantsApp.tsx +21 -0
  18. package/apps/react-admin/src/auth0DataProvider.ts +220 -0
  19. package/apps/react-admin/src/authProvider.ts +42 -0
  20. package/apps/react-admin/src/components/TenantAppBar.tsx +46 -0
  21. package/apps/react-admin/src/components/TenantLayout.tsx +17 -0
  22. package/apps/react-admin/src/components/applications/create.tsx +29 -0
  23. package/apps/react-admin/src/components/applications/edit.tsx +40 -0
  24. package/apps/react-admin/src/components/applications/index.ts +3 -0
  25. package/apps/react-admin/src/components/applications/list.tsx +37 -0
  26. package/apps/react-admin/src/components/common/DateAgo.tsx +6 -0
  27. package/apps/react-admin/src/components/common/JsonOutput.tsx +3 -0
  28. package/apps/react-admin/src/components/common/index.ts +1 -0
  29. package/apps/react-admin/src/components/connections/create.tsx +11 -0
  30. package/apps/react-admin/src/components/connections/edit.tsx +66 -0
  31. package/apps/react-admin/src/components/connections/index.ts +3 -0
  32. package/apps/react-admin/src/components/connections/list.tsx +15 -0
  33. package/apps/react-admin/src/components/domains/create.tsx +11 -0
  34. package/apps/react-admin/src/components/domains/edit.tsx +49 -0
  35. package/apps/react-admin/src/components/domains/index.ts +3 -0
  36. package/apps/react-admin/src/components/domains/list.tsx +15 -0
  37. package/apps/react-admin/src/components/listActions/PostListActions.tsx +10 -0
  38. package/apps/react-admin/src/components/tenants/create.tsx +15 -0
  39. package/apps/react-admin/src/components/tenants/edit.tsx +51 -0
  40. package/apps/react-admin/src/components/tenants/index.ts +2 -0
  41. package/apps/react-admin/src/components/tenants/list.tsx +48 -0
  42. package/apps/react-admin/src/components/users/create.tsx +15 -0
  43. package/apps/react-admin/src/components/users/edit.tsx +108 -0
  44. package/apps/react-admin/src/components/users/index.ts +3 -0
  45. package/apps/react-admin/src/components/users/list.tsx +30 -0
  46. package/apps/react-admin/src/data.json +121 -0
  47. package/apps/react-admin/src/dataProvider.ts +48 -0
  48. package/apps/react-admin/src/index.tsx +30 -0
  49. package/apps/react-admin/src/lib/logs.ts +19 -0
  50. package/apps/react-admin/tsconfig.json +9 -0
  51. package/apps/react-admin/tsconfig.node.json +4 -0
  52. package/apps/react-admin/vercel.json +20 -0
  53. package/apps/react-admin/vite.config.ts +19 -0
  54. package/eslint.config.mjs +25 -0
  55. package/package.json +22 -16
  56. package/packages/authhero/CHANGELOG.md +7 -0
  57. package/packages/authhero/README.md +9 -0
  58. package/packages/authhero/package.json +25 -0
  59. package/packages/authhero/src/bun.ts +16 -0
  60. package/packages/authhero/src/index.ts +34 -0
  61. package/packages/authhero/src/routes/oauth2/index.ts +1 -0
  62. package/packages/authhero/src/routes/oauth2/well-known.ts +179 -0
  63. package/{src → packages/authhero/src}/types/Bindings.ts +3 -0
  64. package/packages/authhero/src/types/JWKS.ts +37 -0
  65. package/packages/authhero/src/types/Variables.ts +1 -0
  66. package/packages/authhero/src/types/index.ts +3 -0
  67. package/packages/authhero/src/vite-env.d.ts +1 -0
  68. package/packages/authhero/tsconfig.json +11 -0
  69. package/packages/authhero/tsconfig.node.json +4 -0
  70. package/packages/create-authhero/package.json +22 -0
  71. package/packages/create-authhero/src/index.ts +72 -0
  72. package/packages/create-authhero/src/vite-env.d.ts +1 -0
  73. package/packages/create-authhero/templates/sqlite/package.json +17 -0
  74. package/packages/create-authhero/templates/sqlite/src/index.ts +19 -0
  75. package/packages/create-authhero/templates/sqlite/yarn.lock +48 -0
  76. package/packages/create-authhero/tsconfig.json +9 -0
  77. package/packages/create-authhero/tsconfig.node.json +4 -0
  78. package/packages/create-authhero/vite.config.ts +14 -0
  79. package/pnpm-workspace.yaml +3 -0
  80. package/tsconfig.json +28 -8
  81. package/tsconfig.node.json +7 -2
  82. package/dist/authhero.js +0 -4912
  83. package/dist/index.d.ts +0 -4
  84. package/dist/index.d.ts.map +0 -1
  85. package/dist/types/Bindings.d.ts +0 -5
  86. package/dist/types/Bindings.d.ts.map +0 -1
  87. package/src/index.ts +0 -13
  88. /package/{src → apps/react-admin/src}/vite-env.d.ts +0 -0
  89. /package/{vite.config.ts → packages/authhero/vite.config.ts} +0 -0
@@ -0,0 +1,8 @@
1
+ # Changesets
2
+
3
+ Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4
+ with multi-package repos, or single-package repos to help you version and publish your code. You can
5
+ find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6
+
7
+ We have a quick list of common questions to get you started engaging with this project in
8
+ [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@changesets/config@3.0.2/schema.json",
3
+ "changelog": "@changesets/cli/changelog",
4
+ "commit": false,
5
+ "fixed": [],
6
+ "linked": [],
7
+ "access": "restricted",
8
+ "baseBranch": "main",
9
+ "updateInternalDependencies": "patch",
10
+ "ignore": []
11
+ }
@@ -0,0 +1,34 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ concurrency: ${{ github.workflow }}-${{ github.ref }}
9
+
10
+ jobs:
11
+ release:
12
+ name: Release
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout Repo
16
+ uses: actions/checkout@v3
17
+
18
+ - name: Setup Node.js 20.x
19
+ uses: actions/setup-node@v3
20
+ with:
21
+ node-version: 20.x
22
+
23
+ - name: Install Dependencies
24
+ run: yarn
25
+
26
+ - name: Create Release Pull Request or Publish to npm
27
+ id: changesets
28
+ uses: changesets/action@v1
29
+ with:
30
+ # This expects you to have a script called release which does a build for your packages and calls changeset publish
31
+ publish: yarn release
32
+ env:
33
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,3 @@
1
+ dist
2
+ node_modules
3
+ */*.yml
@@ -0,0 +1 @@
1
+ {"printWidth": 80, "singleQuote": false}
package/README.md CHANGED
@@ -1,9 +1,14 @@
1
- # Authhero
1
+ # authhero
2
2
 
3
- An open-source auth library for building a drop-in replacement for Auth0.
3
+ Monorepo for authhero containing the following apps:
4
4
 
5
- Setup a new project with Authhero in 5 minutes or less:
5
+ - Manage, a web app for managing auth tenants
6
+
7
+ ## Getting Started
8
+
9
+ Get started by running the following commands:
6
10
 
7
11
  ```bash
8
- npx create-authhero
12
+ pnpm install
13
+ pnpm dev
9
14
  ```
@@ -0,0 +1,21 @@
1
+ export default {
2
+ "extends": [
3
+ "eslint:recommended",
4
+ "plugin:react/recommended",
5
+ "plugin:react/jsx-runtime",
6
+ "plugin:react-hooks/recommended",
7
+ "prettier"
8
+ ],
9
+ "parser": "@typescript-eslint/parser",
10
+ "plugins": ["@typescript-eslint"],
11
+ "env": {
12
+ "browser": true,
13
+ "es2021": true,
14
+ "node": true
15
+ },
16
+ "settings": {
17
+ "react": {
18
+ "version": "detect"
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,50 @@
1
+ # react-admin
2
+
3
+ ## Installation
4
+
5
+ Install the application dependencies by running:
6
+
7
+ ```sh
8
+ npm install
9
+ # or
10
+ yarn install
11
+ ```
12
+
13
+ ## Development
14
+
15
+ Start the application in development mode by running:
16
+
17
+ ```sh
18
+ npm run dev
19
+ # or
20
+ yarn dev
21
+ ```
22
+
23
+ ## Production
24
+
25
+ Build the application in production mode by running:
26
+
27
+ ```sh
28
+ npm run build
29
+ # or
30
+ yarn build
31
+ ```
32
+
33
+ ## DataProvider
34
+
35
+ The included data provider use [FakeREST](https://github.com/marmelab/fakerest) to simulate a backend.
36
+ You'll find a `data.json` file in the `src` directory that includes some fake data for testing purposes.
37
+
38
+ It includes two resources, posts and comments.
39
+ Posts have the following properties: `id`, `title` and `content`.
40
+ Comments have the following properties: `id`, `post_id` and `content`.
41
+
42
+ ## Tests
43
+
44
+ You can run the included tests with the following command:
45
+
46
+ ```sh
47
+ npm run test
48
+ # or
49
+ yarn run test
50
+ ```
@@ -0,0 +1,125 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta
6
+ name="viewport"
7
+ content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no"
8
+ />
9
+ <meta name="theme-color" content="#000000" />
10
+ <link rel="manifest" href="./manifest.json" />
11
+ <link rel="shortcut icon" href="./favicon.ico" />
12
+ <title>Auth</title>
13
+ <style>
14
+ body {
15
+ margin: 0;
16
+ padding: 0;
17
+ font-family: sans-serif;
18
+ }
19
+
20
+ .loader-container {
21
+ display: flex;
22
+ align-items: center;
23
+ justify-content: center;
24
+ flex-direction: column;
25
+ position: absolute;
26
+ top: 0;
27
+ bottom: 0;
28
+ left: 0;
29
+ right: 0;
30
+ background-color: #fafafa;
31
+ }
32
+
33
+ /* CSS Spinner from https://projects.lukehaas.me/css-loaders/ */
34
+
35
+ .loader,
36
+ .loader:before,
37
+ .loader:after {
38
+ border-radius: 50%;
39
+ }
40
+
41
+ .loader {
42
+ color: #283593;
43
+ font-size: 11px;
44
+ text-indent: -99999em;
45
+ margin: 55px auto;
46
+ position: relative;
47
+ width: 10em;
48
+ height: 10em;
49
+ box-shadow: inset 0 0 0 1em;
50
+ -webkit-transform: translateZ(0);
51
+ -ms-transform: translateZ(0);
52
+ transform: translateZ(0);
53
+ }
54
+
55
+ .loader:before,
56
+ .loader:after {
57
+ position: absolute;
58
+ content: '';
59
+ }
60
+
61
+ .loader:before {
62
+ width: 5.2em;
63
+ height: 10.2em;
64
+ background: #fafafa;
65
+ border-radius: 10.2em 0 0 10.2em;
66
+ top: -0.1em;
67
+ left: -0.1em;
68
+ -webkit-transform-origin: 5.2em 5.1em;
69
+ transform-origin: 5.2em 5.1em;
70
+ -webkit-animation: load2 2s infinite ease 1.5s;
71
+ animation: load2 2s infinite ease 1.5s;
72
+ }
73
+
74
+ .loader:after {
75
+ width: 5.2em;
76
+ height: 10.2em;
77
+ background: #fafafa;
78
+ border-radius: 0 10.2em 10.2em 0;
79
+ top: -0.1em;
80
+ left: 5.1em;
81
+ -webkit-transform-origin: 0px 5.1em;
82
+ transform-origin: 0px 5.1em;
83
+ -webkit-animation: load2 2s infinite ease;
84
+ animation: load2 2s infinite ease;
85
+ }
86
+
87
+ @-webkit-keyframes load2 {
88
+ 0% {
89
+ -webkit-transform: rotate(0deg);
90
+ transform: rotate(0deg);
91
+ }
92
+ 100% {
93
+ -webkit-transform: rotate(360deg);
94
+ transform: rotate(360deg);
95
+ }
96
+ }
97
+
98
+ @keyframes load2 {
99
+ 0% {
100
+ -webkit-transform: rotate(0deg);
101
+ transform: rotate(0deg);
102
+ }
103
+ 100% {
104
+ -webkit-transform: rotate(360deg);
105
+ transform: rotate(360deg);
106
+ }
107
+ }
108
+ </style>
109
+ <link rel="preconnect" href="https://fonts.gstatic.com" />
110
+ <link
111
+ href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap"
112
+ rel="stylesheet"
113
+ />
114
+ </head>
115
+
116
+ <body>
117
+ <noscript> You need to enable JavaScript to run this app. </noscript>
118
+ <div id="root">
119
+ <div class="loader-container">
120
+ <div class="loader">Loading...</div>
121
+ </div>
122
+ </div>
123
+ </body>
124
+ <script type="module" src="/src/index.tsx"></script>
125
+ </html>
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@authhero/react-admin",
3
+ "scripts": {
4
+ "dev": "vite",
5
+ "build": "vite build",
6
+ "serve": "vite preview",
7
+ "type-check": "tsc --noEmit",
8
+ "lint": "eslint --fix --ext .js,.jsx,.ts,.tsx ./src",
9
+ "format": "prettier --write ./src",
10
+ "test": "vitest"
11
+ },
12
+ "dependencies": {
13
+ "@auth0/auth0-spa-js": "^2.1.3",
14
+ "@mui/icons-material": "^5.15.20",
15
+ "@mui/material": "^5.15.20",
16
+ "date-fns": "^3.6.0",
17
+ "query-string": "^9.0.0",
18
+ "ra-auth-auth0": "^1.1.1",
19
+ "ra-core": "^5.0.2",
20
+ "ra-data-fakerest": "^5.0.2",
21
+ "react": "^18.3.1",
22
+ "react-admin": "^5.0.2",
23
+ "react-admin-color-picker": "^1.0.3",
24
+ "react-dom": "^18.3.1",
25
+ "react-router-dom": "^6.24.0"
26
+ },
27
+ "devDependencies": {
28
+ "@testing-library/react": "^16.0.0",
29
+ "@types/node": "^20.14.9",
30
+ "@types/react": "^18.3.3",
31
+ "@types/react-dom": "^18.3.0",
32
+ "@typescript-eslint/eslint-plugin": "^7.14.1",
33
+ "@typescript-eslint/parser": "^7.14.1",
34
+ "@vitejs/plugin-react": "^4.3.1",
35
+ "eslint": "^9.6.0",
36
+ "eslint-config-prettier": "^9.1.0",
37
+ "eslint-plugin-react": "^7.34.3",
38
+ "eslint-plugin-react-hooks": "^4.6.2",
39
+ "jsdom": "^24.1.0",
40
+ "prettier": "^3.3.2",
41
+ "typescript": "^5.5.2",
42
+ "vite": "^5.3.2",
43
+ "vitest": "^1.6.0"
44
+ }
45
+ }
@@ -0,0 +1 @@
1
+ module.exports = {}
@@ -0,0 +1,15 @@
1
+ {
2
+ "short_name": "react-admin",
3
+ "name": "{{name}}",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ }
10
+ ],
11
+ "start_url": "./index.html",
12
+ "display": "standalone",
13
+ "theme_color": "#000000",
14
+ "background_color": "#ffffff"
15
+ }
@@ -0,0 +1,39 @@
1
+
2
+ import { fireEvent, render, screen, waitFor } from "@testing-library/react";
3
+ import { App } from "./App";
4
+
5
+ test("should pass", async () => {
6
+ vi.spyOn(window, "scrollTo").mockImplementation(() => {});
7
+ render(<App />);
8
+
9
+
10
+ // Open the first post
11
+ fireEvent.click(await screen.findByText("Post 1"));
12
+ fireEvent.click(await screen.findByText("Edit"));
13
+ await screen.findByDisplayValue("Post 1");
14
+ // Ensure the form is fully loaded before interacting with it
15
+ await new Promise((resolve) => setTimeout(resolve, 1000));
16
+ // Update its title
17
+ fireEvent.change(await screen.findByDisplayValue("Post 1"), {
18
+ target: { value: "Post 1 edited" },
19
+ });
20
+ fireEvent.click(await screen.findByText("Save"));
21
+ await screen.findByText("Post 1 edited");
22
+
23
+ // Navigate to the comments
24
+ fireEvent.click(await screen.findByText("Comments"));
25
+ // Open the first comment
26
+ fireEvent.click(await screen.findByText("Comment 1"));
27
+ fireEvent.click(await screen.findByText("Edit"));
28
+ await screen.findByDisplayValue("Post 1 edited");
29
+ // Ensure the form is fully loaded before interacting with it
30
+ await new Promise((resolve) => setTimeout(resolve, 1000));
31
+ // Edit the comment selected post
32
+ fireEvent.click(await screen.findByDisplayValue("Post 1 edited"));
33
+ fireEvent.click(await screen.findByText("Post 11"));
34
+ fireEvent.click(await screen.findByText("Save"));
35
+ // Check the comment has been updated by finding the post link in the comments list page
36
+ await screen.findByText("Post 11", { selector: "a *" });
37
+ }, 10000);
38
+
39
+
@@ -0,0 +1,75 @@
1
+ import { Admin, Resource, ShowGuesser } from "react-admin";
2
+ import Group from "@mui/icons-material/Group";
3
+ import CloudQueue from "@mui/icons-material/CloudQueue";
4
+ import PickALogsIcon from "@mui/icons-material/AccountBalanceWalletOutlined";
5
+ import Layers from "@mui/icons-material/Layers";
6
+ import { getDataproviderForTenant } from "./dataProvider";
7
+ import { authProvider } from "./authProvider";
8
+ import {
9
+ ApplicationCreate,
10
+ ApplicationEdit,
11
+ ApplicationsList,
12
+ } from "./components/applications";
13
+ import {
14
+ ConnectionsList,
15
+ ConnectionCreate,
16
+ ConnectionEdit,
17
+ } from "./components/connections";
18
+ import { tenantLayout } from "./components/TenantLayout";
19
+ import { UserCreate, UserEdit, UsersList } from "./components/users";
20
+ import { DomainCreate, DomainEdit, DomainList } from "./components/domains";
21
+ import { LogsList, LogShow } from "./components/logs";
22
+
23
+ interface AppProps {
24
+ tenantId: string;
25
+ }
26
+
27
+ export function App(props: AppProps) {
28
+ const dataProvider = getDataproviderForTenant(props.tenantId);
29
+
30
+ return (
31
+ <Admin
32
+ dataProvider={dataProvider}
33
+ authProvider={authProvider}
34
+ layout={tenantLayout}
35
+ requireAuth
36
+ >
37
+ <Resource
38
+ icon={Layers}
39
+ name="applications"
40
+ list={ApplicationsList}
41
+ edit={ApplicationEdit}
42
+ create={ApplicationCreate}
43
+ show={ShowGuesser}
44
+ />
45
+ <Resource
46
+ icon={CloudQueue}
47
+ name="connections"
48
+ list={ConnectionsList}
49
+ create={ConnectionCreate}
50
+ edit={ConnectionEdit}
51
+ show={ShowGuesser}
52
+ />
53
+ <Resource
54
+ icon={Group}
55
+ name="users"
56
+ list={UsersList}
57
+ edit={UserEdit}
58
+ create={UserCreate}
59
+ show={ShowGuesser}
60
+ />
61
+ <Resource
62
+ name="domains"
63
+ create={DomainCreate}
64
+ list={DomainList}
65
+ edit={DomainEdit}
66
+ />
67
+ <Resource
68
+ icon={PickALogsIcon}
69
+ name="logs"
70
+ list={LogsList}
71
+ show={LogShow}
72
+ />
73
+ </Admin>
74
+ );
75
+ }
@@ -0,0 +1,12 @@
1
+ import type { ReactNode } from 'react';
2
+ import {
3
+ Layout as RALayout,
4
+ CheckForApplicationUpdate,
5
+ } from "react-admin";
6
+
7
+ export const Layout = ({ children }: { children: ReactNode }) => (
8
+ <RALayout>
9
+ {children}
10
+ <CheckForApplicationUpdate />
11
+ </RALayout>
12
+ );
@@ -0,0 +1,21 @@
1
+ import { Admin, Resource, ShowGuesser } from "react-admin";
2
+ import { getDataprovider } from "./dataProvider";
3
+ import { authProvider } from "./authProvider";
4
+ import { TenantsCreate, TenantsList } from "./components/tenants";
5
+ import { TenantsEdit } from "./components/tenants/edit";
6
+
7
+ export function TenantsApp() {
8
+ const dataProvider = getDataprovider();
9
+
10
+ return (
11
+ <Admin dataProvider={dataProvider} authProvider={authProvider}>
12
+ <Resource
13
+ name="tenants"
14
+ list={TenantsList}
15
+ edit={TenantsEdit}
16
+ create={TenantsCreate}
17
+ show={ShowGuesser}
18
+ />
19
+ </Admin>
20
+ );
21
+ }