@object-ui/auth 17.6.0 → 17.7.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/CHANGELOG.md +490 -0
- package/README.md +97 -15
- package/dist/ActiveOrganizationStorage.d.ts +32 -1
- package/dist/ActiveOrganizationStorage.d.ts.map +1 -1
- package/dist/ActiveOrganizationStorage.js +72 -3
- package/dist/AuthContext.d.ts +4 -2
- package/dist/AuthContext.d.ts.map +1 -1
- package/dist/AuthProvider.js +4 -4
- package/dist/LoginForm.d.ts +10 -1
- package/dist/LoginForm.d.ts.map +1 -1
- package/dist/LoginForm.js +1 -2
- package/dist/RegisterForm.d.ts +21 -2
- package/dist/RegisterForm.d.ts.map +1 -1
- package/dist/RegisterForm.js +3 -4
- package/dist/SocialSignInButtons.d.ts +9 -2
- package/dist/SocialSignInButtons.d.ts.map +1 -1
- package/dist/SocialSignInButtons.js +3 -3
- package/dist/UserMenu.d.ts +1 -1
- package/dist/UserMenu.js +1 -1
- package/dist/createAuthClient.d.ts.map +1 -1
- package/dist/createAuthClient.js +6 -0
- package/dist/createAuthenticatedFetch.d.ts +1 -1
- package/dist/createAuthenticatedFetch.d.ts.map +1 -1
- package/dist/createAuthenticatedFetch.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/types.d.ts +14 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/useWorkspaceAdminStatus.d.ts +76 -27
- package/dist/useWorkspaceAdminStatus.d.ts.map +1 -1
- package/dist/useWorkspaceAdminStatus.js +146 -40
- package/package.json +5 -6
|
@@ -48,7 +48,7 @@ function ProviderIcon({ id }) {
|
|
|
48
48
|
*
|
|
49
49
|
* Returns `null` while loading or when the server reports no providers.
|
|
50
50
|
*/
|
|
51
|
-
export function SocialSignInButtons({ mode = 'sign-in', callbackURL, errorCallbackURL, dividerText = 'or continue with email', onProvidersResolved, }) {
|
|
51
|
+
export function SocialSignInButtons({ mode = 'sign-in', callbackURL, errorCallbackURL, dividerText = 'or continue with email', buttonText, onProvidersResolved, }) {
|
|
52
52
|
const { getAuthConfig, signInWithProvider } = useAuth();
|
|
53
53
|
const [providers, setProviders] = useState([]);
|
|
54
54
|
const [loading, setLoading] = useState(true);
|
|
@@ -86,7 +86,7 @@ export function SocialSignInButtons({ mode = 'sign-in', callbackURL, errorCallba
|
|
|
86
86
|
}, [getAuthConfig]);
|
|
87
87
|
if (loading || providers.length === 0)
|
|
88
88
|
return null;
|
|
89
|
-
const
|
|
89
|
+
const labelTemplate = buttonText ?? (mode === 'sign-in' ? 'Continue with {provider}' : 'Sign up with {provider}');
|
|
90
90
|
const defaultCallback = typeof window !== 'undefined' ? window.location.href : undefined;
|
|
91
91
|
const onClick = async (provider) => {
|
|
92
92
|
if (pendingId)
|
|
@@ -107,5 +107,5 @@ export function SocialSignInButtons({ mode = 'sign-in', callbackURL, errorCallba
|
|
|
107
107
|
setPendingId(null);
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
|
-
return (_jsxs("div", { className: "flex flex-col gap-2", children: [error && (_jsx("div", { className: "rounded-md bg-destructive/15 p-3 text-sm text-destructive", role: "alert", children: error })), providers.map((p) => (_jsxs("button", { type: "button", onClick: () => onClick(p), disabled: pendingId !== null, "aria-busy": pendingId === p.id, className: "inline-flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", children: [pendingId === p.id ? _jsx(AuthSpinner, {}) : _jsx(ProviderIcon, { id: p.id }),
|
|
110
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [error && (_jsx("div", { className: "rounded-md bg-destructive/15 p-3 text-sm text-destructive", role: "alert", children: error })), providers.map((p) => (_jsxs("button", { type: "button", onClick: () => onClick(p), disabled: pendingId !== null, "aria-busy": pendingId === p.id, className: "inline-flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", children: [pendingId === p.id ? _jsx(AuthSpinner, {}) : _jsx(ProviderIcon, { id: p.id }), labelTemplate.replace('{provider}', () => PROVIDER_LABEL[p.id] ?? p.name)] }, p.id))), _jsxs("div", { className: "relative my-1", children: [_jsx("div", { className: "absolute inset-0 flex items-center", children: _jsx("span", { className: "w-full border-t" }) }), _jsx("div", { className: "relative flex justify-center text-xs uppercase", children: _jsx("span", { className: "bg-background px-2 text-muted-foreground", children: dividerText }) })] })] }));
|
|
111
111
|
}
|
package/dist/UserMenu.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface UserMenuProps {
|
|
|
21
21
|
* Shows avatar, name, email, and common actions (profile, settings, sign out).
|
|
22
22
|
*
|
|
23
23
|
* This is a headless component that provides the user data and actions.
|
|
24
|
-
* The actual dropdown rendering is handled by the consumer
|
|
24
|
+
* The actual dropdown rendering is handled by the consumer.
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* ```tsx
|
package/dist/UserMenu.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getUserInitials } from './types.js';
|
|
|
6
6
|
* Shows avatar, name, email, and common actions (profile, settings, sign out).
|
|
7
7
|
*
|
|
8
8
|
* This is a headless component that provides the user data and actions.
|
|
9
|
-
* The actual dropdown rendering is handled by the consumer
|
|
9
|
+
* The actual dropdown rendering is handled by the consumer.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAuthClient.d.ts","sourceRoot":"","sources":["../src/createAuthClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,UAAU,EAAE,gBAAgB,EAE7B,MAAM,YAAY,CAAC;AAKpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY;kBACD,MAAM,GAAG,IAAI;kCACD,IAAI;WAE/B,MAAM,GAAG,IAAI;eAST,MAAM,GAAG,IAAI;aAkBf,IAAI;IASb;;;OAGG;gCACyB,MAAM,IAAI,GAAG,MAAM,IAAI;CAMpD,CAAC;AA2KF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,
|
|
1
|
+
{"version":3,"file":"createAuthClient.d.ts","sourceRoot":"","sources":["../src/createAuthClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,UAAU,EAAE,gBAAgB,EAE7B,MAAM,YAAY,CAAC;AAKpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY;kBACD,MAAM,GAAG,IAAI;kCACD,IAAI;WAE/B,MAAM,GAAG,IAAI;eAST,MAAM,GAAG,IAAI;aAkBf,IAAI;IASb;;;OAGG;gCACyB,MAAM,IAAI,GAAG,MAAM,IAAI;CAMpD,CAAC;AA2KF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CA2rBrE"}
|
package/dist/createAuthClient.js
CHANGED
|
@@ -360,6 +360,12 @@ export function createAuthClient(config) {
|
|
|
360
360
|
email: signUpData.email,
|
|
361
361
|
password: signUpData.password,
|
|
362
362
|
name: signUpData.name,
|
|
363
|
+
// objectui#10893 — the verification mail's link lands here. Without
|
|
364
|
+
// it better-auth writes `callbackURL=/`, and an invitee who registers
|
|
365
|
+
// from an invitation link is dropped on the workspace picker instead
|
|
366
|
+
// of the invitation. Only sent when the caller has somewhere to go,
|
|
367
|
+
// so the server default is untouched otherwise.
|
|
368
|
+
...(signUpData.callbackURL ? { callbackURL: signUpData.callbackURL } : {}),
|
|
363
369
|
});
|
|
364
370
|
if (error) {
|
|
365
371
|
throw toAuthError(error);
|
|
@@ -21,7 +21,7 @@ export interface AuthenticatedAdapterOptions {
|
|
|
21
21
|
* so `@object-ui/auth`'s barrel, this package's tests and every consumer
|
|
22
22
|
* import the same symbol from the same place they did before.
|
|
23
23
|
*/
|
|
24
|
-
export { ActiveOrganizationStorage, SessionUserScope, purgePreviousUserClientState } from './ActiveOrganizationStorage.js';
|
|
24
|
+
export { ActiveOrganizationStorage, SessionUserScope, purgePreviousUserClientState, getSessionOwnerChangeCount, subscribeSessionOwnerChange, } from './ActiveOrganizationStorage.js';
|
|
25
25
|
export interface CreateAuthenticatedFetchOptions {
|
|
26
26
|
/**
|
|
27
27
|
* When true, requests whose URL resolves to a different origin than the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAuthenticatedFetch.d.ts","sourceRoot":"","sources":["../src/createAuthenticatedFetch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"createAuthenticatedFetch.d.ts","sourceRoot":"","sources":["../src/createAuthenticatedFetch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,gCAAgC,CAAC;AAExC,MAAM,WAAW,+BAA+B;IAC9C;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAYD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,CAAC,EAAE,+BAA+B,GACxC,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CA+GrE"}
|
|
@@ -15,7 +15,7 @@ import { ActiveOrganizationStorage } from './ActiveOrganizationStorage.js';
|
|
|
15
15
|
* so `@object-ui/auth`'s barrel, this package's tests and every consumer
|
|
16
16
|
* import the same symbol from the same place they did before.
|
|
17
17
|
*/
|
|
18
|
-
export { ActiveOrganizationStorage, SessionUserScope, purgePreviousUserClientState } from './ActiveOrganizationStorage.js';
|
|
18
|
+
export { ActiveOrganizationStorage, SessionUserScope, purgePreviousUserClientState, getSessionOwnerChangeCount, subscribeSessionOwnerChange, } from './ActiveOrganizationStorage.js';
|
|
19
19
|
/** True when `url` resolves to a different origin than the current page. */
|
|
20
20
|
function isCrossOrigin(url) {
|
|
21
21
|
if (typeof window === 'undefined' || !window.location)
|
|
@@ -106,7 +106,7 @@ export function createAuthenticatedFetch(options) {
|
|
|
106
106
|
// switcher, so reading it here means a language switch carries the new
|
|
107
107
|
// `Accept-Language` on every subsequent request — closing the gap where
|
|
108
108
|
// server-resolved labels stayed in the old language until a page refresh
|
|
109
|
-
// (issue #1319). We only fold it in for our own API calls, and never
|
|
109
|
+
// (issue objectstack-ai/objectstack#1319). We only fold it in for our own API calls, and never
|
|
110
110
|
// clobber an `Accept-Language` the caller set explicitly.
|
|
111
111
|
if (isApiCall && !headers.has('Accept-Language') && typeof document !== 'undefined') {
|
|
112
112
|
const lang = document.documentElement.lang;
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export { PreviewBanner, type PreviewBannerProps } from './PreviewBanner.js';
|
|
|
33
33
|
export { createAuthClient, TokenStorage } from './createAuthClient.js';
|
|
34
34
|
export { normalizePhoneIdentifier, looksLikePhoneIdentifier } from './phone-identifier.js';
|
|
35
35
|
export { createAuthenticatedFetch, ActiveOrganizationStorage, type AuthenticatedAdapterOptions } from './createAuthenticatedFetch.js';
|
|
36
|
+
export { getSessionOwnerChangeCount, subscribeSessionOwnerChange } from './ActiveOrganizationStorage.js';
|
|
36
37
|
export { getUserInitials } from './types.js';
|
|
37
38
|
export { ORG_ROLE_OWNER, ORG_ROLE_ADMIN, ORG_ROLE_DELEGATED_ADMIN, ORG_ROLE_MEMBER, ORG_ROLES, ORG_ROLE_LABELS, orgRoleGrade, invitableOrgRoles, assignableOrgRoles, type OrgRole, } from './org-roles.js';
|
|
38
39
|
export { AUTH_INVITATION_STATUSES, isAuthInvitationStatus, type AuthInvitationStatus, } from './invitation-status.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAOvC,OAAO,EAAE,uBAAuB,EAAE,KAAK,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAClG,OAAO,EAAE,kBAAkB,EAAE,KAAK,uBAAuB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AM,YAAY,CAAC;AAEpB,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,12 @@ export { PreviewBanner } from './PreviewBanner.js';
|
|
|
39
39
|
export { createAuthClient, TokenStorage } from './createAuthClient.js';
|
|
40
40
|
export { normalizePhoneIdentifier, looksLikePhoneIdentifier } from './phone-identifier.js';
|
|
41
41
|
export { createAuthenticatedFetch, ActiveOrganizationStorage } from './createAuthenticatedFetch.js';
|
|
42
|
+
// objectui#10193 — "the browser changed hands in this page-load". The purge on a
|
|
43
|
+
// change of session user clears storage; state already derived from it in
|
|
44
|
+
// memory (the UI language, first of all) is re-derived by whoever owns it, and
|
|
45
|
+
// these two are how that owner finds out — including one that mounts after the
|
|
46
|
+
// purge fired.
|
|
47
|
+
export { getSessionOwnerChangeCount, subscribeSessionOwnerChange } from './ActiveOrganizationStorage.js';
|
|
42
48
|
export { getUserInitials } from './types.js';
|
|
43
49
|
// Organization membership-role vocabulary — a CLOSED, framework-owned list of
|
|
44
50
|
// four (framework ADR-0108), re-exported from `@objectstack/spec`'s
|
package/dist/types.d.ts
CHANGED
|
@@ -120,6 +120,19 @@ export interface SignUpData {
|
|
|
120
120
|
name: string;
|
|
121
121
|
email: string;
|
|
122
122
|
password: string;
|
|
123
|
+
/**
|
|
124
|
+
* Where the email-verification link lands once the address is verified —
|
|
125
|
+
* e.g. the invitation page the user registered from (objectui#10893).
|
|
126
|
+
* Sent verbatim as better-auth's `/sign-up/email` `callbackURL`; omitted,
|
|
127
|
+
* the server's default (`/`) applies.
|
|
128
|
+
*
|
|
129
|
+
* better-auth accepts only a root-relative path (`/_console/…`) or an
|
|
130
|
+
* absolute URL on a trusted origin. Anything else — including a
|
|
131
|
+
* document-relative `./…` — is refused with `INVALID_CALLBACK_URL` and the
|
|
132
|
+
* WHOLE sign-up fails, so resolve an SPA route against its mount before
|
|
133
|
+
* passing it here.
|
|
134
|
+
*/
|
|
135
|
+
callbackURL?: string;
|
|
123
136
|
}
|
|
124
137
|
/** Auth client configuration */
|
|
125
138
|
export interface AuthClientConfig {
|
|
@@ -222,7 +235,7 @@ export interface AuthPublicConfig {
|
|
|
222
235
|
* better-auth admin plugin mounted server-side (`auth.plugins.admin`;
|
|
223
236
|
* SCIM forces it on). Gates the admin user-management surfaces — the
|
|
224
237
|
* sys_user create/set-password actions and the identity import wizard
|
|
225
|
-
* entry (framework#2766 / #2782).
|
|
238
|
+
* entry (framework#2766 / objectstack-ai/objectstack#2782).
|
|
226
239
|
*/
|
|
227
240
|
admin?: boolean;
|
|
228
241
|
/**
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EACV,QAAQ,IAAI,YAAY,EACxB,cAAc,EACd,mBAAmB,EACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B;;;;;;;;;;;GAWG;AACH,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC;AAEpD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,QAAS,SAAQ,YAAY;IAC5C,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IAUd,gCAAgC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,+BAA+B;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,eAAe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AChD,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,uCAAuC;IACvC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAC/C,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export interface WorkspaceAdminStatus {
|
|
15
15
|
/**
|
|
16
|
-
* True only when adminship is CONFIRMED by one of the
|
|
16
|
+
* True only when adminship is CONFIRMED by one of the legs below.
|
|
17
17
|
* While `isResolved` is false this is `false` because nothing has said
|
|
18
18
|
* otherwise yet — NOT because the viewer is known not to be an admin.
|
|
19
19
|
*/
|
|
@@ -30,29 +30,76 @@ export interface WorkspaceAdminStatus {
|
|
|
30
30
|
* has finished resolving.
|
|
31
31
|
*
|
|
32
32
|
* Sources considered (any one is sufficient):
|
|
33
|
-
* -
|
|
34
|
-
* -
|
|
35
|
-
* that still store an admin role on the user row.
|
|
36
|
-
* - `user.
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
33
|
+
* - LEG 1 — the active organization member row (multi-tenant mode).
|
|
34
|
+
* - LEG 2 — the top-level `user.role` scalar from the session: legacy
|
|
35
|
+
* deployments that still store an admin role on the user row.
|
|
36
|
+
* - LEG 3a — `user.isPlatformAdmin` from the session: the server's ADR-0095
|
|
37
|
+
* posture RUNG, and the ONLY leg that sees a platform administrator whose
|
|
38
|
+
* adminship comes from the `admin_full_access` permission set. On a
|
|
39
|
+
* single-tenant deployment there is no member row to read (leg 1) and the
|
|
40
|
+
* server deliberately no longer overwrites `user.role` (leg 2), so this
|
|
41
|
+
* flag is the whole signal for that viewer. Measured on a live protocol-17
|
|
42
|
+
* server in objectui#5389 — the captured payload there carries
|
|
43
|
+
* `isPlatformAdmin: true` — and pinned by
|
|
44
44
|
* `__tests__/workspaceAdminPositions-5389.test.tsx`.
|
|
45
|
+
* - LEG 3b — `user.positions[]` from the session, judged against
|
|
46
|
+
* {@link ADMIN_POSITION_NAMES} rather than {@link ADMIN_ROLES}: the
|
|
47
|
+
* canonical TENANT-scoped identity names the server derives from the active
|
|
48
|
+
* organization's membership row (ADR-0068 D1/D2, renamed from `roles` by
|
|
49
|
+
* ADR-0090 D3). This is what lets a tenant administrator resolve on the
|
|
50
|
+
* first frame instead of waiting for leg 1 (see the objectui#5619 section
|
|
51
|
+
* below).
|
|
45
52
|
*
|
|
46
|
-
*
|
|
47
|
-
* alongside the retired `roles` (ADR-0090 D3 renamed with no deprecation
|
|
48
|
-
* window and bans resurrecting the old name as a fallback), and not alongside
|
|
49
|
-
* the derived `user.isPlatformAdmin` either — that flag is computed by the
|
|
50
|
-
* server as `'platform_admin' in positions` from the same expression, so
|
|
51
|
-
* reading both would be two spellings for one fact with no way to disagree
|
|
52
|
-
* usefully and every way to drift.
|
|
53
|
+
* ## Why 3a and 3b are two legs and not one (objectui#8291)
|
|
53
54
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
55
|
+
* This docblock used to argue the opposite, and a future reader who finds that
|
|
56
|
+
* argument standing will re-introduce the defect it now describes. It said:
|
|
57
|
+
* do not read `user.isPlatformAdmin` alongside `positions`, because the server
|
|
58
|
+
* computes the flag as `'platform_admin' in positions` from the same
|
|
59
|
+
* expression, so reading both would be two spellings for one fact with no way
|
|
60
|
+
* to disagree usefully and every way to drift.
|
|
61
|
+
*
|
|
62
|
+
* **That was true and it is now false.** Framework objectstack#15948 (a
|
|
63
|
+
* declared BREAKING change) redefined what `positions[]` IS. It used to be the
|
|
64
|
+
* `sys_user.role` scalar split on commas; it is now built by
|
|
65
|
+
* `resolveUserAuthzGrants` and carries ADR-0057 D4 `sys_user_position`
|
|
66
|
+
* assignments. That table is `apiEnabled` and its `position` values are
|
|
67
|
+
* unconstrained, so a caller holding tenant-administration authority can mint
|
|
68
|
+
* a row spelling `platform_admin` for one of their own users — and the name
|
|
69
|
+
* lands on `positions[]` verbatim.
|
|
70
|
+
*
|
|
71
|
+
* The two therefore no longer say one thing:
|
|
72
|
+
*
|
|
73
|
+
* - `isPlatformAdmin` is `grants.posture === 'PLATFORM_ADMIN'` — derived from
|
|
74
|
+
* an UNSCOPED `admin_full_access` grant (or a verified email on the
|
|
75
|
+
* deployment's declared administrator list) and from nothing else. It is
|
|
76
|
+
* byte-for-byte what the server's own `hasPlatformAdminStanding` returns.
|
|
77
|
+
* - `positions[]` is the security AXIS, which is a wider thing: it is the set
|
|
78
|
+
* of names a request resolves to, including names a tenant wrote.
|
|
79
|
+
*
|
|
80
|
+
* They can now disagree, and when they do **the rung is right** — enforcement
|
|
81
|
+
* agrees with the rung, so the array's extra name buys nothing except a
|
|
82
|
+
* Console that paints platform-administrator surfaces at a principal every
|
|
83
|
+
* underlying call refuses. `resolve-authz-context.ts` states the rule at
|
|
84
|
+
* `hasPlatformAdminStanding`: read the RUNG, never
|
|
85
|
+
* `positions.includes('platform_admin')`. The framework moved four server-side
|
|
86
|
+
* sites onto it (`plugin-sharing`, `plugin-approvals`, `plugin-security`,
|
|
87
|
+
* `runtime`); this hook is the same read on the client side of the wire.
|
|
88
|
+
*
|
|
89
|
+
* ⛔ So: never put `platform_admin` back into {@link ADMIN_POSITION_NAMES},
|
|
90
|
+
* and never widen leg 3b back to {@link ADMIN_ROLES}. The name is not the
|
|
91
|
+
* authority. Every server that publishes `positions` publishes
|
|
92
|
+
* `isPlatformAdmin` beside it — `customSession` returns them in one object
|
|
93
|
+
* literal — so nothing is lost by reading the narrow one.
|
|
94
|
+
*
|
|
95
|
+
* `positions` also remains the ONE published spelling of the array itself. It
|
|
96
|
+
* is deliberately not read alongside the retired `roles` (ADR-0090 D3 renamed
|
|
97
|
+
* with no deprecation window and bans resurrecting the old name as a
|
|
98
|
+
* fallback).
|
|
99
|
+
*
|
|
100
|
+
* In preview-mode / no-auth-enabled mode the provider seeds an admin user
|
|
101
|
+
* (`role: 'admin'`, which leg 2 reads), so this returns `isAdmin: true` for
|
|
102
|
+
* dev/demo setups.
|
|
56
103
|
*
|
|
57
104
|
* ## Why this returns a pair and not a boolean (objectui#5619)
|
|
58
105
|
*
|
|
@@ -68,18 +115,20 @@ export interface WorkspaceAdminStatus {
|
|
|
68
115
|
* console chrome dropped and re-added a nav entry, and `AppContent` fired a
|
|
69
116
|
* `<Navigate to="/home" replace>` that the later flip cannot undo.
|
|
70
117
|
*
|
|
71
|
-
* Legs 2 and
|
|
118
|
+
* Legs 2 and 3b DO cover that viewer whenever the session was minted with an
|
|
72
119
|
* active organization stamped on it — framework `auth-manager.ts` reads
|
|
73
120
|
* `session.activeOrganizationId` and, when it is set, maps the member row into
|
|
74
|
-
* `positions[]` as `org_owner`/`org_admin`.
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
121
|
+
* `positions[]` as `org_owner`/`org_admin`. Those two names are exactly why
|
|
122
|
+
* objectui#8291 kept leg 3b alive rather than deleting the array read
|
|
123
|
+
* outright. The window is therefore not "every tenant admin" as first
|
|
124
|
+
* reported, but "every session that reaches the console without that stamp",
|
|
125
|
+
* which is exactly the path `refreshOrganizations`' ADR-0081 repair exists to
|
|
126
|
+
* serve.
|
|
78
127
|
*
|
|
79
128
|
* `isResolved` is deliberately true the moment `isAdmin` is true: a confirmed
|
|
80
129
|
* admin is a final answer, and the legs still in flight can only agree with it.
|
|
81
130
|
* Callers therefore never wait on a verdict they already have — an admin
|
|
82
|
-
* detected through `positions` pays nothing for this gate.
|
|
131
|
+
* detected through the rung or through `positions` pays nothing for this gate.
|
|
83
132
|
*/
|
|
84
133
|
export declare function useWorkspaceAdminStatus(): WorkspaceAdminStatus;
|
|
85
134
|
//# sourceMappingURL=useWorkspaceAdminStatus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWorkspaceAdminStatus.d.ts","sourceRoot":"","sources":["../src/useWorkspaceAdminStatus.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"useWorkspaceAdminStatus.d.ts","sourceRoot":"","sources":["../src/useWorkspaceAdminStatus.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsFH;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGG;AACH,wBAAgB,uBAAuB,IAAI,oBAAoB,CAmB9D"}
|
|
@@ -6,6 +6,20 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
import { useAuth } from './useAuth.js';
|
|
9
|
+
/**
|
|
10
|
+
* The vocabulary of the two SCALAR legs — a membership row's `role` (leg 1)
|
|
11
|
+
* and the stored `user.role` (leg 2).
|
|
12
|
+
*
|
|
13
|
+
* Both are single values written by a path the tenant does not control: leg 1
|
|
14
|
+
* is better-auth's `sys_member.role`, capped at the issuer's own grade on
|
|
15
|
+
* every issuance path; leg 2 is `sys_user.role`, which framework ADR-0092 D2's
|
|
16
|
+
* identity write guard refuses under a user context. A name found in either is
|
|
17
|
+
* therefore evidence.
|
|
18
|
+
*
|
|
19
|
+
* ⛔ This set is NOT the vocabulary for `user.positions[]` — see
|
|
20
|
+
* {@link ADMIN_POSITION_NAMES} for the narrower one that leg 3b uses, and the
|
|
21
|
+
* hook's docblock for why the two had to be separated (objectui#8291).
|
|
22
|
+
*/
|
|
9
23
|
const ADMIN_ROLES = new Set([
|
|
10
24
|
'owner',
|
|
11
25
|
'admin',
|
|
@@ -13,51 +27,138 @@ const ADMIN_ROLES = new Set([
|
|
|
13
27
|
'superadmin',
|
|
14
28
|
'platform_admin',
|
|
15
29
|
'system_admin',
|
|
16
|
-
// ADR-0068 canonical names
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
30
|
+
// ADR-0068 canonical names. `mapMembershipRole` normalizes raw better-auth
|
|
31
|
+
// owner/admin to org_owner/org_admin before they reach a session payload, so
|
|
32
|
+
// a membership role can arrive here in either spelling depending on which
|
|
33
|
+
// surface produced it. Accept both so admin detection survives the removal
|
|
34
|
+
// of the `user.role = 'admin'` overwrite footgun.
|
|
20
35
|
'org_owner',
|
|
21
36
|
'org_admin',
|
|
22
37
|
]);
|
|
23
38
|
/**
|
|
24
|
-
*
|
|
25
|
-
* `user.
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
39
|
+
* The vocabulary of leg 3b — the only names honoured when found in
|
|
40
|
+
* `user.positions[]`.
|
|
41
|
+
*
|
|
42
|
+
* Deliberately NOT {@link ADMIN_ROLES}. `positions[]` is a tenant-WRITABLE
|
|
43
|
+
* array (see the hook's docblock), so the question for each name is not "does
|
|
44
|
+
* it sound like an admin" but "does a trusted server derivation ever put it
|
|
45
|
+
* here". Decided name by name in objectui#8291:
|
|
46
|
+
*
|
|
47
|
+
* - `org_owner`, `org_admin` — KEPT. `resolveUserAuthzGrants` emits exactly
|
|
48
|
+
* these from the ACTIVE organization's `sys_member.role` through
|
|
49
|
+
* `mapMembershipRole`, so a hit is usually the real membership row arriving
|
|
50
|
+
* ahead of leg 1. A `sys_user_position` row CAN also spell them, but that
|
|
51
|
+
* row is written by a caller who already holds tenant-administration
|
|
52
|
+
* authority over the same organization (framework `DelegatedAdminGate`), so
|
|
53
|
+
* what they mint is a second spelling of an authority they have — not a
|
|
54
|
+
* crossing of any boundary. This is also the framework's own line: its
|
|
55
|
+
* four-site sweep left every TENANT_ADMIN arm untouched and moved only the
|
|
56
|
+
* platform ones.
|
|
57
|
+
* - `platform_admin` — DROPPED, and replaced by leg 3a. It is the name a
|
|
58
|
+
* tenant can mint to claim authority it does not have, and the array cannot
|
|
59
|
+
* tell a minted one from a genuine one: `resolveUserAuthzGrants` pushes the
|
|
60
|
+
* built-in name only when it is not already present, so both cases produce
|
|
61
|
+
* a byte-identical array.
|
|
62
|
+
* - `owner`, `admin`, `super_admin`, `superadmin`, `system_admin` — DROPPED.
|
|
63
|
+
* No server derivation emits any of them into `positions[]` at all: the
|
|
64
|
+
* membership leg normalizes `owner`/`admin` to `org_*` first, and the other
|
|
65
|
+
* three are not built-in identity names in any framework vocabulary. A hit
|
|
66
|
+
* on one could therefore ONLY be a `sys_user_position` row — all exposure,
|
|
67
|
+
* no signal. They stay in {@link ADMIN_ROLES}, where they are the raw
|
|
68
|
+
* scalars legs 1 and 2 legitimately read.
|
|
69
|
+
*/
|
|
70
|
+
const ADMIN_POSITION_NAMES = new Set([
|
|
71
|
+
'org_owner',
|
|
72
|
+
'org_admin',
|
|
73
|
+
]);
|
|
74
|
+
/**
|
|
75
|
+
* One name from either SCALAR source — a membership role or the stored
|
|
76
|
+
* `user.role` scalar. The two draw on one vocabulary by design (ADR-0068 D2
|
|
77
|
+
* maps a membership `owner`/`admin` onto the canonical `org_owner`/`org_admin`
|
|
78
|
+
* that {@link ADMIN_ROLES} also carries), so one predicate serves both.
|
|
29
79
|
*/
|
|
30
80
|
function isAdminRole(role) {
|
|
31
81
|
return typeof role === 'string' && ADMIN_ROLES.has(role.toLowerCase());
|
|
32
82
|
}
|
|
83
|
+
/** One entry of `user.positions[]`, judged against the narrower vocabulary. */
|
|
84
|
+
function isAdminPosition(position) {
|
|
85
|
+
return typeof position === 'string' && ADMIN_POSITION_NAMES.has(position.toLowerCase());
|
|
86
|
+
}
|
|
33
87
|
/**
|
|
34
88
|
* Whether the current user has owner/admin privileges, and whether that answer
|
|
35
89
|
* has finished resolving.
|
|
36
90
|
*
|
|
37
91
|
* Sources considered (any one is sufficient):
|
|
38
|
-
* -
|
|
39
|
-
* -
|
|
40
|
-
* that still store an admin role on the user row.
|
|
41
|
-
* - `user.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
92
|
+
* - LEG 1 — the active organization member row (multi-tenant mode).
|
|
93
|
+
* - LEG 2 — the top-level `user.role` scalar from the session: legacy
|
|
94
|
+
* deployments that still store an admin role on the user row.
|
|
95
|
+
* - LEG 3a — `user.isPlatformAdmin` from the session: the server's ADR-0095
|
|
96
|
+
* posture RUNG, and the ONLY leg that sees a platform administrator whose
|
|
97
|
+
* adminship comes from the `admin_full_access` permission set. On a
|
|
98
|
+
* single-tenant deployment there is no member row to read (leg 1) and the
|
|
99
|
+
* server deliberately no longer overwrites `user.role` (leg 2), so this
|
|
100
|
+
* flag is the whole signal for that viewer. Measured on a live protocol-17
|
|
101
|
+
* server in objectui#5389 — the captured payload there carries
|
|
102
|
+
* `isPlatformAdmin: true` — and pinned by
|
|
49
103
|
* `__tests__/workspaceAdminPositions-5389.test.tsx`.
|
|
104
|
+
* - LEG 3b — `user.positions[]` from the session, judged against
|
|
105
|
+
* {@link ADMIN_POSITION_NAMES} rather than {@link ADMIN_ROLES}: the
|
|
106
|
+
* canonical TENANT-scoped identity names the server derives from the active
|
|
107
|
+
* organization's membership row (ADR-0068 D1/D2, renamed from `roles` by
|
|
108
|
+
* ADR-0090 D3). This is what lets a tenant administrator resolve on the
|
|
109
|
+
* first frame instead of waiting for leg 1 (see the objectui#5619 section
|
|
110
|
+
* below).
|
|
111
|
+
*
|
|
112
|
+
* ## Why 3a and 3b are two legs and not one (objectui#8291)
|
|
113
|
+
*
|
|
114
|
+
* This docblock used to argue the opposite, and a future reader who finds that
|
|
115
|
+
* argument standing will re-introduce the defect it now describes. It said:
|
|
116
|
+
* do not read `user.isPlatformAdmin` alongside `positions`, because the server
|
|
117
|
+
* computes the flag as `'platform_admin' in positions` from the same
|
|
118
|
+
* expression, so reading both would be two spellings for one fact with no way
|
|
119
|
+
* to disagree usefully and every way to drift.
|
|
120
|
+
*
|
|
121
|
+
* **That was true and it is now false.** Framework objectstack#15948 (a
|
|
122
|
+
* declared BREAKING change) redefined what `positions[]` IS. It used to be the
|
|
123
|
+
* `sys_user.role` scalar split on commas; it is now built by
|
|
124
|
+
* `resolveUserAuthzGrants` and carries ADR-0057 D4 `sys_user_position`
|
|
125
|
+
* assignments. That table is `apiEnabled` and its `position` values are
|
|
126
|
+
* unconstrained, so a caller holding tenant-administration authority can mint
|
|
127
|
+
* a row spelling `platform_admin` for one of their own users — and the name
|
|
128
|
+
* lands on `positions[]` verbatim.
|
|
129
|
+
*
|
|
130
|
+
* The two therefore no longer say one thing:
|
|
131
|
+
*
|
|
132
|
+
* - `isPlatformAdmin` is `grants.posture === 'PLATFORM_ADMIN'` — derived from
|
|
133
|
+
* an UNSCOPED `admin_full_access` grant (or a verified email on the
|
|
134
|
+
* deployment's declared administrator list) and from nothing else. It is
|
|
135
|
+
* byte-for-byte what the server's own `hasPlatformAdminStanding` returns.
|
|
136
|
+
* - `positions[]` is the security AXIS, which is a wider thing: it is the set
|
|
137
|
+
* of names a request resolves to, including names a tenant wrote.
|
|
138
|
+
*
|
|
139
|
+
* They can now disagree, and when they do **the rung is right** — enforcement
|
|
140
|
+
* agrees with the rung, so the array's extra name buys nothing except a
|
|
141
|
+
* Console that paints platform-administrator surfaces at a principal every
|
|
142
|
+
* underlying call refuses. `resolve-authz-context.ts` states the rule at
|
|
143
|
+
* `hasPlatformAdminStanding`: read the RUNG, never
|
|
144
|
+
* `positions.includes('platform_admin')`. The framework moved four server-side
|
|
145
|
+
* sites onto it (`plugin-sharing`, `plugin-approvals`, `plugin-security`,
|
|
146
|
+
* `runtime`); this hook is the same read on the client side of the wire.
|
|
147
|
+
*
|
|
148
|
+
* ⛔ So: never put `platform_admin` back into {@link ADMIN_POSITION_NAMES},
|
|
149
|
+
* and never widen leg 3b back to {@link ADMIN_ROLES}. The name is not the
|
|
150
|
+
* authority. Every server that publishes `positions` publishes
|
|
151
|
+
* `isPlatformAdmin` beside it — `customSession` returns them in one object
|
|
152
|
+
* literal — so nothing is lost by reading the narrow one.
|
|
50
153
|
*
|
|
51
|
-
* `positions`
|
|
52
|
-
* alongside the retired `roles` (ADR-0090 D3 renamed
|
|
53
|
-
* window and bans resurrecting the old name as a
|
|
54
|
-
*
|
|
55
|
-
* server as `'platform_admin' in positions` from the same expression, so
|
|
56
|
-
* reading both would be two spellings for one fact with no way to disagree
|
|
57
|
-
* usefully and every way to drift.
|
|
154
|
+
* `positions` also remains the ONE published spelling of the array itself. It
|
|
155
|
+
* is deliberately not read alongside the retired `roles` (ADR-0090 D3 renamed
|
|
156
|
+
* with no deprecation window and bans resurrecting the old name as a
|
|
157
|
+
* fallback).
|
|
58
158
|
*
|
|
59
|
-
* In preview-mode / no-auth-enabled mode the provider seeds an admin user
|
|
60
|
-
* so this returns `isAdmin: true` for
|
|
159
|
+
* In preview-mode / no-auth-enabled mode the provider seeds an admin user
|
|
160
|
+
* (`role: 'admin'`, which leg 2 reads), so this returns `isAdmin: true` for
|
|
161
|
+
* dev/demo setups.
|
|
61
162
|
*
|
|
62
163
|
* ## Why this returns a pair and not a boolean (objectui#5619)
|
|
63
164
|
*
|
|
@@ -73,30 +174,35 @@ function isAdminRole(role) {
|
|
|
73
174
|
* console chrome dropped and re-added a nav entry, and `AppContent` fired a
|
|
74
175
|
* `<Navigate to="/home" replace>` that the later flip cannot undo.
|
|
75
176
|
*
|
|
76
|
-
* Legs 2 and
|
|
177
|
+
* Legs 2 and 3b DO cover that viewer whenever the session was minted with an
|
|
77
178
|
* active organization stamped on it — framework `auth-manager.ts` reads
|
|
78
179
|
* `session.activeOrganizationId` and, when it is set, maps the member row into
|
|
79
|
-
* `positions[]` as `org_owner`/`org_admin`.
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
180
|
+
* `positions[]` as `org_owner`/`org_admin`. Those two names are exactly why
|
|
181
|
+
* objectui#8291 kept leg 3b alive rather than deleting the array read
|
|
182
|
+
* outright. The window is therefore not "every tenant admin" as first
|
|
183
|
+
* reported, but "every session that reaches the console without that stamp",
|
|
184
|
+
* which is exactly the path `refreshOrganizations`' ADR-0081 repair exists to
|
|
185
|
+
* serve.
|
|
83
186
|
*
|
|
84
187
|
* `isResolved` is deliberately true the moment `isAdmin` is true: a confirmed
|
|
85
188
|
* admin is a final answer, and the legs still in flight can only agree with it.
|
|
86
189
|
* Callers therefore never wait on a verdict they already have — an admin
|
|
87
|
-
* detected through `positions` pays nothing for this gate.
|
|
190
|
+
* detected through the rung or through `positions` pays nothing for this gate.
|
|
88
191
|
*/
|
|
89
192
|
export function useWorkspaceAdminStatus() {
|
|
90
193
|
const { activeMember, user, isLoading, isMembershipResolved } = useAuth();
|
|
91
194
|
const positions = user?.positions;
|
|
92
195
|
const isAdmin = isAdminRole(activeMember?.role) ||
|
|
93
196
|
isAdminRole(user?.role) ||
|
|
94
|
-
|
|
197
|
+
// Leg 3a — `=== true` on purpose. A session that never published the flag
|
|
198
|
+
// must read as "no platform standing", not as a truthy unknown.
|
|
199
|
+
user?.isPlatformAdmin === true ||
|
|
200
|
+
(Array.isArray(positions) && positions.some(isAdminPosition));
|
|
95
201
|
if (isAdmin)
|
|
96
202
|
return { isAdmin: true, isResolved: true };
|
|
97
|
-
// Legs 2 and
|
|
98
|
-
// is settled once the organization/member pipeline has reached a
|
|
99
|
-
// state (`isMembershipResolved`). Both, because a viewer can be an
|
|
100
|
-
// through either.
|
|
203
|
+
// Legs 2, 3a and 3b are settled once the session has landed (`isLoading`);
|
|
204
|
+
// leg 1 is settled once the organization/member pipeline has reached a
|
|
205
|
+
// terminal state (`isMembershipResolved`). Both, because a viewer can be an
|
|
206
|
+
// admin through either.
|
|
101
207
|
return { isAdmin: false, isResolved: !isLoading && isMembershipResolved };
|
|
102
208
|
}
|