hazo_auth 9.0.1 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +39 -11
  2. package/SETUP_CHECKLIST.md +35 -16
  3. package/cli-src/cli/init_users.ts +40 -48
  4. package/cli-src/lib/auth/auth_types.ts +0 -2
  5. package/cli-src/lib/auth/hazo_get_auth.server.ts +31 -25
  6. package/cli-src/lib/auth/hazo_get_tenant_auth.server.ts +9 -13
  7. package/cli-src/lib/config/config_loader.server.ts +41 -3
  8. package/cli-src/lib/config/hazo_auth_core_config.ts +1 -1
  9. package/cli-src/lib/constants.ts +2 -0
  10. package/cli-src/lib/hazo_connect_setup.server.ts +20 -2
  11. package/cli-src/lib/profile_pic_menu_config.server.ts +4 -3
  12. package/cli-src/lib/schema/sqlite_schema.ts +0 -4
  13. package/cli-src/lib/scope_hierarchy_config.server.ts +1 -9
  14. package/cli-src/lib/services/invitation_service.ts +1 -1
  15. package/cli-src/lib/services/scope_service.ts +2 -76
  16. package/cli-src/lib/services/user_scope_service.ts +7 -61
  17. package/config/hazo_auth_config.example.ini +3 -1
  18. package/dist/cli/init_users.d.ts.map +1 -1
  19. package/dist/cli/init_users.js +42 -42
  20. package/dist/client.d.ts +1 -1
  21. package/dist/client.d.ts.map +1 -1
  22. package/dist/client.js +1 -1
  23. package/dist/components/layouts/shared/components/profile_pic_menu.d.ts.map +1 -1
  24. package/dist/components/layouts/shared/components/profile_pic_menu.js +7 -1
  25. package/dist/components/ui/input-otp.d.ts +2 -2
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +1 -1
  29. package/dist/lib/auth/auth_types.d.ts +0 -2
  30. package/dist/lib/auth/auth_types.d.ts.map +1 -1
  31. package/dist/lib/auth/hazo_get_auth.server.d.ts.map +1 -1
  32. package/dist/lib/auth/hazo_get_auth.server.js +27 -19
  33. package/dist/lib/auth/hazo_get_tenant_auth.server.d.ts.map +1 -1
  34. package/dist/lib/auth/hazo_get_tenant_auth.server.js +10 -10
  35. package/dist/lib/config/config_loader.server.d.ts.map +1 -1
  36. package/dist/lib/config/config_loader.server.js +38 -3
  37. package/dist/lib/config/hazo_auth_core_config.js +1 -1
  38. package/dist/lib/constants.d.ts +1 -0
  39. package/dist/lib/constants.d.ts.map +1 -1
  40. package/dist/lib/constants.js +1 -0
  41. package/dist/lib/hazo_connect_setup.server.d.ts +1 -0
  42. package/dist/lib/hazo_connect_setup.server.d.ts.map +1 -1
  43. package/dist/lib/hazo_connect_setup.server.js +15 -2
  44. package/dist/lib/profile_pic_menu_config.server.d.ts +2 -1
  45. package/dist/lib/profile_pic_menu_config.server.d.ts.map +1 -1
  46. package/dist/lib/profile_pic_menu_config.server.js +1 -1
  47. package/dist/lib/schema/sqlite_schema.d.ts +1 -1
  48. package/dist/lib/schema/sqlite_schema.d.ts.map +1 -1
  49. package/dist/lib/schema/sqlite_schema.js +0 -4
  50. package/dist/lib/scope_hierarchy_config.server.d.ts +0 -2
  51. package/dist/lib/scope_hierarchy_config.server.d.ts.map +1 -1
  52. package/dist/lib/scope_hierarchy_config.server.js +1 -3
  53. package/dist/lib/services/invitation_service.d.ts +1 -1
  54. package/dist/lib/services/invitation_service.js +1 -1
  55. package/dist/lib/services/scope_service.d.ts +1 -14
  56. package/dist/lib/services/scope_service.d.ts.map +1 -1
  57. package/dist/lib/services/scope_service.js +2 -67
  58. package/dist/lib/services/user_scope_service.d.ts +5 -12
  59. package/dist/lib/services/user_scope_service.d.ts.map +1 -1
  60. package/dist/lib/services/user_scope_service.js +8 -45
  61. package/dist/server/routes/invitations.d.ts +1 -1
  62. package/dist/server/routes/invitations.d.ts.map +1 -1
  63. package/dist/server/routes/invitations.js +12 -11
  64. package/dist/server/routes/user_management_users.d.ts +1 -1
  65. package/package.json +15 -15
@@ -2,11 +2,6 @@ import { createCrudService } from "hazo_connect/server";
2
2
  import { create_app_logger } from "../app_logger.js";
3
3
  import { sanitize_error_for_user } from "../utils/error_sanitizer.js";
4
4
  // section: constants
5
- /**
6
- * Super admin scope ID - special UUID for system-level administrators
7
- * Users assigned to this scope have global access
8
- */
9
- export const SUPER_ADMIN_SCOPE_ID = "00000000-0000-0000-0000-000000000000";
10
5
  /**
11
6
  * Default system scope ID - for non-multi-tenancy mode
12
7
  * All users are assigned to this scope when multi-tenancy is disabled
@@ -52,12 +47,6 @@ export function extract_branding(scope) {
52
47
  export function has_branding(scope) {
53
48
  return !!(scope.logo_url || scope.primary_color || scope.secondary_color || scope.tagline);
54
49
  }
55
- /**
56
- * Checks if the given scope_id is the super admin scope
57
- */
58
- export function is_super_admin_scope(scope_id) {
59
- return scope_id === SUPER_ADMIN_SCOPE_ID;
60
- }
61
50
  /**
62
51
  * Checks if the given scope_id is the default system scope
63
52
  */
@@ -65,10 +54,10 @@ export function is_default_system_scope(scope_id) {
65
54
  return scope_id === DEFAULT_SYSTEM_SCOPE_ID;
66
55
  }
67
56
  /**
68
- * Checks if the given scope_id is a system scope (super admin or default system)
57
+ * Checks if the given scope_id is a system scope (default system)
69
58
  */
70
59
  export function is_system_scope(scope_id) {
71
- return is_super_admin_scope(scope_id) || is_default_system_scope(scope_id);
60
+ return is_default_system_scope(scope_id);
72
61
  }
73
62
  // section: crud operations
74
63
  /**
@@ -605,60 +594,6 @@ export async function get_scope_tree(adapter, root_scope_id) {
605
594
  };
606
595
  }
607
596
  }
608
- /**
609
- * Ensures the super admin scope exists
610
- */
611
- export async function ensure_super_admin_scope(adapter) {
612
- try {
613
- // Check if already exists
614
- const existing = await get_scope_by_id(adapter, SUPER_ADMIN_SCOPE_ID);
615
- if (existing.success && existing.scope) {
616
- return existing;
617
- }
618
- // Create it
619
- const scope_service = createCrudService(adapter, "hazo_scopes");
620
- const now = new Date().toISOString();
621
- const inserted = await scope_service.insert({
622
- id: SUPER_ADMIN_SCOPE_ID,
623
- name: "Super Admin",
624
- level: "system",
625
- parent_id: null,
626
- logo_url: null,
627
- primary_color: null,
628
- secondary_color: null,
629
- tagline: null,
630
- created_at: now,
631
- changed_at: now,
632
- });
633
- if (!Array.isArray(inserted) || inserted.length === 0) {
634
- return {
635
- success: false,
636
- error: "Failed to create super admin scope",
637
- };
638
- }
639
- return {
640
- success: true,
641
- scope: normalize_scope_record(inserted[0]),
642
- };
643
- }
644
- catch (error) {
645
- const logger = create_app_logger();
646
- const error_message = sanitize_error_for_user(error, {
647
- logToConsole: true,
648
- logToLogger: true,
649
- logger,
650
- context: {
651
- filename: "scope_service.ts",
652
- line_number: 0,
653
- operation: "ensure_super_admin_scope",
654
- },
655
- });
656
- return {
657
- success: false,
658
- error: error_message,
659
- };
660
- }
661
- }
662
597
  /**
663
598
  * Ensures the default system scope exists
664
599
  */
@@ -20,7 +20,6 @@ export type ScopeAccessCheckResult = {
20
20
  scope_name?: string;
21
21
  };
22
22
  user_scopes?: UserScope[];
23
- is_super_admin?: boolean;
24
23
  };
25
24
  export type AssignUserScopeData = {
26
25
  user_id: string;
@@ -52,10 +51,6 @@ export declare function update_user_scopes(adapter: HazoConnectAdapter, user_id:
52
51
  scope_id: string;
53
52
  role_id: string;
54
53
  }>): Promise<UserScopeResult>;
55
- /**
56
- * Checks if a user is a super admin (has super admin scope assigned)
57
- */
58
- export declare function is_user_super_admin(adapter: HazoConnectAdapter, user_id: string): Promise<boolean>;
59
54
  /**
60
55
  * Checks if a user has any scope assigned
61
56
  */
@@ -63,9 +58,11 @@ export declare function user_has_any_scope(adapter: HazoConnectAdapter, user_id:
63
58
  /**
64
59
  * Checks if a user has access to a specific scope
65
60
  * Access is granted if:
66
- * 1. User is a super admin (has super admin scope)
67
- * 2. User has the exact scope assigned
68
- * 3. User has access to an ancestor scope (inherited access)
61
+ * 1. User has the exact scope assigned
62
+ * 2. User has access to an ancestor scope (inherited access)
63
+ *
64
+ * Global admin access (hazo_org_global_admin permission) is handled upstream
65
+ * in hazo_get_auth before this function is called.
69
66
  *
70
67
  * @param adapter - HazoConnect adapter
71
68
  * @param user_id - User ID to check
@@ -85,8 +82,4 @@ export declare function get_user_direct_scopes(adapter: HazoConnectAdapter, user
85
82
  }>;
86
83
  error?: string;
87
84
  }>;
88
- /**
89
- * Assigns super admin scope to a user
90
- */
91
- export declare function assign_super_admin_scope(adapter: HazoConnectAdapter, user_id: string, role_id: string): Promise<UserScopeResult>;
92
85
  //# sourceMappingURL=user_scope_service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"user_scope_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/user_scope_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAyBvD,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAA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AAO,EAAE,MAAM,GACd,OAAO,CAAC;IACT,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CA4CD;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,CAAC,CAO1B"}
1
+ {"version":3,"file":"user_scope_service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/user_scope_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAuBvD,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC;CAC3B,CAAC;AAEF,M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1C,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IACT,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CA4CD"}
@@ -1,7 +1,7 @@
1
1
  import { createCrudService } from "hazo_connect/server";
2
2
  import { create_app_logger } from "../app_logger.js";
3
3
  import { sanitize_error_for_user } from "../utils/error_sanitizer.js";
4
- import { get_scope_by_id, get_scope_ancestors, get_root_scope_id, SUPER_ADMIN_SCOPE_ID, is_super_admin_scope, } from "./scope_service.js";
4
+ import { get_scope_by_id, get_scope_ancestors, get_root_scope_id, } from "./scope_service.js";
5
5
  // section: constants
6
6
  /**
7
7
  * CRUD service options for hazo_user_scopes table
@@ -274,21 +274,6 @@ export async function update_user_scopes(adapter, user_id, new_scopes) {
274
274
  };
275
275
  }
276
276
  }
277
- /**
278
- * Checks if a user is a super admin (has super admin scope assigned)
279
- */
280
- export async function is_user_super_admin(adapter, user_id) {
281
- try {
282
- const user_scopes_result = await get_user_scopes(adapter, user_id);
283
- if (!user_scopes_result.success || !user_scopes_result.scopes) {
284
- return false;
285
- }
286
- return user_scopes_result.scopes.some((scope) => is_super_admin_scope(scope.scope_id));
287
- }
288
- catch (_a) {
289
- return false;
290
- }
291
- }
292
277
  /**
293
278
  * Checks if a user has any scope assigned
294
279
  */
@@ -306,9 +291,11 @@ export async function user_has_any_scope(adapter, user_id) {
306
291
  /**
307
292
  * Checks if a user has access to a specific scope
308
293
  * Access is granted if:
309
- * 1. User is a super admin (has super admin scope)
310
- * 2. User has the exact scope assigned
311
- * 3. User has access to an ancestor scope (inherited access)
294
+ * 1. User has the exact scope assigned
295
+ * 2. User has access to an ancestor scope (inherited access)
296
+ *
297
+ * Global admin access (hazo_org_global_admin permission) is handled upstream
298
+ * in hazo_get_auth before this function is called.
312
299
  *
313
300
  * @param adapter - HazoConnect adapter
314
301
  * @param user_id - User ID to check
@@ -323,20 +310,7 @@ export async function check_user_scope_access(adapter, user_id, target_scope_id)
323
310
  return { has_access: false };
324
311
  }
325
312
  const user_scopes = user_scopes_result.scopes;
326
- // Check 1: Is user a super admin?
327
- const has_super_admin = user_scopes.some((scope) => is_super_admin_scope(scope.scope_id));
328
- if (has_super_admin) {
329
- return {
330
- has_access: true,
331
- access_via: {
332
- scope_id: SUPER_ADMIN_SCOPE_ID,
333
- scope_name: "Super Admin",
334
- },
335
- user_scopes,
336
- is_super_admin: true,
337
- };
338
- }
339
- // Check 2: Does user have exact scope assigned?
313
+ // Check 1: Does user have exact scope assigned?
340
314
  for (const user_scope of user_scopes) {
341
315
  if (user_scope.scope_id === target_scope_id) {
342
316
  const scope_result = await get_scope_by_id(adapter, target_scope_id);
@@ -352,7 +326,7 @@ export async function check_user_scope_access(adapter, user_id, target_scope_id)
352
326
  };
353
327
  }
354
328
  }
355
- // Check 3: Does user have access via an ancestor scope?
329
+ // Check 2: Does user have access via an ancestor scope?
356
330
  const ancestors_result = await get_scope_ancestors(adapter, target_scope_id);
357
331
  if (ancestors_result.success && ancestors_result.scopes) {
358
332
  for (const ancestor of ancestors_result.scopes) {
@@ -436,14 +410,3 @@ export async function get_user_direct_scopes(adapter, user_id) {
436
410
  };
437
411
  }
438
412
  }
439
- /**
440
- * Assigns super admin scope to a user
441
- */
442
- export async function assign_super_admin_scope(adapter, user_id, role_id) {
443
- return assign_user_scope(adapter, {
444
- user_id,
445
- scope_id: SUPER_ADMIN_SCOPE_ID,
446
- root_scope_id: SUPER_ADMIN_SCOPE_ID,
447
- role_id,
448
- });
449
- }
@@ -5,7 +5,7 @@ export declare const dynamic = "force-dynamic";
5
5
  * Query params:
6
6
  * - scope_id: Filter by scope (optional, required for non-super-admins)
7
7
  * - status: Filter by status (optional: PENDING, ACCEPTED, EXPIRED, REVOKED)
8
- * Super admins can see all invitations, others can only see invitations for their scopes
8
+ * Global admins can see all invitations, others can only see invitations for their scopes
9
9
  */
10
10
  export declare function GET(request: NextRequest): Promise<NextResponse<{
11
11
  error: string;
@@ -1 +1 @@
1
- {"version":3,"file":"invitations.d.ts","sourceRoot":"","sources":["../../../src/server/routes/invitations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAmBxD,eAAO,MAAM,OAAO,kBAAkB,CAAC;AAGvC;;;;;;GAMG;AACH,wBAAsB,GAAG,CAAC,OAAO,EAAE,WAAW;;;;;IAqH7C;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW;;;;;IAoG9C;AAED;;;GAGG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,WAAW;;;;;IAkG/C;AAED;;;GAGG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,WAAW;;;;IA2FhD"}
1
+ {"version":3,"file":"invitations.d.ts","sourceRoot":"","sources":["../../../src/server/routes/invitations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAiBxD,eAAO,MAAM,OAAO,kBAAkB,CAAC;AAGvC;;;;;;GAMG;AACH,wBAAsB,GAAG,CAAC,OAAO,EAAE,WAAW;;;;;IAqH7C;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW;;;;;IAoG9C;AAED;;;GAGG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,WAAW;;;;;IAkG/C;AAED;;;GAGG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,WAAW;;;;IA2FhD"}
@@ -6,7 +6,8 @@ import { create_app_logger } from "../../lib/app_logger.js";
6
6
  import { get_filename, get_line_number } from "../../lib/utils/api_route_helpers.js";
7
7
  import { hazo_get_auth } from "../../lib/auth/hazo_get_auth.server.js";
8
8
  import { create_invitation, list_invitations_by_scope, list_all_invitations, revoke_invitation, get_invitation_by_id, } from "../../lib/services/invitation_service.js";
9
- import { is_user_super_admin, get_user_scopes, } from "../../lib/services/user_scope_service.js";
9
+ import { get_user_scopes } from "../../lib/services/user_scope_service.js";
10
+ import { GLOBAL_ADMIN_PERMISSION } from "../../lib/constants.js";
10
11
  // section: route_config
11
12
  export const dynamic = "force-dynamic";
12
13
  // section: api_handler
@@ -15,7 +16,7 @@ export const dynamic = "force-dynamic";
15
16
  * Query params:
16
17
  * - scope_id: Filter by scope (optional, required for non-super-admins)
17
18
  * - status: Filter by status (optional: PENDING, ACCEPTED, EXPIRED, REVOKED)
18
- * Super admins can see all invitations, others can only see invitations for their scopes
19
+ * Global admins can see all invitations, others can only see invitations for their scopes
19
20
  */
20
21
  export async function GET(request) {
21
22
  var _a, _b;
@@ -34,11 +35,11 @@ export async function GET(request) {
34
35
  const status_param = searchParams.get("status");
35
36
  const status = status_param;
36
37
  const hazoConnect = get_hazo_connect_instance();
37
- // Check if user is super admin
38
- const is_super = await is_user_super_admin(hazoConnect, auth.user.id);
38
+ // Check if user is a global admin
39
+ const is_super = auth.permissions.includes(GLOBAL_ADMIN_PERMISSION);
39
40
  let result;
40
41
  if (is_super) {
41
- // Super admin can see all invitations
42
+ // Global admin can see all invitations
42
43
  if (scope_id) {
43
44
  result = await list_invitations_by_scope(hazoConnect, scope_id, status);
44
45
  }
@@ -124,8 +125,8 @@ export async function POST(request) {
124
125
  return NextResponse.json({ error: "Invalid email address format" }, { status: 400 });
125
126
  }
126
127
  const hazoConnect = get_hazo_connect_instance();
127
- // Check if user is super admin or has access to the scope
128
- const is_super = await is_user_super_admin(hazoConnect, auth.user.id);
128
+ // Check if user is a global admin or has access to the scope
129
+ const is_super = auth.permissions.includes(GLOBAL_ADMIN_PERMISSION);
129
130
  if (!is_super) {
130
131
  const user_scopes = await get_user_scopes(hazoConnect, auth.user.id);
131
132
  const has_scope_access = (_a = user_scopes.scopes) === null || _a === void 0 ? void 0 : _a.some((s) => s.scope_id === scope_id);
@@ -196,8 +197,8 @@ export async function PATCH(request) {
196
197
  if (!invitation_result.success || !invitation_result.invitation) {
197
198
  return NextResponse.json({ error: "Invitation not found" }, { status: 404 });
198
199
  }
199
- // Check if user is super admin or has access to the invitation's scope
200
- const is_super = await is_user_super_admin(hazoConnect, auth.user.id);
200
+ // Check if user is a global admin or has access to the invitation's scope
201
+ const is_super = auth.permissions.includes(GLOBAL_ADMIN_PERMISSION);
201
202
  if (!is_super) {
202
203
  const user_scopes = await get_user_scopes(hazoConnect, auth.user.id);
203
204
  const has_scope_access = (_a = user_scopes.scopes) === null || _a === void 0 ? void 0 : _a.some((s) => { var _a; return s.scope_id === ((_a = invitation_result.invitation) === null || _a === void 0 ? void 0 : _a.scope_id); });
@@ -257,8 +258,8 @@ export async function DELETE(request) {
257
258
  if (!invitation_result.success || !invitation_result.invitation) {
258
259
  return NextResponse.json({ error: "Invitation not found" }, { status: 404 });
259
260
  }
260
- // Check if user is super admin or has access to the invitation's scope
261
- const is_super = await is_user_super_admin(hazoConnect, auth.user.id);
261
+ // Check if user is a global admin or has access to the invitation's scope
262
+ const is_super = auth.permissions.includes(GLOBAL_ADMIN_PERMISSION);
262
263
  if (!is_super) {
263
264
  const user_scopes = await get_user_scopes(hazoConnect, auth.user.id);
264
265
  const has_scope_access = (_a = user_scopes.scopes) === null || _a === void 0 ? void 0 : _a.some((s) => { var _a; return s.scope_id === ((_a = invitation_result.invitation) === null || _a === void 0 ? void 0 : _a.scope_id); });
@@ -26,7 +26,7 @@ export declare function GET(request: NextRequest): Promise<NextResponse<{
26
26
  profile_source: {} | null;
27
27
  user_type: string | null;
28
28
  app_user_data: Record<string, unknown> | null;
29
- legal_acceptance_status: "current" | "none" | "outdated";
29
+ legal_acceptance_status: "none" | "current" | "outdated";
30
30
  }[];
31
31
  }>>;
32
32
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_auth",
3
- "version": "9.0.1",
3
+ "version": "10.0.0",
4
4
  "description": "Zero-config authentication UI components for Next.js with RBAC, OAuth, scope-based multi-tenancy, and invitations",
5
5
  "keywords": [
6
6
  "authentication",
@@ -252,13 +252,13 @@
252
252
  "@radix-ui/react-switch": "^1.2.0",
253
253
  "@radix-ui/react-tabs": "^1.1.0",
254
254
  "@radix-ui/react-tooltip": "^1.2.0",
255
- "hazo_api": "^2.1.0",
256
- "hazo_config": "^2.1.5",
257
- "hazo_connect": "^3.0.0",
258
- "hazo_core": "^1.0.0",
259
- "hazo_logs": "^2.0.0",
260
- "hazo_notify": "^6.0.0",
261
- "hazo_ui": "^3.1.0",
255
+ "hazo_api": "^2.3.1",
256
+ "hazo_config": "^2.1.10",
257
+ "hazo_connect": "^3.4.1",
258
+ "hazo_core": "^1.1.0",
259
+ "hazo_logs": "^2.0.3",
260
+ "hazo_notify": "^6.1.3",
261
+ "hazo_ui": "^3.2.1",
262
262
  "input-otp": "^1.4.0",
263
263
  "lucide-react": "^0.553.0",
264
264
  "next": "^14.0.0",
@@ -388,13 +388,13 @@
388
388
  "eslint": "^9.39.1",
389
389
  "eslint-config-next": "^16.0.4",
390
390
  "eslint-plugin-storybook": "^10.0.6",
391
- "hazo_api": "^2.1.0",
392
- "hazo_config": "^2.1.6",
393
- "hazo_connect": "^3.0.0",
394
- "hazo_core": "^1.0.0",
395
- "hazo_logs": "^2.0.1",
396
- "hazo_notify": "^6.0.0",
397
- "hazo_ui": "^3.1.0",
391
+ "hazo_api": "^2.3.1",
392
+ "hazo_config": "^2.1.10",
393
+ "hazo_connect": "^3.4.1",
394
+ "hazo_core": "^1.1.0",
395
+ "hazo_logs": "^2.0.3",
396
+ "hazo_notify": "^6.1.3",
397
+ "hazo_ui": "^3.2.1",
398
398
  "input-otp": "^1.4.0",
399
399
  "jest": "^30.2.0",
400
400
  "jest-environment-jsdom": "^30.0.0",