@aepstore-dev/contracts 1.2.0 → 1.4.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.
- package/gen/auth.ts +70 -79
- package/gen/users.ts +7 -0
- package/package.json +1 -1
- package/proto/auth.proto +69 -63
- package/proto/users.proto +5 -0
package/gen/auth.ts
CHANGED
|
@@ -34,32 +34,16 @@ export interface RegisterRequest {
|
|
|
34
34
|
ip: string;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/**
|
|
38
|
-
export interface AuthResponse {
|
|
39
|
-
accessToken: string;
|
|
40
|
-
refreshToken: string;
|
|
41
|
-
user: AuthUser | undefined;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface AuthUser {
|
|
45
|
-
id: string;
|
|
46
|
-
email: string;
|
|
47
|
-
username: string;
|
|
48
|
-
/** primary role for backwards compat ("User" / "Administrator" / "Moderator") */
|
|
49
|
-
role: string;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** Code types: '2fa', 'reset', 'confirm', 'totp' (legacy strings preserved as-is). */
|
|
37
|
+
/** type ∈ { twofa, reset, totp_generate, totp_activate, confirm } (legacy strings) */
|
|
53
38
|
export interface CreateCodeRequest {
|
|
54
39
|
email: string;
|
|
55
40
|
type: string;
|
|
56
41
|
}
|
|
57
42
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
/** `new_password` is only used by the 'reset' flow. */
|
|
43
|
+
/**
|
|
44
|
+
* type ∈ { twofa, twofa_deactivate, reset, totp, totp_deactivate, backup, confirm }
|
|
45
|
+
* new_password is only used by the 'reset' flow.
|
|
46
|
+
*/
|
|
63
47
|
export interface VerifyCodeRequest {
|
|
64
48
|
email: string;
|
|
65
49
|
code: string;
|
|
@@ -68,29 +52,10 @@ export interface VerifyCodeRequest {
|
|
|
68
52
|
newPassword: string;
|
|
69
53
|
}
|
|
70
54
|
|
|
71
|
-
/**
|
|
72
|
-
* Some verification flows (e.g. confirm-on-register) issue tokens immediately;
|
|
73
|
-
* others just return ok=true.
|
|
74
|
-
*/
|
|
75
|
-
export interface VerifyCodeResponse {
|
|
76
|
-
ok: boolean;
|
|
77
|
-
/** optional */
|
|
78
|
-
accessToken: string;
|
|
79
|
-
/** optional */
|
|
80
|
-
refreshToken: string;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
55
|
export interface CheckTokenRequest {
|
|
84
56
|
token: string;
|
|
85
57
|
}
|
|
86
58
|
|
|
87
|
-
export interface CheckTokenResponse {
|
|
88
|
-
valid: boolean;
|
|
89
|
-
userId: string;
|
|
90
|
-
/** populated when valid=false */
|
|
91
|
-
reason: string;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
59
|
export interface RefreshTokenRequest {
|
|
95
60
|
refreshToken: string;
|
|
96
61
|
/** optional */
|
|
@@ -103,24 +68,54 @@ export interface Get2faStatusRequest {
|
|
|
103
68
|
username: string;
|
|
104
69
|
}
|
|
105
70
|
|
|
106
|
-
export interface Get2faStatusResponse {
|
|
107
|
-
enabled: boolean;
|
|
108
|
-
type: TwoFactorType;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
71
|
export interface GetProfileRequest {
|
|
112
72
|
userId: string;
|
|
113
73
|
}
|
|
114
74
|
|
|
115
|
-
export interface
|
|
75
|
+
export interface AuthUser {
|
|
116
76
|
id: string;
|
|
117
|
-
email: string;
|
|
118
77
|
username: string;
|
|
119
|
-
|
|
78
|
+
email: string;
|
|
79
|
+
avatarUrl: string;
|
|
80
|
+
bannerUrl: string;
|
|
81
|
+
roles: string[];
|
|
82
|
+
/** primary role (roles[0]) */
|
|
83
|
+
role: string;
|
|
120
84
|
isVerified: boolean;
|
|
85
|
+
twoFactorType: TwoFactorType;
|
|
121
86
|
twoFactorEnabled: boolean;
|
|
87
|
+
/** Decimal as string (D7) */
|
|
88
|
+
balance: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Unified result for login/register/createCode/verifyCode/refresh. Which fields
|
|
93
|
+
* are populated depends on the flow:
|
|
94
|
+
* - fully authenticated → access_token + refresh_token + expires_in + user
|
|
95
|
+
* - 2FA required / pending confirm → message + requires_2fa + two_factor_type + user (no tokens)
|
|
96
|
+
* - totp_generate → secret + otpauth + qr (+ user)
|
|
97
|
+
* - totp_activate → backup_codes (+ tokens/user)
|
|
98
|
+
*/
|
|
99
|
+
export interface AuthResult {
|
|
100
|
+
accessToken: string;
|
|
101
|
+
refreshToken: string;
|
|
102
|
+
expiresIn: number;
|
|
103
|
+
user: AuthUser | undefined;
|
|
104
|
+
message: string;
|
|
105
|
+
requires2fa: boolean;
|
|
122
106
|
twoFactorType: TwoFactorType;
|
|
123
|
-
|
|
107
|
+
/** TOTP setup extras */
|
|
108
|
+
secret: string;
|
|
109
|
+
otpauth: string;
|
|
110
|
+
/** data URL (PNG) */
|
|
111
|
+
qr: string;
|
|
112
|
+
backupCodes: string[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface TwoFactorStatusResponse {
|
|
116
|
+
twoFactorType: TwoFactorType;
|
|
117
|
+
has2fa: boolean;
|
|
118
|
+
isVerified: boolean;
|
|
124
119
|
}
|
|
125
120
|
|
|
126
121
|
export interface Empty {
|
|
@@ -130,64 +125,60 @@ export const AUTH_V1_PACKAGE_NAME = "auth.v1";
|
|
|
130
125
|
|
|
131
126
|
/**
|
|
132
127
|
* Ported from legacy auth-service (@MessagePattern → @GrpcMethod).
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
128
|
+
* Tokens are HMAC primitives from @aepstore-dev/passport:
|
|
129
|
+
* - access token: short TTL, carries userId; the gateway validates it
|
|
130
|
+
* locally via PassportAuthGuard (no round-trip here).
|
|
131
|
+
* - refresh token: long TTL HMAC + a RefreshToken DB row (device list +
|
|
132
|
+
* revocation). Refresh verifies the HMAC AND that the row still exists.
|
|
136
133
|
*/
|
|
137
134
|
|
|
138
135
|
export interface AuthServiceClient {
|
|
139
|
-
login(request: LoginRequest): Observable<
|
|
136
|
+
login(request: LoginRequest): Observable<AuthResult>;
|
|
140
137
|
|
|
141
|
-
register(request: RegisterRequest): Observable<
|
|
138
|
+
register(request: RegisterRequest): Observable<AuthResult>;
|
|
142
139
|
|
|
143
|
-
createCode(request: CreateCodeRequest): Observable<
|
|
140
|
+
createCode(request: CreateCodeRequest): Observable<AuthResult>;
|
|
144
141
|
|
|
145
|
-
verifyCode(request: VerifyCodeRequest): Observable<
|
|
142
|
+
verifyCode(request: VerifyCodeRequest): Observable<AuthResult>;
|
|
146
143
|
|
|
147
|
-
checkToken(request: CheckTokenRequest): Observable<
|
|
144
|
+
checkToken(request: CheckTokenRequest): Observable<AuthUser>;
|
|
148
145
|
|
|
149
|
-
refreshToken(request: RefreshTokenRequest): Observable<
|
|
146
|
+
refreshToken(request: RefreshTokenRequest): Observable<AuthResult>;
|
|
150
147
|
|
|
151
|
-
get2FaStatus(request: Get2faStatusRequest): Observable<
|
|
148
|
+
get2FaStatus(request: Get2faStatusRequest): Observable<TwoFactorStatusResponse>;
|
|
152
149
|
|
|
153
|
-
getProfile(request: GetProfileRequest): Observable<
|
|
150
|
+
getProfile(request: GetProfileRequest): Observable<AuthUser>;
|
|
154
151
|
|
|
155
152
|
cleanupExpiredTotpSetups(request: Empty): Observable<Empty>;
|
|
156
153
|
}
|
|
157
154
|
|
|
158
155
|
/**
|
|
159
156
|
* Ported from legacy auth-service (@MessagePattern → @GrpcMethod).
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
157
|
+
* Tokens are HMAC primitives from @aepstore-dev/passport:
|
|
158
|
+
* - access token: short TTL, carries userId; the gateway validates it
|
|
159
|
+
* locally via PassportAuthGuard (no round-trip here).
|
|
160
|
+
* - refresh token: long TTL HMAC + a RefreshToken DB row (device list +
|
|
161
|
+
* revocation). Refresh verifies the HMAC AND that the row still exists.
|
|
163
162
|
*/
|
|
164
163
|
|
|
165
164
|
export interface AuthServiceController {
|
|
166
|
-
login(request: LoginRequest): Promise<
|
|
165
|
+
login(request: LoginRequest): Promise<AuthResult> | Observable<AuthResult> | AuthResult;
|
|
167
166
|
|
|
168
|
-
register(request: RegisterRequest): Promise<
|
|
167
|
+
register(request: RegisterRequest): Promise<AuthResult> | Observable<AuthResult> | AuthResult;
|
|
169
168
|
|
|
170
|
-
createCode(
|
|
171
|
-
request: CreateCodeRequest,
|
|
172
|
-
): Promise<CreateCodeResponse> | Observable<CreateCodeResponse> | CreateCodeResponse;
|
|
169
|
+
createCode(request: CreateCodeRequest): Promise<AuthResult> | Observable<AuthResult> | AuthResult;
|
|
173
170
|
|
|
174
|
-
verifyCode(
|
|
175
|
-
request: VerifyCodeRequest,
|
|
176
|
-
): Promise<VerifyCodeResponse> | Observable<VerifyCodeResponse> | VerifyCodeResponse;
|
|
171
|
+
verifyCode(request: VerifyCodeRequest): Promise<AuthResult> | Observable<AuthResult> | AuthResult;
|
|
177
172
|
|
|
178
|
-
checkToken(
|
|
179
|
-
request: CheckTokenRequest,
|
|
180
|
-
): Promise<CheckTokenResponse> | Observable<CheckTokenResponse> | CheckTokenResponse;
|
|
173
|
+
checkToken(request: CheckTokenRequest): Promise<AuthUser> | Observable<AuthUser> | AuthUser;
|
|
181
174
|
|
|
182
|
-
refreshToken(request: RefreshTokenRequest): Promise<
|
|
175
|
+
refreshToken(request: RefreshTokenRequest): Promise<AuthResult> | Observable<AuthResult> | AuthResult;
|
|
183
176
|
|
|
184
177
|
get2FaStatus(
|
|
185
178
|
request: Get2faStatusRequest,
|
|
186
|
-
): Promise<
|
|
179
|
+
): Promise<TwoFactorStatusResponse> | Observable<TwoFactorStatusResponse> | TwoFactorStatusResponse;
|
|
187
180
|
|
|
188
|
-
getProfile(
|
|
189
|
-
request: GetProfileRequest,
|
|
190
|
-
): Promise<UserProfileResponse> | Observable<UserProfileResponse> | UserProfileResponse;
|
|
181
|
+
getProfile(request: GetProfileRequest): Promise<AuthUser> | Observable<AuthUser> | AuthUser;
|
|
191
182
|
|
|
192
183
|
cleanupExpiredTotpSetups(request: Empty): Promise<Empty> | Observable<Empty> | Empty;
|
|
193
184
|
}
|
package/gen/users.ts
CHANGED
|
@@ -57,6 +57,13 @@ export interface Product {
|
|
|
57
57
|
price: string;
|
|
58
58
|
createdAt: string;
|
|
59
59
|
updatedAt: string;
|
|
60
|
+
/** profile-card preview fields */
|
|
61
|
+
preview: string;
|
|
62
|
+
/** Decimal as string */
|
|
63
|
+
finalPrice: string;
|
|
64
|
+
/** number as string */
|
|
65
|
+
averageRating: string;
|
|
66
|
+
status: string;
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
export interface Video {
|
package/package.json
CHANGED
package/proto/auth.proto
CHANGED
|
@@ -3,21 +3,33 @@ syntax = "proto3";
|
|
|
3
3
|
package auth.v1;
|
|
4
4
|
|
|
5
5
|
// Ported from legacy auth-service (@MessagePattern → @GrpcMethod).
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
6
|
+
// Tokens are HMAC primitives from @aepstore-dev/passport:
|
|
7
|
+
// - access token: short TTL, carries userId; the gateway validates it
|
|
8
|
+
// locally via PassportAuthGuard (no round-trip here).
|
|
9
|
+
// - refresh token: long TTL HMAC + a RefreshToken DB row (device list +
|
|
10
|
+
// revocation). Refresh verifies the HMAC AND that the row still exists.
|
|
9
11
|
service AuthService {
|
|
10
|
-
rpc Login(LoginRequest) returns (
|
|
11
|
-
rpc Register(RegisterRequest) returns (
|
|
12
|
-
rpc CreateCode(CreateCodeRequest) returns (
|
|
13
|
-
rpc VerifyCode(VerifyCodeRequest) returns (
|
|
14
|
-
rpc CheckToken(CheckTokenRequest) returns (
|
|
15
|
-
rpc RefreshToken(RefreshTokenRequest) returns (
|
|
16
|
-
rpc Get2faStatus(Get2faStatusRequest) returns (
|
|
17
|
-
rpc GetProfile(GetProfileRequest) returns (
|
|
12
|
+
rpc Login(LoginRequest) returns (AuthResult);
|
|
13
|
+
rpc Register(RegisterRequest) returns (AuthResult);
|
|
14
|
+
rpc CreateCode(CreateCodeRequest) returns (AuthResult);
|
|
15
|
+
rpc VerifyCode(VerifyCodeRequest) returns (AuthResult);
|
|
16
|
+
rpc CheckToken(CheckTokenRequest) returns (AuthUser);
|
|
17
|
+
rpc RefreshToken(RefreshTokenRequest) returns (AuthResult);
|
|
18
|
+
rpc Get2faStatus(Get2faStatusRequest) returns (TwoFactorStatusResponse);
|
|
19
|
+
rpc GetProfile(GetProfileRequest) returns (AuthUser);
|
|
18
20
|
rpc CleanupExpiredTotpSetups(Empty) returns (Empty);
|
|
19
21
|
}
|
|
20
22
|
|
|
23
|
+
enum TwoFactorType {
|
|
24
|
+
NONE = 0;
|
|
25
|
+
APP = 1;
|
|
26
|
+
EMAIL = 2;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Requests
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
|
|
21
33
|
// Login by username OR email (one of the two must be set).
|
|
22
34
|
message LoginRequest {
|
|
23
35
|
string password = 1;
|
|
@@ -32,31 +44,14 @@ message RegisterRequest {
|
|
|
32
44
|
string ip = 4; // optional, attached by gateway from req
|
|
33
45
|
}
|
|
34
46
|
|
|
35
|
-
//
|
|
36
|
-
message AuthResponse {
|
|
37
|
-
string access_token = 1;
|
|
38
|
-
string refresh_token = 2;
|
|
39
|
-
AuthUser user = 3;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
message AuthUser {
|
|
43
|
-
string id = 1;
|
|
44
|
-
string email = 2;
|
|
45
|
-
string username = 3;
|
|
46
|
-
string role = 4; // primary role for backwards compat ("User" / "Administrator" / "Moderator")
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Code types: '2fa', 'reset', 'confirm', 'totp' (legacy strings preserved as-is).
|
|
47
|
+
// type ∈ { twofa, reset, totp_generate, totp_activate, confirm } (legacy strings)
|
|
50
48
|
message CreateCodeRequest {
|
|
51
49
|
string email = 1;
|
|
52
50
|
string type = 2;
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// `new_password` is only used by the 'reset' flow.
|
|
53
|
+
// type ∈ { twofa, twofa_deactivate, reset, totp, totp_deactivate, backup, confirm }
|
|
54
|
+
// new_password is only used by the 'reset' flow.
|
|
60
55
|
message VerifyCodeRequest {
|
|
61
56
|
string email = 1;
|
|
62
57
|
string code = 2;
|
|
@@ -64,24 +59,10 @@ message VerifyCodeRequest {
|
|
|
64
59
|
string new_password = 4; // optional
|
|
65
60
|
}
|
|
66
61
|
|
|
67
|
-
// Some verification flows (e.g. confirm-on-register) issue tokens immediately;
|
|
68
|
-
// others just return ok=true.
|
|
69
|
-
message VerifyCodeResponse {
|
|
70
|
-
bool ok = 1;
|
|
71
|
-
string access_token = 2; // optional
|
|
72
|
-
string refresh_token = 3; // optional
|
|
73
|
-
}
|
|
74
|
-
|
|
75
62
|
message CheckTokenRequest {
|
|
76
63
|
string token = 1;
|
|
77
64
|
}
|
|
78
65
|
|
|
79
|
-
message CheckTokenResponse {
|
|
80
|
-
bool valid = 1;
|
|
81
|
-
string user_id = 2;
|
|
82
|
-
string reason = 3; // populated when valid=false
|
|
83
|
-
}
|
|
84
|
-
|
|
85
66
|
message RefreshTokenRequest {
|
|
86
67
|
string refresh_token = 1;
|
|
87
68
|
string user_agent = 2; // optional
|
|
@@ -92,30 +73,55 @@ message Get2faStatusRequest {
|
|
|
92
73
|
string username = 1;
|
|
93
74
|
}
|
|
94
75
|
|
|
95
|
-
message Get2faStatusResponse {
|
|
96
|
-
bool enabled = 1;
|
|
97
|
-
TwoFactorType type = 2;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
enum TwoFactorType {
|
|
101
|
-
NONE = 0;
|
|
102
|
-
APP = 1;
|
|
103
|
-
EMAIL = 2;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
76
|
message GetProfileRequest {
|
|
107
77
|
string user_id = 1;
|
|
108
78
|
}
|
|
109
79
|
|
|
110
|
-
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Responses
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
message AuthUser {
|
|
111
85
|
string id = 1;
|
|
112
|
-
string
|
|
113
|
-
string
|
|
114
|
-
string
|
|
115
|
-
|
|
116
|
-
|
|
86
|
+
string username = 2;
|
|
87
|
+
string email = 3;
|
|
88
|
+
string avatar_url = 4;
|
|
89
|
+
string banner_url = 5;
|
|
90
|
+
repeated string roles = 6;
|
|
91
|
+
string role = 7; // primary role (roles[0])
|
|
92
|
+
bool is_verified = 8;
|
|
93
|
+
TwoFactorType two_factor_type = 9;
|
|
94
|
+
bool two_factor_enabled = 10;
|
|
95
|
+
string balance = 11; // Decimal as string (D7)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Unified result for login/register/createCode/verifyCode/refresh. Which fields
|
|
99
|
+
// are populated depends on the flow:
|
|
100
|
+
// - fully authenticated → access_token + refresh_token + expires_in + user
|
|
101
|
+
// - 2FA required / pending confirm → message + requires_2fa + two_factor_type + user (no tokens)
|
|
102
|
+
// - totp_generate → secret + otpauth + qr (+ user)
|
|
103
|
+
// - totp_activate → backup_codes (+ tokens/user)
|
|
104
|
+
message AuthResult {
|
|
105
|
+
string access_token = 1;
|
|
106
|
+
string refresh_token = 2;
|
|
107
|
+
int32 expires_in = 3;
|
|
108
|
+
AuthUser user = 4;
|
|
109
|
+
|
|
110
|
+
string message = 5;
|
|
111
|
+
bool requires_2fa = 6;
|
|
117
112
|
TwoFactorType two_factor_type = 7;
|
|
118
|
-
|
|
113
|
+
|
|
114
|
+
// TOTP setup extras
|
|
115
|
+
string secret = 8;
|
|
116
|
+
string otpauth = 9;
|
|
117
|
+
string qr = 10; // data URL (PNG)
|
|
118
|
+
repeated string backup_codes = 11;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
message TwoFactorStatusResponse {
|
|
122
|
+
TwoFactorType two_factor_type = 1;
|
|
123
|
+
bool has_2fa = 2;
|
|
124
|
+
bool is_verified = 3;
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
message Empty {}
|
package/proto/users.proto
CHANGED
|
@@ -52,6 +52,11 @@ message Product {
|
|
|
52
52
|
string price = 4; // Decimal as string (D7)
|
|
53
53
|
string created_at = 5;
|
|
54
54
|
string updated_at = 6;
|
|
55
|
+
// profile-card preview fields
|
|
56
|
+
string preview = 7;
|
|
57
|
+
string final_price = 8; // Decimal as string
|
|
58
|
+
string average_rating = 9; // number as string
|
|
59
|
+
string status = 10;
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
message Video {
|