@authhero/react-admin 0.10.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.
- package/.eslintrc.js +21 -0
- package/.vercelignore +4 -0
- package/CHANGELOG.md +56 -0
- package/LICENSE +21 -0
- package/README.md +50 -0
- package/index.html +125 -0
- package/package.json +61 -0
- package/prettier.config.js +1 -0
- package/public/favicon.ico +0 -0
- package/public/manifest.json +15 -0
- package/src/App.spec.tsx +42 -0
- package/src/App.tsx +232 -0
- package/src/AuthCallback.tsx +138 -0
- package/src/Layout.tsx +12 -0
- package/src/TenantsApp.tsx +115 -0
- package/src/auth0DataProvider.ts +1242 -0
- package/src/authProvider.ts +521 -0
- package/src/components/CertificateErrorDialog.tsx +116 -0
- package/src/components/DomainSelector.tsx +401 -0
- package/src/components/TenantAppBar.tsx +83 -0
- package/src/components/TenantLayout.tsx +25 -0
- package/src/components/TenantsAppBar.tsx +21 -0
- package/src/components/TenantsLayout.tsx +28 -0
- package/src/components/activity/ActivityDashboard.tsx +381 -0
- package/src/components/activity/index.ts +1 -0
- package/src/components/branding/BrandingList.tsx +0 -0
- package/src/components/branding/BrandingShow.tsx +0 -0
- package/src/components/branding/ThemesTab.tsx +286 -0
- package/src/components/branding/edit.tsx +149 -0
- package/src/components/branding/hooks/useThemesData.ts +123 -0
- package/src/components/branding/index.ts +2 -0
- package/src/components/branding/list.tsx +12 -0
- package/src/components/clients/create.tsx +12 -0
- package/src/components/clients/edit.tsx +1285 -0
- package/src/components/clients/index.ts +3 -0
- package/src/components/clients/list.tsx +37 -0
- package/src/components/common/DateAgo.tsx +6 -0
- package/src/components/common/JsonOutput.tsx +26 -0
- package/src/components/common/index.ts +1 -0
- package/src/components/connections/create.tsx +35 -0
- package/src/components/connections/edit.tsx +212 -0
- package/src/components/connections/index.ts +3 -0
- package/src/components/connections/list.tsx +15 -0
- package/src/components/custom-domains/create.tsx +26 -0
- package/src/components/custom-domains/edit.tsx +101 -0
- package/src/components/custom-domains/index.ts +3 -0
- package/src/components/custom-domains/list.tsx +16 -0
- package/src/components/flows/create.tsx +30 -0
- package/src/components/flows/edit.tsx +238 -0
- package/src/components/flows/index.ts +3 -0
- package/src/components/flows/list.tsx +15 -0
- package/src/components/forms/FlowEditor.tsx +1363 -0
- package/src/components/forms/NodeEditor.tsx +1119 -0
- package/src/components/forms/RichTextEditor.tsx +145 -0
- package/src/components/forms/create.tsx +30 -0
- package/src/components/forms/edit.tsx +256 -0
- package/src/components/forms/index.ts +3 -0
- package/src/components/forms/list.tsx +16 -0
- package/src/components/hooks/create.tsx +96 -0
- package/src/components/hooks/edit.tsx +114 -0
- package/src/components/hooks/index.ts +3 -0
- package/src/components/hooks/list.tsx +17 -0
- package/src/components/listActions/PostListActions.tsx +10 -0
- package/src/components/logs/LogIcon.tsx +32 -0
- package/src/components/logs/LogShow.tsx +82 -0
- package/src/components/logs/LogType.tsx +38 -0
- package/src/components/logs/index.ts +4 -0
- package/src/components/logs/list.tsx +41 -0
- package/src/components/organizations/create.tsx +13 -0
- package/src/components/organizations/edit.tsx +682 -0
- package/src/components/organizations/index.ts +3 -0
- package/src/components/organizations/list.tsx +21 -0
- package/src/components/resource-servers/create.tsx +87 -0
- package/src/components/resource-servers/edit.tsx +121 -0
- package/src/components/resource-servers/index.ts +3 -0
- package/src/components/resource-servers/list.tsx +47 -0
- package/src/components/roles/create.tsx +12 -0
- package/src/components/roles/edit.tsx +426 -0
- package/src/components/roles/index.ts +3 -0
- package/src/components/roles/list.tsx +24 -0
- package/src/components/sessions/edit.tsx +101 -0
- package/src/components/sessions/index.ts +3 -0
- package/src/components/sessions/list.tsx +20 -0
- package/src/components/sessions/show.tsx +113 -0
- package/src/components/settings/edit.tsx +236 -0
- package/src/components/settings/index.ts +2 -0
- package/src/components/settings/list.tsx +14 -0
- package/src/components/tenants/create.tsx +20 -0
- package/src/components/tenants/edit.tsx +54 -0
- package/src/components/tenants/index.ts +2 -0
- package/src/components/tenants/list.tsx +67 -0
- package/src/components/themes/edit.tsx +200 -0
- package/src/components/themes/index.ts +2 -0
- package/src/components/themes/list.tsx +12 -0
- package/src/components/users/create.tsx +144 -0
- package/src/components/users/edit.tsx +1711 -0
- package/src/components/users/index.ts +3 -0
- package/src/components/users/list.tsx +35 -0
- package/src/data.json +121 -0
- package/src/dataProvider.ts +97 -0
- package/src/index.tsx +106 -0
- package/src/lib/logs.ts +21 -0
- package/src/types/reactflow.d.ts +86 -0
- package/src/utils/domainUtils.ts +169 -0
- package/src/utils/tokenUtils.ts +75 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +37 -0
- package/tsconfig.node.json +10 -0
- package/vercel.json +17 -0
- package/vite.config.ts +30 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { DomainConfig } from "./domainUtils";
|
|
2
|
+
import { Auth0Client } from "@auth0/auth0-spa-js";
|
|
3
|
+
|
|
4
|
+
async function fetchTokenWithClientCredentials(
|
|
5
|
+
domain: string,
|
|
6
|
+
clientId: string,
|
|
7
|
+
clientSecret: string,
|
|
8
|
+
): Promise<string> {
|
|
9
|
+
const response = await fetch(`https://proxy.authhe.ro/oauth/token`, {
|
|
10
|
+
method: "POST",
|
|
11
|
+
headers: {
|
|
12
|
+
"Content-Type": "application/json",
|
|
13
|
+
"X-Auth0-Domain": domain,
|
|
14
|
+
},
|
|
15
|
+
body: JSON.stringify({
|
|
16
|
+
grant_type: "client_credentials",
|
|
17
|
+
client_id: clientId,
|
|
18
|
+
client_secret: clientSecret,
|
|
19
|
+
audience: `https://${domain}/api/v2/`,
|
|
20
|
+
scope:
|
|
21
|
+
"read:users update:users create:users delete:users read:user_idp_tokens " +
|
|
22
|
+
"read:clients update:clients create:clients delete:clients " +
|
|
23
|
+
"read:connections update:connections create:connections delete:connections " +
|
|
24
|
+
"read:resource_servers update:resource_servers create:resource_servers delete:resource_servers " +
|
|
25
|
+
"read:rules update:rules create:rules delete:rules " +
|
|
26
|
+
"read:email_templates update:email_templates " +
|
|
27
|
+
"read:tenant_settings update:tenant_settings " +
|
|
28
|
+
"read:logs read:stats read:branding update:branding read:forms",
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
throw new Error("Failed to fetch token with client credentials");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const data = await response.json();
|
|
37
|
+
return data.access_token;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default async function getToken(
|
|
41
|
+
domainConfig: DomainConfig,
|
|
42
|
+
auth0Client?: Auth0Client,
|
|
43
|
+
): Promise<string> {
|
|
44
|
+
// Check if the domain config has a token
|
|
45
|
+
if (domainConfig.connectionMethod === "token" && domainConfig.token) {
|
|
46
|
+
return domainConfig.token;
|
|
47
|
+
} else if (
|
|
48
|
+
domainConfig.connectionMethod === "client_credentials" &&
|
|
49
|
+
domainConfig.clientId &&
|
|
50
|
+
domainConfig.clientSecret
|
|
51
|
+
) {
|
|
52
|
+
// If using client credentials, generate a token
|
|
53
|
+
const token = await fetchTokenWithClientCredentials(
|
|
54
|
+
domainConfig.url,
|
|
55
|
+
domainConfig.clientId,
|
|
56
|
+
domainConfig.clientSecret,
|
|
57
|
+
);
|
|
58
|
+
return token;
|
|
59
|
+
} else if (domainConfig.connectionMethod === "login" && auth0Client) {
|
|
60
|
+
// If using OAuth login, get token from auth0Client
|
|
61
|
+
try {
|
|
62
|
+
const token = await auth0Client.getTokenSilently();
|
|
63
|
+
return token;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
"Failed to get token from OAuth session. Please log in again.",
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// If no token is available, throw an error
|
|
72
|
+
throw new Error(
|
|
73
|
+
"No authentication method available. Configure either a token or client credentials.",
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"noImplicitAny": false,
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"noErrorTruncation": true,
|
|
10
|
+
|
|
11
|
+
/* Bundler mode */
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
"jsx": "react-jsx",
|
|
18
|
+
|
|
19
|
+
/* Linting */
|
|
20
|
+
"strict": true,
|
|
21
|
+
"noUncheckedIndexedAccess": true,
|
|
22
|
+
"noUnusedLocals": true,
|
|
23
|
+
"noUnusedParameters": true,
|
|
24
|
+
"noFallthroughCasesInSwitch": true,
|
|
25
|
+
|
|
26
|
+
"declaration": true,
|
|
27
|
+
"composite": true,
|
|
28
|
+
"sourceMap": true,
|
|
29
|
+
"declarationMap": true,
|
|
30
|
+
"forceConsistentCasingInFileNames": true,
|
|
31
|
+
|
|
32
|
+
/* Project specific */
|
|
33
|
+
"baseUrl": "."
|
|
34
|
+
},
|
|
35
|
+
"include": ["src"],
|
|
36
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
37
|
+
}
|
package/vercel.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rewrites": [
|
|
3
|
+
{
|
|
4
|
+
"source": "/(.*)manifest.json",
|
|
5
|
+
"destination": "/manifest.json"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"source": "/favicon.ico",
|
|
9
|
+
"destination": "/favicon.ico"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"source": "/(.*)",
|
|
13
|
+
"destination": "/index.html"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"installCommand": "pnpm install --no-frozen-lockfile"
|
|
17
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
|
+
import react from "@vitejs/plugin-react";
|
|
4
|
+
|
|
5
|
+
// https://vitejs.dev/config/
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
plugins: [react()],
|
|
8
|
+
define: {
|
|
9
|
+
"process.env": process.env,
|
|
10
|
+
},
|
|
11
|
+
server: {
|
|
12
|
+
host: true,
|
|
13
|
+
},
|
|
14
|
+
base: "./",
|
|
15
|
+
// @ts-expect-error
|
|
16
|
+
test: {
|
|
17
|
+
environment: "jsdom", // Set JSDOM as the default test environment
|
|
18
|
+
globals: true, // Make test globals available
|
|
19
|
+
env: {
|
|
20
|
+
VITE_AUTH0_API_URL: "http://localhost:3000",
|
|
21
|
+
VITE_AUTH0_DOMAIN: "test.auth0.com",
|
|
22
|
+
},
|
|
23
|
+
server: {
|
|
24
|
+
deps: {
|
|
25
|
+
// Workaround for React Admin ES module issues
|
|
26
|
+
inline: ["ra-ui-materialui", "ra-core", "react-admin", "@mui/material", "@mui/icons-material"],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|