@reflagged/shell 1.0.3 → 1.2.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reflagged/shell",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Shared app shell for Reflagged services — OIDC auth, SSO, app switcher",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"./api/oidc-callback": "./src/lib/api/oidc-callback.ts",
|
|
26
26
|
"./api/oidc-signout": "./src/lib/api/oidc-signout.ts",
|
|
27
27
|
"./api/shell-info": "./src/lib/api/shell-info.ts",
|
|
28
|
-
"./package.json": "./package.json"
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
"./components/ServiceIcon": "./src/components/ServiceIcon.tsx"
|
|
29
30
|
},
|
|
30
31
|
"scripts": {
|
|
31
32
|
"typecheck": "tsc --noEmit"
|
|
@@ -38,7 +39,8 @@
|
|
|
38
39
|
"next": "^15.4.0",
|
|
39
40
|
"payload": "^3.79.0",
|
|
40
41
|
"react": "^19.2.0",
|
|
41
|
-
"react-dom": "^19.2.0"
|
|
42
|
+
"react-dom": "^19.2.0",
|
|
43
|
+
"lucide-react": ">=0.400.0"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
46
|
"@types/react": "^19.2.0",
|
|
@@ -47,6 +49,12 @@
|
|
|
47
49
|
"payload": "^3.79.0",
|
|
48
50
|
"react": "^19.2.0",
|
|
49
51
|
"react-dom": "^19.2.0",
|
|
50
|
-
"typescript": "^5.7.0"
|
|
52
|
+
"typescript": "^5.7.0",
|
|
53
|
+
"lucide-react": "^0.500.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"lucide-react": {
|
|
57
|
+
"optional": false
|
|
58
|
+
}
|
|
51
59
|
}
|
|
52
60
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { useEffect, useRef, useState } from 'react'
|
|
4
4
|
import { createPortal } from 'react-dom'
|
|
5
5
|
import { loadAppConfig } from '../config'
|
|
6
|
+
import { ServiceIcon } from './ServiceIcon'
|
|
6
7
|
|
|
7
8
|
type Booking = {
|
|
8
9
|
id: string
|
|
@@ -11,6 +12,12 @@ type Booking = {
|
|
|
11
12
|
status: string
|
|
12
13
|
url: string | null
|
|
13
14
|
iconUrl: string | null
|
|
15
|
+
/**
|
|
16
|
+
* Lucide name of the service icon, from rflgd-base. Optional: an older
|
|
17
|
+
* platform does not send it, and then the initial stands in — the way it
|
|
18
|
+
* always did.
|
|
19
|
+
*/
|
|
20
|
+
icon?: string | null
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
type Org = {
|
|
@@ -391,7 +398,7 @@ export function BrandSwitcher() {
|
|
|
391
398
|
fontWeight: 600,
|
|
392
399
|
}}
|
|
393
400
|
>
|
|
394
|
-
{b.label.
|
|
401
|
+
<ServiceIcon name={b.icon} label={b.label} />
|
|
395
402
|
</div>
|
|
396
403
|
<div style={{ flex: 1, minWidth: 0 }}>
|
|
397
404
|
<div style={{ fontWeight: 500, fontSize: 13.5 }}>{b.label}</div>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AudioLines,
|
|
5
|
+
Bot,
|
|
6
|
+
Box,
|
|
7
|
+
Brain,
|
|
8
|
+
Contact,
|
|
9
|
+
Factory,
|
|
10
|
+
ListMusic,
|
|
11
|
+
MailPlus,
|
|
12
|
+
MessageSquareText,
|
|
13
|
+
PenTool,
|
|
14
|
+
ShieldCheck,
|
|
15
|
+
Users,
|
|
16
|
+
type LucideIcon,
|
|
17
|
+
} from 'lucide-react'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The icon a service shows in the app switcher.
|
|
21
|
+
*
|
|
22
|
+
* Which icon a service gets is rflgd-base's decision — it sends the lucide
|
|
23
|
+
* name in `/api/shell/me` (`serviceIconName()`), so switcher, launchpad and
|
|
24
|
+
* catalog show the same mark. This file only holds the components to render
|
|
25
|
+
* those names with.
|
|
26
|
+
*
|
|
27
|
+
* Listed one by one rather than looked up in lucide's `icons` object, and that
|
|
28
|
+
* is the whole reason this file exists: an index lookup defeats tree shaking,
|
|
29
|
+
* and all ~1500 icons would land in the bundle of every app using this
|
|
30
|
+
* package. Ten repositories depend on it.
|
|
31
|
+
*
|
|
32
|
+
* The cost is a list that can fall behind the platform's. It degrades to
|
|
33
|
+
* exactly today's behaviour — a service whose name is not here shows its
|
|
34
|
+
* initial, as every service did before. Nothing breaks, it just looks
|
|
35
|
+
* unfinished, and adding the icon here is a one-line fix.
|
|
36
|
+
*/
|
|
37
|
+
const ICONS: Record<string, LucideIcon> = {
|
|
38
|
+
AudioLines,
|
|
39
|
+
Bot,
|
|
40
|
+
Box,
|
|
41
|
+
Brain,
|
|
42
|
+
Contact,
|
|
43
|
+
Factory,
|
|
44
|
+
ListMusic,
|
|
45
|
+
MailPlus,
|
|
46
|
+
MessageSquareText,
|
|
47
|
+
PenTool,
|
|
48
|
+
ShieldCheck,
|
|
49
|
+
Users,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function ServiceIcon({
|
|
53
|
+
name,
|
|
54
|
+
label,
|
|
55
|
+
size = 18,
|
|
56
|
+
}: {
|
|
57
|
+
/** Lucide name from the platform, e.g. 'Brain'. */
|
|
58
|
+
name?: string | null
|
|
59
|
+
/** Fallback when the name is missing or not bundled here. */
|
|
60
|
+
label: string
|
|
61
|
+
size?: number
|
|
62
|
+
}) {
|
|
63
|
+
const Icon = name ? ICONS[name] : undefined
|
|
64
|
+
if (!Icon) return <>{label.slice(0, 1).toUpperCase()}</>
|
|
65
|
+
return <Icon size={size} strokeWidth={1.75} aria-hidden />
|
|
66
|
+
}
|
|
@@ -81,6 +81,7 @@ export async function GET(req: Request): Promise<NextResponse> {
|
|
|
81
81
|
tenantSlug: asString(claims.tenant_slug),
|
|
82
82
|
orgSlug: asString(claims.org_slug),
|
|
83
83
|
orgRole: asString(claims.org_role),
|
|
84
|
+
platformRole: asString(claims.platform_role),
|
|
84
85
|
accessibleServices,
|
|
85
86
|
})
|
|
86
87
|
|
|
@@ -17,6 +17,16 @@ export type OidcSessionToken = {
|
|
|
17
17
|
tenantSlug?: string | null
|
|
18
18
|
orgSlug?: string | null
|
|
19
19
|
orgRole?: string | null
|
|
20
|
+
/**
|
|
21
|
+
* The platform-wide role (`superadmin` · `reflagged_admin` · `tenant_admin`
|
|
22
|
+
* · `member`), beside `org_role` rather than behind it.
|
|
23
|
+
*
|
|
24
|
+
* `org_role` is emitted as `membership ?? platform`, which drops the second
|
|
25
|
+
* one: a `superadmin` carried as `member` in their own organisation looks
|
|
26
|
+
* like an ordinary member to a service. A service deriving rights from the
|
|
27
|
+
* token would lock them out of their own instance at the next sign-in.
|
|
28
|
+
*/
|
|
29
|
+
platformRole?: string | null
|
|
20
30
|
/** Product keys the user may access; ['*'] = all, [] = none. */
|
|
21
31
|
accessibleServices?: string[] | null
|
|
22
32
|
iat: number
|
|
@@ -22,6 +22,7 @@ export async function signSessionCookie(
|
|
|
22
22
|
tenantSlug?: string | null
|
|
23
23
|
orgSlug?: string | null
|
|
24
24
|
orgRole?: string | null
|
|
25
|
+
platformRole?: string | null
|
|
25
26
|
accessibleServices?: string[] | null
|
|
26
27
|
},
|
|
27
28
|
): Promise<string> {
|
|
@@ -36,6 +37,7 @@ export async function signSessionCookie(
|
|
|
36
37
|
tenantSlug: payload.tenantSlug ?? null,
|
|
37
38
|
orgSlug: payload.orgSlug ?? null,
|
|
38
39
|
orgRole: payload.orgRole ?? null,
|
|
40
|
+
platformRole: payload.platformRole ?? null,
|
|
39
41
|
accessibleServices: payload.accessibleServices ?? null,
|
|
40
42
|
})
|
|
41
43
|
.setProtectedHeader({ alg: ALG })
|
|
@@ -65,6 +67,7 @@ export async function verifySessionCookie(
|
|
|
65
67
|
tenantSlug: typeof payload.tenantSlug === 'string' ? payload.tenantSlug : null,
|
|
66
68
|
orgSlug: typeof payload.orgSlug === 'string' ? payload.orgSlug : null,
|
|
67
69
|
orgRole: typeof payload.orgRole === 'string' ? payload.orgRole : null,
|
|
70
|
+
platformRole: typeof payload.platformRole === 'string' ? payload.platformRole : null,
|
|
68
71
|
accessibleServices: Array.isArray(payload.accessibleServices)
|
|
69
72
|
? (payload.accessibleServices as unknown[]).filter((s): s is string => typeof s === 'string')
|
|
70
73
|
: null,
|