@object-ui/auth 17.5.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +600 -0
  2. package/README.md +245 -15
  3. package/dist/ActiveOrganizationStorage.d.ts +199 -0
  4. package/dist/ActiveOrganizationStorage.d.ts.map +1 -0
  5. package/dist/ActiveOrganizationStorage.js +584 -0
  6. package/dist/AuthContext.d.ts +23 -3
  7. package/dist/AuthContext.d.ts.map +1 -1
  8. package/dist/AuthGuard.d.ts +8 -1
  9. package/dist/AuthGuard.d.ts.map +1 -1
  10. package/dist/AuthGuard.js +16 -3
  11. package/dist/AuthProvider.d.ts +1 -1
  12. package/dist/AuthProvider.d.ts.map +1 -1
  13. package/dist/AuthProvider.js +274 -9
  14. package/dist/ForgotPasswordForm.d.ts +1 -1
  15. package/dist/ForgotPasswordForm.d.ts.map +1 -1
  16. package/dist/ForgotPasswordForm.js +5 -5
  17. package/dist/LoginForm.d.ts +11 -2
  18. package/dist/LoginForm.d.ts.map +1 -1
  19. package/dist/LoginForm.js +5 -6
  20. package/dist/PreviewBanner.js +1 -1
  21. package/dist/RegisterForm.d.ts +22 -3
  22. package/dist/RegisterForm.d.ts.map +1 -1
  23. package/dist/RegisterForm.js +6 -7
  24. package/dist/SocialSignInButtons.d.ts +9 -2
  25. package/dist/SocialSignInButtons.d.ts.map +1 -1
  26. package/dist/SocialSignInButtons.js +5 -5
  27. package/dist/UserMenu.d.ts +1 -1
  28. package/dist/UserMenu.js +3 -3
  29. package/dist/createAuthClient.d.ts +1 -1
  30. package/dist/createAuthClient.d.ts.map +1 -1
  31. package/dist/createAuthClient.js +42 -4
  32. package/dist/createAuthenticatedFetch.d.ts +9 -9
  33. package/dist/createAuthenticatedFetch.d.ts.map +1 -1
  34. package/dist/createAuthenticatedFetch.js +50 -38
  35. package/dist/index.d.ts +21 -19
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +34 -17
  38. package/dist/invitation-status.d.ts +59 -0
  39. package/dist/invitation-status.d.ts.map +1 -0
  40. package/dist/invitation-status.js +32 -0
  41. package/dist/types.d.ts +25 -5
  42. package/dist/types.d.ts.map +1 -1
  43. package/dist/useAuth.d.ts +1 -1
  44. package/dist/useAuth.d.ts.map +1 -1
  45. package/dist/useAuth.js +5 -1
  46. package/dist/useWorkspaceAdminStatus.d.ts +134 -0
  47. package/dist/useWorkspaceAdminStatus.d.ts.map +1 -0
  48. package/dist/useWorkspaceAdminStatus.js +208 -0
  49. package/package.json +6 -7
  50. package/dist/useIsWorkspaceAdmin.d.ts +0 -21
  51. package/dist/useIsWorkspaceAdmin.d.ts.map +0 -1
  52. package/dist/useIsWorkspaceAdmin.js +0 -47
@@ -0,0 +1,59 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ /**
9
+ * Invitation status vocabulary — the console's ONE entry point for it.
10
+ *
11
+ * ## Why this is a module and not a doc comment
12
+ *
13
+ * `AuthInvitation.status` was declared as an open `string` while its own doc
14
+ * comment enumerated exactly four members (objectui#3879). A comment cannot be
15
+ * enforced, so every consumer had to be liberal in turn: `InvitationsPage`
16
+ * carried a `default: 'secondary'` arm in its badge-variant switch and a
17
+ * `defaultValue: inv.status` that would render the raw wire string as UI copy —
18
+ * in all ten packs — for any value the enumeration did not cover. Declared =
19
+ * enforced (AGENTS.md #0.1): the union now lives in the type, and the wire
20
+ * boundary in `createAuthClient` is the one place an unvalidated string may
21
+ * become one.
22
+ *
23
+ * ## The vocabulary is CLOSED — and derived, not mirrored
24
+ *
25
+ * The producer is better-auth's organization plugin, whose own
26
+ * `InvitationStatus` is `'pending' | 'accepted' | 'rejected' | 'canceled'`
27
+ * (`better-auth/client/plugins`; the framework stores it in
28
+ * `sys_invitation.status`). This module BINDS that type instead of restating it,
29
+ * for the same reason `org-roles.ts` binds the spec's
30
+ * `BUILTIN_MEMBERSHIP_ROLES`: a member-for-member copy is precisely the state
31
+ * one upstream release away from drifting silently.
32
+ *
33
+ * The runtime list is derived from a total `Record` keyed by that union, so the
34
+ * compile-time half and the runtime half cannot disagree — a fifth status
35
+ * upstream fails to compile HERE (the map is missing a key) rather than slipping
36
+ * past the boundary check and out onto a badge.
37
+ *
38
+ * What stays LOCAL, deliberately: everything about *display*. The filter tabs'
39
+ * `StatusFilter` (which adds an `all` pseudo-member) and the badge variants are
40
+ * screen concerns and live with the screen — the same boundary `org-roles.ts`
41
+ * draws for its labels and grade ladder.
42
+ */
43
+ import type { InvitationStatus } from 'better-auth/client/plugins';
44
+ /**
45
+ * Status an organization invitation can carry — better-auth's own union, bound
46
+ * rather than copied.
47
+ */
48
+ export type AuthInvitationStatus = InvitationStatus;
49
+ /** Every status an invitation can carry, in the order the screens list them. */
50
+ export declare const AUTH_INVITATION_STATUSES: readonly AuthInvitationStatus[];
51
+ /**
52
+ * Narrow an unvalidated wire value onto the closed status set.
53
+ *
54
+ * The ONE place a `string` may become an `AuthInvitationStatus`. Everything
55
+ * downstream reads the narrowed type and therefore needs no fallback arm — which
56
+ * is the whole point: a tolerant consumer is where an unexpected value hides.
57
+ */
58
+ export declare function isAuthInvitationStatus(value: unknown): value is AuthInvitationStatus;
59
+ //# sourceMappingURL=invitation-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invitation-status.d.ts","sourceRoot":"","sources":["../src/invitation-status.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAcpD,gFAAgF;AAChF,eAAO,MAAM,wBAAwB,EAAE,SAAS,oBAAoB,EACrC,CAAC;AAKhC;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAEpF"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ /**
9
+ * Total map over the union — the compile-time half of the pin. Values are the
10
+ * members themselves so the runtime list below is DERIVED rather than restated
11
+ * (one literal list, not two).
12
+ */
13
+ const STATUS_MEMBERS = {
14
+ pending: 'pending',
15
+ accepted: 'accepted',
16
+ rejected: 'rejected',
17
+ canceled: 'canceled',
18
+ };
19
+ /** Every status an invitation can carry, in the order the screens list them. */
20
+ export const AUTH_INVITATION_STATUSES = Object.values(STATUS_MEMBERS);
21
+ /** Membership test backing the guard. `Set` so the check stays O(1) per row. */
22
+ const STATUS_LOOKUP = new Set(AUTH_INVITATION_STATUSES);
23
+ /**
24
+ * Narrow an unvalidated wire value onto the closed status set.
25
+ *
26
+ * The ONE place a `string` may become an `AuthInvitationStatus`. Everything
27
+ * downstream reads the narrowed type and therefore needs no fallback arm — which
28
+ * is the whole point: a tolerant consumer is where an unexpected value hides.
29
+ */
30
+ export function isAuthInvitationStatus(value) {
31
+ return typeof value === 'string' && STATUS_LOOKUP.has(value);
32
+ }
package/dist/types.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  import type React from 'react';
9
9
  import type { AuthUser as SpecAuthUser, DelegableScope, DelegableAdminScope } from '@objectstack/spec/contracts';
10
10
  import type { TenancyPosture } from '@objectstack/spec/security';
11
+ import type { AuthInvitationStatus } from './invitation-status.js';
11
12
  /**
12
13
  * Authentication types for @object-ui/auth
13
14
  */
@@ -55,8 +56,6 @@ export interface AuthUser extends SpecAuthUser {
55
56
  image?: string;
56
57
  /** Primary role */
57
58
  role?: string;
58
- /** All assigned roles */
59
- roles?: string[];
60
59
  /** Email verification status */
61
60
  emailVerified?: boolean;
62
61
  /** Additional user metadata */
@@ -121,6 +120,19 @@ export interface SignUpData {
121
120
  name: string;
122
121
  email: string;
123
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;
124
136
  }
125
137
  /** Auth client configuration */
126
138
  export interface AuthClientConfig {
@@ -223,7 +235,7 @@ export interface AuthPublicConfig {
223
235
  * better-auth admin plugin mounted server-side (`auth.plugins.admin`;
224
236
  * SCIM forces it on). Gates the admin user-management surfaces — the
225
237
  * sys_user create/set-password actions and the identity import wizard
226
- * entry (framework#2766 / #2782).
238
+ * entry (framework#2766 / objectstack-ai/objectstack#2782).
227
239
  */
228
240
  admin?: boolean;
229
241
  /**
@@ -442,8 +454,16 @@ export interface AuthInvitation {
442
454
  email: string;
443
455
  /** Role to be granted upon acceptance */
444
456
  role: string;
445
- /** Status: 'pending' | 'accepted' | 'rejected' | 'canceled' */
446
- status: string;
457
+ /**
458
+ * Lifecycle status, as the CLOSED set better-auth stores.
459
+ *
460
+ * Was an open `string` with the four members living in this comment, which
461
+ * left every consumer to be liberal about the fifth value that comment could
462
+ * not forbid (objectui#3879). The union is `AuthInvitationStatus` now, and
463
+ * `createAuthClient` narrows the wire value onto it at the boundary — so a
464
+ * screen reading this field can switch on it exhaustively.
465
+ */
466
+ status: AuthInvitationStatus;
447
467
  /** Expiration timestamp */
448
468
  expiresAt?: string;
449
469
  /** ID of the inviting user */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"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CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iCAAiC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,0BAA0B;AAC1B,MAAM,WAAW,sBAAsB;IACrC,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB;IAClC,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,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"}
package/dist/useAuth.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
- import { type AuthContextValue } from './AuthContext';
8
+ import { type AuthContextValue } from './AuthContext.js';
9
9
  /**
10
10
  * Hook to access authentication state and methods.
11
11
  * Must be used within an AuthProvider.
@@ -1 +1 @@
1
- {"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../src/useAuth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAW,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE/D;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,IAAI,gBAAgB,CA6D1C"}
1
+ {"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../src/useAuth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAW,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,IAAI,gBAAgB,CAiE1C"}
package/dist/useAuth.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  import { useContext } from 'react';
9
- import { AuthCtx } from './AuthContext';
9
+ import { AuthCtx } from './AuthContext.js';
10
10
  /**
11
11
  * Hook to access authentication state and methods.
12
12
  * Must be used within an AuthProvider.
@@ -60,6 +60,10 @@ export function useAuth() {
60
60
  activeOrganization: null,
61
61
  activeMember: null,
62
62
  isOrganizationsLoading: false,
63
+ // Nothing to resolve without a provider — same reasoning as `isLoading`
64
+ // above, which is `false` here for the same reason. A consumer gating on
65
+ // this must render through in a provider-less embed, not hang.
66
+ isMembershipResolved: true,
63
67
  switchOrganization: async () => { throw new Error('useAuth must be used within an AuthProvider'); },
64
68
  createOrganization: async () => { throw new Error('useAuth must be used within an AuthProvider'); },
65
69
  refreshOrganizations: async () => { throw new Error('useAuth must be used within an AuthProvider'); },
@@ -0,0 +1,134 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ /**
9
+ * The workspace-admin verdict AND whether it is worth acting on yet.
10
+ *
11
+ * These are two different facts and they were one boolean until objectui#5619.
12
+ * See {@link useWorkspaceAdminStatus} for why collapsing them was a defect.
13
+ */
14
+ export interface WorkspaceAdminStatus {
15
+ /**
16
+ * True only when adminship is CONFIRMED by one of the legs below.
17
+ * While `isResolved` is false this is `false` because nothing has said
18
+ * otherwise yet — NOT because the viewer is known not to be an admin.
19
+ */
20
+ isAdmin: boolean;
21
+ /**
22
+ * Whether every input `isAdmin` depends on has arrived. Gate any branch
23
+ * whose wrong side is expensive — a refusal screen, a `<Navigate>`, a nav
24
+ * entry that would have to be added back — on this being true.
25
+ */
26
+ isResolved: boolean;
27
+ }
28
+ /**
29
+ * Whether the current user has owner/admin privileges, and whether that answer
30
+ * has finished resolving.
31
+ *
32
+ * Sources considered (any one is sufficient):
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
+ * `__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).
52
+ *
53
+ * ## Why 3a and 3b are two legs and not one (objectui#8291)
54
+ *
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.
103
+ *
104
+ * ## Why this returns a pair and not a boolean (objectui#5619)
105
+ *
106
+ * It used to return a bare `boolean`, which gave "not resolved yet" and
107
+ * "resolved: not an admin" the same answer — `false`. Leg 1 is not settled
108
+ * when a console page first mounts: `AuthProvider.refreshActiveMember` runs
109
+ * from its own effect, keyed on `activeOrganization`, which itself appears
110
+ * only after `listOrganizations()` → `getActiveOrganization()` (→ the ADR-0081
111
+ * single-membership `setActiveOrganization()` repair) resolve. So an
112
+ * administrator whose adminship lives ONLY in the member row rendered at least
113
+ * once as a non-admin, and every gate downstream acted on it: two marketplace
114
+ * surfaces painted `MarketplaceAccessDenied` at a real administrator, the
115
+ * console chrome dropped and re-added a nav entry, and `AppContent` fired a
116
+ * `<Navigate to="/home" replace>` that the later flip cannot undo.
117
+ *
118
+ * Legs 2 and 3b DO cover that viewer whenever the session was minted with an
119
+ * active organization stamped on it — framework `auth-manager.ts` reads
120
+ * `session.activeOrganizationId` and, when it is set, maps the member row into
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.
127
+ *
128
+ * `isResolved` is deliberately true the moment `isAdmin` is true: a confirmed
129
+ * admin is a final answer, and the legs still in flight can only agree with it.
130
+ * Callers therefore never wait on a verdict they already have — an admin
131
+ * detected through the rung or through `positions` pays nothing for this gate.
132
+ */
133
+ export declare function useWorkspaceAdminStatus(): WorkspaceAdminStatus;
134
+ //# sourceMappingURL=useWorkspaceAdminStatus.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
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
+ */
23
+ const ADMIN_ROLES = new Set([
24
+ 'owner',
25
+ 'admin',
26
+ 'super_admin',
27
+ 'superadmin',
28
+ 'platform_admin',
29
+ 'system_admin',
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.
35
+ 'org_owner',
36
+ 'org_admin',
37
+ ]);
38
+ /**
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.
79
+ */
80
+ function isAdminRole(role) {
81
+ return typeof role === 'string' && ADMIN_ROLES.has(role.toLowerCase());
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
+ }
87
+ /**
88
+ * Whether the current user has owner/admin privileges, and whether that answer
89
+ * has finished resolving.
90
+ *
91
+ * Sources considered (any one is sufficient):
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
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.
153
+ *
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).
158
+ *
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.
162
+ *
163
+ * ## Why this returns a pair and not a boolean (objectui#5619)
164
+ *
165
+ * It used to return a bare `boolean`, which gave "not resolved yet" and
166
+ * "resolved: not an admin" the same answer — `false`. Leg 1 is not settled
167
+ * when a console page first mounts: `AuthProvider.refreshActiveMember` runs
168
+ * from its own effect, keyed on `activeOrganization`, which itself appears
169
+ * only after `listOrganizations()` → `getActiveOrganization()` (→ the ADR-0081
170
+ * single-membership `setActiveOrganization()` repair) resolve. So an
171
+ * administrator whose adminship lives ONLY in the member row rendered at least
172
+ * once as a non-admin, and every gate downstream acted on it: two marketplace
173
+ * surfaces painted `MarketplaceAccessDenied` at a real administrator, the
174
+ * console chrome dropped and re-added a nav entry, and `AppContent` fired a
175
+ * `<Navigate to="/home" replace>` that the later flip cannot undo.
176
+ *
177
+ * Legs 2 and 3b DO cover that viewer whenever the session was minted with an
178
+ * active organization stamped on it — framework `auth-manager.ts` reads
179
+ * `session.activeOrganizationId` and, when it is set, maps the member row into
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.
186
+ *
187
+ * `isResolved` is deliberately true the moment `isAdmin` is true: a confirmed
188
+ * admin is a final answer, and the legs still in flight can only agree with it.
189
+ * Callers therefore never wait on a verdict they already have — an admin
190
+ * detected through the rung or through `positions` pays nothing for this gate.
191
+ */
192
+ export function useWorkspaceAdminStatus() {
193
+ const { activeMember, user, isLoading, isMembershipResolved } = useAuth();
194
+ const positions = user?.positions;
195
+ const isAdmin = isAdminRole(activeMember?.role) ||
196
+ isAdminRole(user?.role) ||
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));
201
+ if (isAdmin)
202
+ return { isAdmin: true, isResolved: true };
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.
207
+ return { isAdmin: false, isResolved: !isLoading && isMembershipResolved };
208
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/auth",
3
- "version": "17.5.0",
3
+ "version": "17.7.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Authentication system for Object UI with AuthProvider, useAuth hook, AuthGuard, and form components.",
@@ -30,9 +30,8 @@
30
30
  "react": "^18.0.0 || ^19.0.0"
31
31
  },
32
32
  "dependencies": {
33
- "@objectstack/spec": "^17.0.0-rc.6",
34
- "better-auth": "^1.6.26",
35
- "@object-ui/types": "17.5.0"
33
+ "@objectstack/spec": "^17.0.0",
34
+ "better-auth": "^1.7.2"
36
35
  },
37
36
  "devDependencies": {
38
37
  "@types/react": "19.2.18",
@@ -62,9 +61,9 @@
62
61
  "access": "public"
63
62
  },
64
63
  "scripts": {
65
- "build": "tsc",
66
- "clean": "rm -rf dist",
67
- "test": "vitest run",
64
+ "build": "tsc && node ../../scripts/check-dist-completeness.mjs",
65
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
66
+ "test": "vitest run --root ../.. packages/auth/",
68
67
  "type-check": "tsc --noEmit && tsc -p tsconfig.test.json",
69
68
  "lint": "eslint ."
70
69
  }
@@ -1,21 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- /**
9
- * Returns true when the current user has owner/admin privileges.
10
- *
11
- * Sources considered (any one is sufficient):
12
- * - The active organization member row (multi-tenant mode).
13
- * - The top-level `user.role` / `user.roles` from the session — this covers
14
- * platform / system administrators in single-tenant deployments where
15
- * there is no `activeMember` row to read a role from.
16
- *
17
- * In preview-mode / no-auth-enabled mode the provider seeds an admin user,
18
- * so this returns `true` for dev/demo setups.
19
- */
20
- export declare function useIsWorkspaceAdmin(): boolean;
21
- //# sourceMappingURL=useIsWorkspaceAdmin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIsWorkspaceAdmin.d.ts","sourceRoot":"","sources":["../src/useIsWorkspaceAdmin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuBH;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAM7C"}