@longzai-intelligence-auth/core 0.0.2 → 0.0.5
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/index.cjs +1 -0
- package/dist/index.d.cts +532 -0
- package/dist/index.d.mts +532 -0
- package/dist/index.mjs +1 -0
- package/package.json +6 -1
- package/dist/errors/auth.errors.d.ts +0 -37
- package/dist/errors/auth.errors.js +0 -61
- package/dist/index.d.ts +0 -22
- package/dist/index.js +0 -6
- package/dist/ports/auth-backend.port.d.ts +0 -53
- package/dist/ports/auth-backend.port.js +0 -1
- package/dist/ports/identity.port.d.ts +0 -87
- package/dist/ports/identity.port.js +0 -1
- package/dist/ports/index.d.ts +0 -4
- package/dist/ports/index.js +0 -1
- package/dist/ports/password-hash.port.d.ts +0 -4
- package/dist/ports/password-hash.port.js +0 -1
- package/dist/ports/strategy.port.d.ts +0 -26
- package/dist/ports/strategy.port.js +0 -1
- package/dist/schemas/auth-config.schema.d.ts +0 -36
- package/dist/schemas/auth-config.schema.js +0 -24
- package/dist/schemas/permission.schema.d.ts +0 -6
- package/dist/schemas/permission.schema.js +0 -6
- package/dist/schemas/session.schema.d.ts +0 -8
- package/dist/schemas/session.schema.js +0 -8
- package/dist/schemas/token.schema.d.ts +0 -24
- package/dist/schemas/token.schema.js +0 -24
- package/dist/schemas/user.schema.d.ts +0 -15
- package/dist/schemas/user.schema.js +0 -15
- package/dist/types/audit.types.d.ts +0 -1
- package/dist/types/audit.types.js +0 -1
- package/dist/types/auth-api.types.d.ts +0 -42
- package/dist/types/auth-api.types.js +0 -1
- package/dist/types/auth-context.types.d.ts +0 -8
- package/dist/types/auth-context.types.js +0 -1
- package/dist/types/config.types.d.ts +0 -19
- package/dist/types/config.types.js +0 -1
- package/dist/types/index.d.ts +0 -12
- package/dist/types/index.js +0 -12
- package/dist/types/logger.types.d.ts +0 -6
- package/dist/types/logger.types.js +0 -1
- package/dist/types/password.types.d.ts +0 -4
- package/dist/types/password.types.js +0 -1
- package/dist/types/permission.types.d.ts +0 -6
- package/dist/types/permission.types.js +0 -1
- package/dist/types/rate-limit.types.d.ts +0 -4
- package/dist/types/rate-limit.types.js +0 -1
- package/dist/types/session.types.d.ts +0 -21
- package/dist/types/session.types.js +0 -1
- package/dist/types/tenant-member.types.d.ts +0 -13
- package/dist/types/tenant-member.types.js +0 -1
- package/dist/types/tenant.types.d.ts +0 -22
- package/dist/types/tenant.types.js +0 -1
- package/dist/types/token.types.d.ts +0 -24
- package/dist/types/token.types.js +0 -1
- package/dist/types/user.types.d.ts +0 -29
- package/dist/types/user.types.js +0 -1
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { User, CreateUserInput, UpdateUserInput, UserStatus, Session, CreateSessionInput, Tenant, AccessTokenPayload, RefreshTokenPayload, ResourceAction } from "../types";
|
|
2
|
-
export type UserAuthInfo = {
|
|
3
|
-
userId: string;
|
|
4
|
-
email: string;
|
|
5
|
-
tenantId: string;
|
|
6
|
-
status: UserStatus;
|
|
7
|
-
passwordHash: string;
|
|
8
|
-
mfaEnabled: boolean;
|
|
9
|
-
mfaSecret: string | null;
|
|
10
|
-
failedLoginAttempts: number;
|
|
11
|
-
lockedUntil: string | null;
|
|
12
|
-
};
|
|
13
|
-
export type VerifyPasswordResult = {
|
|
14
|
-
success: boolean;
|
|
15
|
-
user?: User;
|
|
16
|
-
error?: string;
|
|
17
|
-
};
|
|
18
|
-
export type TenantValidateResult = {
|
|
19
|
-
valid: boolean;
|
|
20
|
-
tenant?: Tenant;
|
|
21
|
-
error?: string;
|
|
22
|
-
};
|
|
23
|
-
export type UserPort = {
|
|
24
|
-
findById(userId: string): Promise<User | null>;
|
|
25
|
-
findByEmail(email: string): Promise<User | null>;
|
|
26
|
-
findByUsername(username: string): Promise<User | null>;
|
|
27
|
-
findAuthInfo(userId: string): Promise<UserAuthInfo | null>;
|
|
28
|
-
findAuthInfoByEmail(email: string): Promise<UserAuthInfo | null>;
|
|
29
|
-
findPermissions(userId: string, tenantId: string): Promise<ResourceAction[]>;
|
|
30
|
-
isSuperAdmin(userId: string, tenantId: string): Promise<boolean>;
|
|
31
|
-
create(input: CreateUserInput): Promise<User>;
|
|
32
|
-
update(userId: string, input: UpdateUserInput): Promise<User>;
|
|
33
|
-
verifyPassword(email: string, password: string): Promise<VerifyPasswordResult>;
|
|
34
|
-
updatePassword(userId: string, newPasswordHash: string): Promise<void>;
|
|
35
|
-
};
|
|
36
|
-
export type SessionPort = {
|
|
37
|
-
create(input: CreateSessionInput): Promise<Session>;
|
|
38
|
-
findById(sessionId: string): Promise<Session | null>;
|
|
39
|
-
findByRefreshTokenHash(hash: string): Promise<Session | null>;
|
|
40
|
-
revoke(sessionId: string): Promise<void>;
|
|
41
|
-
revokeAllByUser(userId: string): Promise<void>;
|
|
42
|
-
};
|
|
43
|
-
export type TokenPort = {
|
|
44
|
-
signAccessToken(payload: AccessTokenPayload): Promise<string>;
|
|
45
|
-
signRefreshToken(payload: RefreshTokenPayload): Promise<string>;
|
|
46
|
-
verifyAccessToken(token: string): Promise<AccessTokenPayload>;
|
|
47
|
-
verifyRefreshToken(token: string): Promise<RefreshTokenPayload>;
|
|
48
|
-
};
|
|
49
|
-
export type AuthBackendPort = {
|
|
50
|
-
user: UserPort;
|
|
51
|
-
session: SessionPort;
|
|
52
|
-
token: TokenPort;
|
|
53
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { Tenant, CreateTenantInput, TenantMember } from "../types";
|
|
2
|
-
import type { AuthBackendPort, TenantValidateResult } from "./auth-backend.port";
|
|
3
|
-
export type TenantPort = {
|
|
4
|
-
findById(tenantId: string): Promise<Tenant | null>;
|
|
5
|
-
findBySlug(slug: string): Promise<Tenant | null>;
|
|
6
|
-
create(input: CreateTenantInput): Promise<Tenant>;
|
|
7
|
-
validateStatus(tenantId: string): Promise<TenantValidateResult>;
|
|
8
|
-
};
|
|
9
|
-
export type TenantMemberPort = {
|
|
10
|
-
getMember(tenantId: string, userId: string): Promise<TenantMember | null>;
|
|
11
|
-
addMember(tenantId: string, userId: string, role: string): Promise<TenantMember>;
|
|
12
|
-
removeMember(tenantId: string, userId: string): Promise<void>;
|
|
13
|
-
isMember(tenantId: string, userId: string): Promise<boolean>;
|
|
14
|
-
};
|
|
15
|
-
export type AuditLogEntry = {
|
|
16
|
-
id: string;
|
|
17
|
-
action: string;
|
|
18
|
-
resource: string;
|
|
19
|
-
resourceId?: string;
|
|
20
|
-
userId?: string;
|
|
21
|
-
tenantId?: string;
|
|
22
|
-
success: boolean;
|
|
23
|
-
metadata?: Record<string, unknown>;
|
|
24
|
-
ipAddress?: string;
|
|
25
|
-
userAgent?: string;
|
|
26
|
-
createdAt: string;
|
|
27
|
-
hashChain?: string;
|
|
28
|
-
previousHash?: string;
|
|
29
|
-
};
|
|
30
|
-
export type AuditLogQueryParams = {
|
|
31
|
-
page?: number;
|
|
32
|
-
pageSize?: number;
|
|
33
|
-
action?: string;
|
|
34
|
-
resource?: string;
|
|
35
|
-
userId?: string;
|
|
36
|
-
tenantId?: string;
|
|
37
|
-
startDate?: string;
|
|
38
|
-
endDate?: string;
|
|
39
|
-
};
|
|
40
|
-
export type PaginatedResult<T> = {
|
|
41
|
-
items: T[];
|
|
42
|
-
pagination: {
|
|
43
|
-
page: number;
|
|
44
|
-
pageSize: number;
|
|
45
|
-
total: number;
|
|
46
|
-
totalPages: number;
|
|
47
|
-
hasPrev: boolean;
|
|
48
|
-
hasNext: boolean;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
export type AuditStatistics = {
|
|
52
|
-
totalEntries: number;
|
|
53
|
-
successCount: number;
|
|
54
|
-
failureCount: number;
|
|
55
|
-
topActions: {
|
|
56
|
-
action: string;
|
|
57
|
-
count: number;
|
|
58
|
-
}[];
|
|
59
|
-
topResources: {
|
|
60
|
-
resource: string;
|
|
61
|
-
count: number;
|
|
62
|
-
}[];
|
|
63
|
-
};
|
|
64
|
-
export type IntegrityVerificationResult = {
|
|
65
|
-
valid: boolean;
|
|
66
|
-
brokenAt: string | null;
|
|
67
|
-
totalChecked: number;
|
|
68
|
-
};
|
|
69
|
-
export type AuditLogPort = {
|
|
70
|
-
save(entry: AuditLogEntry): Promise<AuditLogEntry>;
|
|
71
|
-
findById(id: string): Promise<AuditLogEntry | null>;
|
|
72
|
-
query(params: AuditLogQueryParams): Promise<PaginatedResult<AuditLogEntry>>;
|
|
73
|
-
getStatistics(filter: AuditStatsFilter): Promise<AuditStatistics>;
|
|
74
|
-
deleteOlderThan(date: Date): Promise<number>;
|
|
75
|
-
verifyIntegrity(startId?: string): Promise<IntegrityVerificationResult>;
|
|
76
|
-
};
|
|
77
|
-
export type AuditStatsFilter = {
|
|
78
|
-
startDate?: string;
|
|
79
|
-
endDate?: string;
|
|
80
|
-
tenantId?: string;
|
|
81
|
-
};
|
|
82
|
-
export type IdentityAuthBackend = AuthBackendPort & {
|
|
83
|
-
tenant: TenantPort;
|
|
84
|
-
tenantMember: TenantMemberPort;
|
|
85
|
-
audit: AuditLogPort;
|
|
86
|
-
};
|
|
87
|
-
export type TenantValidateFn = (tenantId: string) => Promise<TenantValidateResult>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/ports/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export type { AuthBackendPort, UserPort, SessionPort, TokenPort, UserAuthInfo, VerifyPasswordResult, TenantValidateResult, } from "./auth-backend.port";
|
|
2
|
-
export type { PasswordHasher } from "./password-hash.port";
|
|
3
|
-
export type { AuthStrategy, TokenSigner, TokenVerifier, TokenVerifyResult, RateLimiter, } from "./strategy.port";
|
|
4
|
-
export type { IdentityAuthBackend, TenantPort, TenantMemberPort, AuditLogPort, AuditLogEntry, AuditLogQueryParams, PaginatedResult, AuditStatistics, AuditStatsFilter, IntegrityVerificationResult, TenantValidateFn, } from "./identity.port";
|
package/dist/ports/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { AccessTokenPayload, RefreshTokenPayload } from "../types/token.types";
|
|
2
|
-
export type TokenVerifyResult<T> = {
|
|
3
|
-
success: boolean;
|
|
4
|
-
payload?: T;
|
|
5
|
-
error?: string;
|
|
6
|
-
};
|
|
7
|
-
export type TokenSigner = {
|
|
8
|
-
signAccessToken(payload: AccessTokenPayload): Promise<string>;
|
|
9
|
-
signRefreshToken(payload: RefreshTokenPayload): Promise<string>;
|
|
10
|
-
};
|
|
11
|
-
export type TokenVerifier = {
|
|
12
|
-
verifyAccessToken(token: string): Promise<TokenVerifyResult<AccessTokenPayload>>;
|
|
13
|
-
verifyRefreshToken(token: string): Promise<TokenVerifyResult<RefreshTokenPayload>>;
|
|
14
|
-
};
|
|
15
|
-
export type AuthStrategy = {
|
|
16
|
-
name: string;
|
|
17
|
-
verify(credentials: unknown): Promise<AccessTokenPayload>;
|
|
18
|
-
};
|
|
19
|
-
export type RateLimiter = {
|
|
20
|
-
check(key: string): Promise<{
|
|
21
|
-
allowed: boolean;
|
|
22
|
-
remaining: number;
|
|
23
|
-
resetAt: Date;
|
|
24
|
-
}>;
|
|
25
|
-
reset(key: string): Promise<void>;
|
|
26
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const jwtConfigSchema: z.ZodObject<{
|
|
3
|
-
secret: z.ZodString;
|
|
4
|
-
accessExpiresIn: z.ZodDefault<z.ZodString>;
|
|
5
|
-
refreshExpiresIn: z.ZodDefault<z.ZodString>;
|
|
6
|
-
}, z.core.$strip>;
|
|
7
|
-
export declare const passwordPolicyConfigSchema: z.ZodObject<{
|
|
8
|
-
minLength: z.ZodDefault<z.ZodNumber>;
|
|
9
|
-
requireUppercase: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
-
requireLowercase: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
-
requireNumber: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
-
requireSpecial: z.ZodDefault<z.ZodBoolean>;
|
|
13
|
-
historyCount: z.ZodDefault<z.ZodNumber>;
|
|
14
|
-
expireDays: z.ZodDefault<z.ZodNumber>;
|
|
15
|
-
}, z.core.$strip>;
|
|
16
|
-
export declare const rateLimitConfigSchema: z.ZodObject<{
|
|
17
|
-
windowSeconds: z.ZodDefault<z.ZodNumber>;
|
|
18
|
-
maxRequests: z.ZodDefault<z.ZodNumber>;
|
|
19
|
-
}, z.core.$strip>;
|
|
20
|
-
export declare const authConfigSchema: z.ZodObject<{
|
|
21
|
-
jwt: z.ZodObject<{
|
|
22
|
-
secret: z.ZodString;
|
|
23
|
-
accessExpiresIn: z.ZodDefault<z.ZodString>;
|
|
24
|
-
refreshExpiresIn: z.ZodDefault<z.ZodString>;
|
|
25
|
-
}, z.core.$strip>;
|
|
26
|
-
passwordPolicy: z.ZodObject<{
|
|
27
|
-
minLength: z.ZodDefault<z.ZodNumber>;
|
|
28
|
-
requireUppercase: z.ZodDefault<z.ZodBoolean>;
|
|
29
|
-
requireLowercase: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
-
requireNumber: z.ZodDefault<z.ZodBoolean>;
|
|
31
|
-
requireSpecial: z.ZodDefault<z.ZodBoolean>;
|
|
32
|
-
historyCount: z.ZodDefault<z.ZodNumber>;
|
|
33
|
-
expireDays: z.ZodDefault<z.ZodNumber>;
|
|
34
|
-
}, z.core.$strip>;
|
|
35
|
-
defaultTenantId: z.ZodDefault<z.ZodString>;
|
|
36
|
-
}, z.core.$strip>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export const jwtConfigSchema = z.object({
|
|
3
|
-
secret: z.string().min(1, "JWT 密钥不能为空"),
|
|
4
|
-
accessExpiresIn: z.string().default("15m"),
|
|
5
|
-
refreshExpiresIn: z.string().default("7d"),
|
|
6
|
-
});
|
|
7
|
-
export const passwordPolicyConfigSchema = z.object({
|
|
8
|
-
minLength: z.number().int().positive().default(8),
|
|
9
|
-
requireUppercase: z.boolean().default(true),
|
|
10
|
-
requireLowercase: z.boolean().default(true),
|
|
11
|
-
requireNumber: z.boolean().default(true),
|
|
12
|
-
requireSpecial: z.boolean().default(false),
|
|
13
|
-
historyCount: z.number().int().nonnegative().default(5),
|
|
14
|
-
expireDays: z.number().int().nonnegative().default(0),
|
|
15
|
-
});
|
|
16
|
-
export const rateLimitConfigSchema = z.object({
|
|
17
|
-
windowSeconds: z.number().int().positive().default(60),
|
|
18
|
-
maxRequests: z.number().int().positive().default(100),
|
|
19
|
-
});
|
|
20
|
-
export const authConfigSchema = z.object({
|
|
21
|
-
jwt: jwtConfigSchema,
|
|
22
|
-
passwordPolicy: passwordPolicyConfigSchema,
|
|
23
|
-
defaultTenantId: z.string().min(1).default("default"),
|
|
24
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const accessTokenPayloadSchema: z.ZodObject<{
|
|
3
|
-
sub: z.ZodString;
|
|
4
|
-
type: z.ZodLiteral<"access">;
|
|
5
|
-
tenantId: z.ZodOptional<z.ZodString>;
|
|
6
|
-
iss: z.ZodOptional<z.ZodString>;
|
|
7
|
-
aud: z.ZodOptional<z.ZodString>;
|
|
8
|
-
jti: z.ZodOptional<z.ZodString>;
|
|
9
|
-
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
-
permissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
export declare const refreshTokenPayloadSchema: z.ZodObject<{
|
|
13
|
-
sub: z.ZodString;
|
|
14
|
-
sessionId: z.ZodString;
|
|
15
|
-
type: z.ZodLiteral<"refresh">;
|
|
16
|
-
}, z.core.$strip>;
|
|
17
|
-
export declare const passwordResetTokenPayloadSchema: z.ZodObject<{
|
|
18
|
-
sub: z.ZodString;
|
|
19
|
-
type: z.ZodLiteral<"password_reset">;
|
|
20
|
-
}, z.core.$strip>;
|
|
21
|
-
export declare const mfaPendingTokenPayloadSchema: z.ZodObject<{
|
|
22
|
-
sub: z.ZodString;
|
|
23
|
-
type: z.ZodLiteral<"mfa_pending">;
|
|
24
|
-
}, z.core.$strip>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export const accessTokenPayloadSchema = z.object({
|
|
3
|
-
sub: z.string(),
|
|
4
|
-
type: z.literal("access"),
|
|
5
|
-
tenantId: z.string().optional(),
|
|
6
|
-
iss: z.string().optional(),
|
|
7
|
-
aud: z.string().optional(),
|
|
8
|
-
jti: z.string().optional(),
|
|
9
|
-
roles: z.array(z.string()).optional(),
|
|
10
|
-
permissions: z.array(z.string()).optional(),
|
|
11
|
-
});
|
|
12
|
-
export const refreshTokenPayloadSchema = z.object({
|
|
13
|
-
sub: z.string(),
|
|
14
|
-
sessionId: z.string(),
|
|
15
|
-
type: z.literal("refresh"),
|
|
16
|
-
});
|
|
17
|
-
export const passwordResetTokenPayloadSchema = z.object({
|
|
18
|
-
sub: z.string(),
|
|
19
|
-
type: z.literal("password_reset"),
|
|
20
|
-
});
|
|
21
|
-
export const mfaPendingTokenPayloadSchema = z.object({
|
|
22
|
-
sub: z.string(),
|
|
23
|
-
type: z.literal("mfa_pending"),
|
|
24
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const createUserSchema: z.ZodObject<{
|
|
3
|
-
email: z.ZodString;
|
|
4
|
-
username: z.ZodString;
|
|
5
|
-
password: z.ZodString;
|
|
6
|
-
displayName: z.ZodOptional<z.ZodString>;
|
|
7
|
-
}, z.core.$strip>;
|
|
8
|
-
export declare const updateUserSchema: z.ZodObject<{
|
|
9
|
-
displayName: z.ZodOptional<z.ZodString>;
|
|
10
|
-
avatarUrl: z.ZodOptional<z.ZodString>;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
export declare const changePasswordSchema: z.ZodObject<{
|
|
13
|
-
currentPassword: z.ZodString;
|
|
14
|
-
newPassword: z.ZodString;
|
|
15
|
-
}, z.core.$strip>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export const createUserSchema = z.object({
|
|
3
|
-
email: z.string().email("邮箱格式无效"),
|
|
4
|
-
username: z.string().min(3, "用户名至少 3 个字符").max(50, "用户名最多 50 个字符"),
|
|
5
|
-
password: z.string().min(8, "密码至少 8 个字符").max(128, "密码最多 128 个字符"),
|
|
6
|
-
displayName: z.string().optional(),
|
|
7
|
-
});
|
|
8
|
-
export const updateUserSchema = z.object({
|
|
9
|
-
displayName: z.string().optional(),
|
|
10
|
-
avatarUrl: z.string().url("头像 URL 格式无效").optional(),
|
|
11
|
-
});
|
|
12
|
-
export const changePasswordSchema = z.object({
|
|
13
|
-
currentPassword: z.string("请输入当前密码"),
|
|
14
|
-
newPassword: z.string().min(8, "新密码至少 8 个字符").max(128, "新密码最多 128 个字符"),
|
|
15
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { AuditLogEntry } from "@longzai-intelligence-audit/audit-log-contract";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export type LoginRequest = {
|
|
2
|
-
email: string;
|
|
3
|
-
password: string;
|
|
4
|
-
};
|
|
5
|
-
export type LoginResponse = {
|
|
6
|
-
accessToken: string;
|
|
7
|
-
refreshToken: string;
|
|
8
|
-
};
|
|
9
|
-
export type RegisterRequest = {
|
|
10
|
-
email: string;
|
|
11
|
-
password: string;
|
|
12
|
-
name: string;
|
|
13
|
-
};
|
|
14
|
-
export type RegisterResponse = {
|
|
15
|
-
userId: string;
|
|
16
|
-
message: string;
|
|
17
|
-
};
|
|
18
|
-
export type RefreshTokenRequest = {
|
|
19
|
-
refreshToken: string;
|
|
20
|
-
};
|
|
21
|
-
export type RefreshTokenResponse = {
|
|
22
|
-
accessToken: string;
|
|
23
|
-
refreshToken: string;
|
|
24
|
-
};
|
|
25
|
-
export type PasswordResetRequest = {
|
|
26
|
-
email: string;
|
|
27
|
-
};
|
|
28
|
-
export type PasswordResetConfirmRequest = {
|
|
29
|
-
token: string;
|
|
30
|
-
password: string;
|
|
31
|
-
};
|
|
32
|
-
export type ChangePasswordRequest = {
|
|
33
|
-
oldPassword: string;
|
|
34
|
-
newPassword: string;
|
|
35
|
-
};
|
|
36
|
-
export type MessageResponse = {
|
|
37
|
-
message: string;
|
|
38
|
-
};
|
|
39
|
-
export type MeResponse = {
|
|
40
|
-
userId: string;
|
|
41
|
-
tenantId?: string;
|
|
42
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type JwtConfig = {
|
|
2
|
-
secret: string;
|
|
3
|
-
accessExpiresIn: string;
|
|
4
|
-
refreshExpiresIn: string;
|
|
5
|
-
};
|
|
6
|
-
export type PasswordPolicyConfig = {
|
|
7
|
-
minLength: number;
|
|
8
|
-
requireUppercase: boolean;
|
|
9
|
-
requireLowercase: boolean;
|
|
10
|
-
requireNumber: boolean;
|
|
11
|
-
requireSpecial: boolean;
|
|
12
|
-
historyCount: number;
|
|
13
|
-
expireDays: number;
|
|
14
|
-
};
|
|
15
|
-
export type AuthConfig = {
|
|
16
|
-
jwt: JwtConfig;
|
|
17
|
-
passwordPolicy: PasswordPolicyConfig;
|
|
18
|
-
defaultTenantId: string;
|
|
19
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from "./auth-api.types";
|
|
2
|
-
export * from "./auth-context.types";
|
|
3
|
-
export * from "./config.types";
|
|
4
|
-
export * from "./logger.types";
|
|
5
|
-
export * from "./password.types";
|
|
6
|
-
export * from "./permission.types";
|
|
7
|
-
export * from "./rate-limit.types";
|
|
8
|
-
export * from "./session.types";
|
|
9
|
-
export * from "./tenant-member.types";
|
|
10
|
-
export * from "./tenant.types";
|
|
11
|
-
export * from "./token.types";
|
|
12
|
-
export * from "./user.types";
|
package/dist/types/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from "./auth-api.types";
|
|
2
|
-
export * from "./auth-context.types";
|
|
3
|
-
export * from "./config.types";
|
|
4
|
-
export * from "./logger.types";
|
|
5
|
-
export * from "./password.types";
|
|
6
|
-
export * from "./permission.types";
|
|
7
|
-
export * from "./rate-limit.types";
|
|
8
|
-
export * from "./session.types";
|
|
9
|
-
export * from "./tenant-member.types";
|
|
10
|
-
export * from "./tenant.types";
|
|
11
|
-
export * from "./token.types";
|
|
12
|
-
export * from "./user.types";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type LoggerService = {
|
|
2
|
-
debug(message: string, context?: Record<string, unknown>): void;
|
|
3
|
-
info(message: string, context?: Record<string, unknown>): void;
|
|
4
|
-
warn(message: string, context?: Record<string, unknown>): void;
|
|
5
|
-
error(message: string, context?: Record<string, unknown>): void;
|
|
6
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type ResourceAction = {
|
|
2
|
-
resource: string;
|
|
3
|
-
action: string;
|
|
4
|
-
};
|
|
5
|
-
export type PermissionCheckFn = (userId: string, resource: string, action: string) => Promise<void>;
|
|
6
|
-
export type TenantPermissionCheckFn = (userId: string, tenantId: string, resource: string, action: string) => Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type Session = {
|
|
2
|
-
id: string;
|
|
3
|
-
userId: string;
|
|
4
|
-
tenantId: string;
|
|
5
|
-
refreshTokenHash: string;
|
|
6
|
-
deviceInfo: string | null;
|
|
7
|
-
ipAddress: string | null;
|
|
8
|
-
userAgent: string | null;
|
|
9
|
-
expiresAt: string;
|
|
10
|
-
createdAt: string;
|
|
11
|
-
};
|
|
12
|
-
export type CreateSessionInput = {
|
|
13
|
-
userId: string;
|
|
14
|
-
tenantId: string;
|
|
15
|
-
refreshTokenHash: string;
|
|
16
|
-
deviceInfo?: string;
|
|
17
|
-
ipAddress?: string;
|
|
18
|
-
userAgent?: string;
|
|
19
|
-
expiresAt: string;
|
|
20
|
-
};
|
|
21
|
-
export type SessionInfo = Session;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type TenantMemberRole = "owner" | "admin" | "member";
|
|
2
|
-
export type TenantMember = {
|
|
3
|
-
id: string;
|
|
4
|
-
tenantId: string;
|
|
5
|
-
userId: string;
|
|
6
|
-
role: TenantMemberRole;
|
|
7
|
-
joinedAt: string;
|
|
8
|
-
};
|
|
9
|
-
export type CreateTenantMemberInput = {
|
|
10
|
-
tenantId: string;
|
|
11
|
-
userId: string;
|
|
12
|
-
role?: TenantMemberRole;
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type TenantStatus = "active" | "suspended";
|
|
2
|
-
export type Tenant = {
|
|
3
|
-
id: string;
|
|
4
|
-
name: string;
|
|
5
|
-
slug: string;
|
|
6
|
-
status: TenantStatus;
|
|
7
|
-
maxUsers: number;
|
|
8
|
-
settings: string | null;
|
|
9
|
-
createdAt: string;
|
|
10
|
-
updatedAt: string;
|
|
11
|
-
};
|
|
12
|
-
export type CreateTenantInput = {
|
|
13
|
-
name: string;
|
|
14
|
-
slug: string;
|
|
15
|
-
maxUsers?: number;
|
|
16
|
-
settings?: string;
|
|
17
|
-
};
|
|
18
|
-
export type UpdateTenantInput = {
|
|
19
|
-
name?: string;
|
|
20
|
-
maxUsers?: number;
|
|
21
|
-
settings?: string;
|
|
22
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type AccessTokenPayload = {
|
|
2
|
-
sub: string;
|
|
3
|
-
type: "access";
|
|
4
|
-
tenantId?: string;
|
|
5
|
-
iss?: string;
|
|
6
|
-
aud?: string;
|
|
7
|
-
jti?: string;
|
|
8
|
-
roles?: string[];
|
|
9
|
-
permissions?: string[];
|
|
10
|
-
};
|
|
11
|
-
export type RefreshTokenPayload = {
|
|
12
|
-
sub: string;
|
|
13
|
-
sessionId: string;
|
|
14
|
-
type: "refresh";
|
|
15
|
-
};
|
|
16
|
-
export type PasswordResetTokenPayload = {
|
|
17
|
-
sub: string;
|
|
18
|
-
type: "password_reset";
|
|
19
|
-
};
|
|
20
|
-
export type MfaPendingTokenPayload = {
|
|
21
|
-
sub: string;
|
|
22
|
-
type: "mfa_pending";
|
|
23
|
-
};
|
|
24
|
-
export type TokenPayload = AccessTokenPayload | RefreshTokenPayload | PasswordResetTokenPayload | MfaPendingTokenPayload;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|