@spfn/auth 0.2.0-beta.18 → 0.2.0-beta.19

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.
@@ -457,6 +457,7 @@ declare function getGoogleAccessToken(userId: number): Promise<string>;
457
457
  * - OAuth: /_auth/oauth/google, /_auth/oauth/google/callback, etc.
458
458
  * - Invitations: /_auth/invitations/*
459
459
  * - Users: /_auth/users/*
460
+ * - Admin: /_auth/admin/* (superadmin only)
460
461
  */
461
462
  declare const mainAuthRouter: _spfn_core_route.Router<{
462
463
  checkAccountExists: _spfn_core_route.RouteDef<{
@@ -712,6 +713,86 @@ declare const mainAuthRouter: _spfn_core_route.Router<{
712
713
  metadata: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
713
714
  }>;
714
715
  }, {}, ProfileInfo>;
716
+ listRoles: _spfn_core_route.RouteDef<{
717
+ query: _sinclair_typebox.TObject<{
718
+ includeInactive: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
719
+ }>;
720
+ }, {}, {
721
+ roles: {
722
+ description: string | null;
723
+ id: number;
724
+ name: string;
725
+ displayName: string;
726
+ isBuiltin: boolean;
727
+ isSystem: boolean;
728
+ isActive: boolean;
729
+ priority: number;
730
+ createdAt: Date;
731
+ updatedAt: Date;
732
+ }[];
733
+ }>;
734
+ createAdminRole: _spfn_core_route.RouteDef<{
735
+ body: _sinclair_typebox.TObject<{
736
+ name: _sinclair_typebox.TString;
737
+ displayName: _sinclair_typebox.TString;
738
+ description: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
739
+ priority: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
740
+ permissionIds: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TNumber>>;
741
+ }>;
742
+ }, {}, {
743
+ role: {
744
+ description: string | null;
745
+ id: number;
746
+ name: string;
747
+ displayName: string;
748
+ isBuiltin: boolean;
749
+ isSystem: boolean;
750
+ isActive: boolean;
751
+ priority: number;
752
+ createdAt: Date;
753
+ updatedAt: Date;
754
+ };
755
+ }>;
756
+ updateAdminRole: _spfn_core_route.RouteDef<{
757
+ params: _sinclair_typebox.TObject<{
758
+ id: _sinclair_typebox.TNumber;
759
+ }>;
760
+ body: _sinclair_typebox.TObject<{
761
+ displayName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
762
+ description: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
763
+ priority: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
764
+ isActive: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
765
+ }>;
766
+ }, {}, {
767
+ role: {
768
+ description: string | null;
769
+ id: number;
770
+ name: string;
771
+ displayName: string;
772
+ isBuiltin: boolean;
773
+ isSystem: boolean;
774
+ isActive: boolean;
775
+ priority: number;
776
+ createdAt: Date;
777
+ updatedAt: Date;
778
+ };
779
+ }>;
780
+ deleteAdminRole: _spfn_core_route.RouteDef<{
781
+ params: _sinclair_typebox.TObject<{
782
+ id: _sinclair_typebox.TNumber;
783
+ }>;
784
+ }, {}, void>;
785
+ updateUserRole: _spfn_core_route.RouteDef<{
786
+ params: _sinclair_typebox.TObject<{
787
+ userId: _sinclair_typebox.TNumber;
788
+ }>;
789
+ body: _sinclair_typebox.TObject<{
790
+ roleId: _sinclair_typebox.TNumber;
791
+ }>;
792
+ }, {}, {
793
+ userId: number;
794
+ roleId: number;
795
+ }>;
715
796
  }>;
716
797
 
717
798
  interface AuthContext {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _spfn_core_nextjs from '@spfn/core/nextjs';
2
- import { R as RoleConfig, P as PermissionConfig, C as CheckAccountExistsResult, S as SendVerificationCodeResult, a as RegisterResult, L as LoginResult, b as RotateKeyResult, O as OAuthStartResult, U as UserProfile, c as ProfileInfo, m as mainAuthRouter } from './authenticate-CMgURpWm.js';
3
- export { k as AuthInitOptions, A as AuthSession, I as INVITATION_STATUSES, n as InvitationStatus, K as KEY_ALGORITHM, l as KeyAlgorithmType, i as PERMISSION_CATEGORIES, j as PermissionCategory, e as SOCIAL_PROVIDERS, p as SocialProvider, d as USER_STATUSES, o as UserStatus, h as VERIFICATION_PURPOSES, g as VERIFICATION_TARGET_TYPES, f as VerificationPurpose, V as VerificationTargetType } from './authenticate-CMgURpWm.js';
2
+ import { R as RoleConfig, P as PermissionConfig, C as CheckAccountExistsResult, S as SendVerificationCodeResult, a as RegisterResult, L as LoginResult, b as RotateKeyResult, O as OAuthStartResult, U as UserProfile, c as ProfileInfo, m as mainAuthRouter } from './authenticate-BmzJ6hTF.js';
3
+ export { k as AuthInitOptions, A as AuthSession, I as INVITATION_STATUSES, n as InvitationStatus, K as KEY_ALGORITHM, l as KeyAlgorithmType, i as PERMISSION_CATEGORIES, j as PermissionCategory, e as SOCIAL_PROVIDERS, p as SocialProvider, d as USER_STATUSES, o as UserStatus, h as VERIFICATION_PURPOSES, g as VERIFICATION_TARGET_TYPES, f as VerificationPurpose, V as VerificationTargetType } from './authenticate-BmzJ6hTF.js';
4
4
  import * as _spfn_core_route from '@spfn/core/route';
5
5
  import { HttpMethod } from '@spfn/core/route';
6
6
  import * as _sinclair_typebox from '@sinclair/typebox';
@@ -340,6 +340,86 @@ declare const authApi: _spfn_core_nextjs.Client<_spfn_core_route.Router<{
340
340
  metadata: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
341
341
  }>;
342
342
  }, {}, ProfileInfo>;
343
+ listRoles: _spfn_core_route.RouteDef<{
344
+ query: _sinclair_typebox.TObject<{
345
+ includeInactive: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
346
+ }>;
347
+ }, {}, {
348
+ roles: {
349
+ description: string | null;
350
+ id: number;
351
+ name: string;
352
+ displayName: string;
353
+ isBuiltin: boolean;
354
+ isSystem: boolean;
355
+ isActive: boolean;
356
+ priority: number;
357
+ createdAt: Date;
358
+ updatedAt: Date;
359
+ }[];
360
+ }>;
361
+ createAdminRole: _spfn_core_route.RouteDef<{
362
+ body: _sinclair_typebox.TObject<{
363
+ name: _sinclair_typebox.TString;
364
+ displayName: _sinclair_typebox.TString;
365
+ description: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
366
+ priority: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
367
+ permissionIds: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TNumber>>;
368
+ }>;
369
+ }, {}, {
370
+ role: {
371
+ description: string | null;
372
+ id: number;
373
+ name: string;
374
+ displayName: string;
375
+ isBuiltin: boolean;
376
+ isSystem: boolean;
377
+ isActive: boolean;
378
+ priority: number;
379
+ createdAt: Date;
380
+ updatedAt: Date;
381
+ };
382
+ }>;
383
+ updateAdminRole: _spfn_core_route.RouteDef<{
384
+ params: _sinclair_typebox.TObject<{
385
+ id: _sinclair_typebox.TNumber;
386
+ }>;
387
+ body: _sinclair_typebox.TObject<{
388
+ displayName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
389
+ description: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
390
+ priority: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
391
+ isActive: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
392
+ }>;
393
+ }, {}, {
394
+ role: {
395
+ description: string | null;
396
+ id: number;
397
+ name: string;
398
+ displayName: string;
399
+ isBuiltin: boolean;
400
+ isSystem: boolean;
401
+ isActive: boolean;
402
+ priority: number;
403
+ createdAt: Date;
404
+ updatedAt: Date;
405
+ };
406
+ }>;
407
+ deleteAdminRole: _spfn_core_route.RouteDef<{
408
+ params: _sinclair_typebox.TObject<{
409
+ id: _sinclair_typebox.TNumber;
410
+ }>;
411
+ }, {}, void>;
412
+ updateUserRole: _spfn_core_route.RouteDef<{
413
+ params: _sinclair_typebox.TObject<{
414
+ userId: _sinclair_typebox.TNumber;
415
+ }>;
416
+ body: _sinclair_typebox.TObject<{
417
+ roleId: _sinclair_typebox.TNumber;
418
+ }>;
419
+ }, {}, {
420
+ userId: number;
421
+ roleId: number;
422
+ }>;
343
423
  }>>;
344
424
  type AuthRouter = typeof mainAuthRouter;
345
425
 
package/dist/index.js CHANGED
@@ -166,7 +166,12 @@ var routeMap = {
166
166
  oauthStart: { method: "POST", path: "/_auth/oauth/start" },
167
167
  oauthProviders: { method: "GET", path: "/_auth/oauth/providers" },
168
168
  getGoogleOAuthUrl: { method: "POST", path: "/_auth/oauth/google/url" },
169
- oauthFinalize: { method: "POST", path: "/_auth/oauth/finalize" }
169
+ oauthFinalize: { method: "POST", path: "/_auth/oauth/finalize" },
170
+ listRoles: { method: "GET", path: "/_auth/admin/roles" },
171
+ createAdminRole: { method: "POST", path: "/_auth/admin/roles" },
172
+ updateAdminRole: { method: "PATCH", path: "/_auth/admin/roles/:id" },
173
+ deleteAdminRole: { method: "DELETE", path: "/_auth/admin/roles/:id" },
174
+ updateUserRole: { method: "PATCH", path: "/_auth/admin/users/:userId/role" }
170
175
  };
171
176
 
172
177
  // src/lib/types.ts