@plyaz/types 1.27.8 → 1.27.10
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/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/types.d.ts +151 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/auth/types.d.ts
CHANGED
|
@@ -344,6 +344,7 @@ export interface Permission {
|
|
|
344
344
|
metadata?: Record<string, unknown>;
|
|
345
345
|
createdAt: Date;
|
|
346
346
|
updatedAt: Date;
|
|
347
|
+
conditions?: Record<string, unknown>;
|
|
347
348
|
}
|
|
348
349
|
/**
|
|
349
350
|
* Role-Permission mapping (backoffice only).
|
|
@@ -801,9 +802,19 @@ export interface AuthUser {
|
|
|
801
802
|
export interface UserRepository {
|
|
802
803
|
findById(id: string): Promise<AuthUser | null>;
|
|
803
804
|
findByEmail(email: string): Promise<AuthUser | null>;
|
|
805
|
+
findByProviderAccount(provider: string, providerAccountId: string): Promise<AuthUser | null>;
|
|
806
|
+
findByCredentials(email: string, passwordHash: string): Promise<AuthUser | null>;
|
|
804
807
|
create(data: CreateUserData): Promise<AuthUser>;
|
|
805
808
|
update(id: string, data: UpdateUserData): Promise<AuthUser>;
|
|
806
809
|
delete(id: string): Promise<void>;
|
|
810
|
+
assignRole(userId: string, role: string, assignedBy?: string): Promise<void>;
|
|
811
|
+
removeRole(userId: string, role: string): Promise<void>;
|
|
812
|
+
getUserRoles(userId: string): Promise<string[]>;
|
|
813
|
+
checkPermission(roles: string[], permission: string): Promise<boolean>;
|
|
814
|
+
updateLastLogin(userId: string): Promise<void>;
|
|
815
|
+
updateOnboardingStatus(userId: string, status: 'completed' | 'pending' | 'skipped'): Promise<AuthUser>;
|
|
816
|
+
findByClerkId(clerkId: string): Promise<AuthUser | null>;
|
|
817
|
+
findByWalletAddress(address: string): Promise<AuthUser | null>;
|
|
807
818
|
}
|
|
808
819
|
export interface SessionRepository {
|
|
809
820
|
create(data: CreateSessionData): Promise<Session>;
|
|
@@ -899,3 +910,143 @@ export interface OAuthProviderConfig {
|
|
|
899
910
|
/** Provider icon name (for UI) */
|
|
900
911
|
iconName: string;
|
|
901
912
|
}
|
|
913
|
+
/**
|
|
914
|
+
* Role assignment data
|
|
915
|
+
*/
|
|
916
|
+
export interface RoleAssignmentData {
|
|
917
|
+
/** User ID */
|
|
918
|
+
userId: string;
|
|
919
|
+
/** Role ID */
|
|
920
|
+
roleId: string;
|
|
921
|
+
/** Role name/code */
|
|
922
|
+
role: string;
|
|
923
|
+
/** Is primary role */
|
|
924
|
+
isPrimary?: boolean;
|
|
925
|
+
/** Assignment status */
|
|
926
|
+
status?: 'ACTIVE' | 'INACTIVE' | 'SUSPENDED';
|
|
927
|
+
/** Assigned by user ID */
|
|
928
|
+
assignedBy?: string;
|
|
929
|
+
/** Assignment reason */
|
|
930
|
+
assignedReason?: string;
|
|
931
|
+
/** Assignment expiration */
|
|
932
|
+
expiresAt?: Date;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Role repository interface
|
|
936
|
+
*/
|
|
937
|
+
export interface RoleRepositoryInterface {
|
|
938
|
+
findByScope(scope: 'B2C' | 'B2B'): Promise<Role[]>;
|
|
939
|
+
findUserRoles(userId: string): Promise<Role[]>;
|
|
940
|
+
assignRole(userId: string, roleId: string, assignedBy?: string, reason?: string): Promise<void>;
|
|
941
|
+
revokeRole(userId: string, roleId: string, revokedBy?: string, reason?: string): Promise<void>;
|
|
942
|
+
getRolePermissions(roleId: string): Promise<Permission[]>;
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Dynamic role assignment
|
|
946
|
+
*/
|
|
947
|
+
export interface DynamicRoleAssignment {
|
|
948
|
+
/** Assignment ID */
|
|
949
|
+
id: string;
|
|
950
|
+
/** User ID */
|
|
951
|
+
userId: string;
|
|
952
|
+
/** Role ID or name */
|
|
953
|
+
roleId: string;
|
|
954
|
+
/** Assignment conditions */
|
|
955
|
+
conditions?: Record<string, unknown>;
|
|
956
|
+
/** Assignment expiration */
|
|
957
|
+
expiresAt?: Date;
|
|
958
|
+
/** Assignment reason */
|
|
959
|
+
reason?: string;
|
|
960
|
+
/** Assigned by user ID */
|
|
961
|
+
assignedBy?: string;
|
|
962
|
+
/** Assignment metadata */
|
|
963
|
+
metadata?: Record<string, unknown>;
|
|
964
|
+
/** Created at */
|
|
965
|
+
createdAt: Date;
|
|
966
|
+
/** Is active */
|
|
967
|
+
isActive: boolean;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Role condition evaluator function
|
|
971
|
+
*/
|
|
972
|
+
export type RoleConditionEvaluator = (userId: string, conditions: Record<string, unknown>, context?: Record<string, unknown>) => Promise<boolean>;
|
|
973
|
+
/**
|
|
974
|
+
* Dynamic roles configuration
|
|
975
|
+
*/
|
|
976
|
+
export interface DynamicRolesConfig {
|
|
977
|
+
/** Enable role expiration */
|
|
978
|
+
enableExpiration: boolean;
|
|
979
|
+
/** Default role TTL in seconds */
|
|
980
|
+
defaultTTL: number;
|
|
981
|
+
/** Enable condition evaluation */
|
|
982
|
+
enableConditions: boolean;
|
|
983
|
+
/** Maximum assignments per user */
|
|
984
|
+
maxAssignmentsPerUser: number;
|
|
985
|
+
/** Enable audit logging */
|
|
986
|
+
enableAuditLog: boolean;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Role hierarchy node
|
|
990
|
+
*/
|
|
991
|
+
export interface RoleNode {
|
|
992
|
+
/** Role information */
|
|
993
|
+
role: Role;
|
|
994
|
+
/** Parent roles (higher hierarchy) */
|
|
995
|
+
parents: Set<string>;
|
|
996
|
+
/** Child roles (lower hierarchy) */
|
|
997
|
+
children: Set<string>;
|
|
998
|
+
/** Direct permissions */
|
|
999
|
+
permissions: Set<string>;
|
|
1000
|
+
/** Inherited permissions (computed) */
|
|
1001
|
+
inheritedPermissions?: Set<string>;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Role hierarchy configuration
|
|
1005
|
+
*/
|
|
1006
|
+
export interface RoleHierarchyConfig {
|
|
1007
|
+
/** Enable permission inheritance */
|
|
1008
|
+
enableInheritance: boolean;
|
|
1009
|
+
/** Maximum hierarchy depth */
|
|
1010
|
+
maxDepth: number;
|
|
1011
|
+
/** Enable circular dependency detection */
|
|
1012
|
+
detectCircular: boolean;
|
|
1013
|
+
/** Cache inherited permissions */
|
|
1014
|
+
cacheInheritance: boolean;
|
|
1015
|
+
}
|
|
1016
|
+
export interface RoleConfig {
|
|
1017
|
+
hierarchyEnabled: boolean;
|
|
1018
|
+
cacheEnabled: boolean;
|
|
1019
|
+
cacheTTL: number;
|
|
1020
|
+
}
|
|
1021
|
+
export interface PermissionContext {
|
|
1022
|
+
/** Resource owner ID */
|
|
1023
|
+
ownerId?: string;
|
|
1024
|
+
/** Organization ID */
|
|
1025
|
+
organizationId?: string;
|
|
1026
|
+
/** Additional context data */
|
|
1027
|
+
[key: string]: unknown;
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Permission check result
|
|
1031
|
+
*/
|
|
1032
|
+
export interface PermissionCheckResult {
|
|
1033
|
+
/** Permission granted */
|
|
1034
|
+
granted: boolean;
|
|
1035
|
+
/** Reason for decision */
|
|
1036
|
+
reason: string;
|
|
1037
|
+
/** Matched permission (if any) */
|
|
1038
|
+
matchedPermission?: Permission;
|
|
1039
|
+
/** Applied conditions */
|
|
1040
|
+
conditions?: Record<string, unknown>;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Permission checker configuration
|
|
1044
|
+
*/
|
|
1045
|
+
export interface PermissionCheckerConfig {
|
|
1046
|
+
/** Enable permission caching */
|
|
1047
|
+
enableCaching: boolean;
|
|
1048
|
+
/** Cache TTL in seconds */
|
|
1049
|
+
cacheTTL: number;
|
|
1050
|
+
/** Enable audit logging */
|
|
1051
|
+
enableAuditLog: boolean;
|
|
1052
|
+
}
|