@aepstore-dev/contracts 1.32.0 → 1.33.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/payments.ts +175 -0
- package/gen/users.ts +201 -0
- package/package.json +1 -1
- package/proto/activity.proto +200 -200
- package/proto/auth.proto +126 -126
- package/proto/mail.proto +42 -42
- package/proto/payments.proto +303 -203
- package/proto/products.proto +404 -404
- package/proto/support.proto +118 -118
- package/proto/taxonomy.proto +105 -105
- package/proto/upload.proto +171 -171
- package/proto/users.proto +411 -286
package/proto/activity.proto
CHANGED
|
@@ -1,200 +1,200 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
package activity.v1;
|
|
4
|
-
|
|
5
|
-
service ActivityService {
|
|
6
|
-
// Reports
|
|
7
|
-
rpc ReportCreate(CreateReportRequest) returns (ReportResponse);
|
|
8
|
-
rpc ReportList(ListReportsRequest) returns (ReportsListResponse);
|
|
9
|
-
rpc ReportGet(ReportIdRequest) returns (ReportResponse);
|
|
10
|
-
rpc ReportModerate(ModerateReportRequest) returns (ReportResponse);
|
|
11
|
-
|
|
12
|
-
// Report categories
|
|
13
|
-
rpc ReportCategoryCreate(CreateReportCategoryRequest) returns (ReportCategoryResponse);
|
|
14
|
-
rpc ReportCategoryList(ListReportCategoriesRequest) returns (ReportCategoriesListResponse);
|
|
15
|
-
rpc ReportCategoryGet(ReportCategoryIdRequest) returns (ReportCategoryResponse);
|
|
16
|
-
rpc ReportCategoryUpdate(UpdateReportCategoryRequest) returns (ReportCategoryResponse);
|
|
17
|
-
rpc ReportCategoryDelete(ReportCategoryIdRequest) returns (Ok);
|
|
18
|
-
|
|
19
|
-
// Reviews
|
|
20
|
-
rpc ReviewCreate(CreateReviewRequest) returns (ReviewResponse);
|
|
21
|
-
rpc GetProductReviews(GetProductReviewsRequest) returns (ReviewsListResponse);
|
|
22
|
-
|
|
23
|
-
// NOTE: subscriptions live in users-service (CreateSubscription/DeleteSubscription).
|
|
24
|
-
// The former activity.ToggleSubscription was a duplicate write path — removed.
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// =================================================================
|
|
28
|
-
// Enums
|
|
29
|
-
// =================================================================
|
|
30
|
-
|
|
31
|
-
// Member names match the DB enum string values exactly (enums: String on the
|
|
32
|
-
// wire), so DB values pass straight through with no mapping. UNSPECIFIED=0
|
|
33
|
-
// represents "no value / not provided" (e.g. an optional list filter).
|
|
34
|
-
enum ReportType {
|
|
35
|
-
REPORT_TYPE_UNSPECIFIED = 0;
|
|
36
|
-
PRODUCT = 1;
|
|
37
|
-
PROFILE = 2;
|
|
38
|
-
REVIEW = 3;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
enum ReportStatus {
|
|
42
|
-
REPORT_STATUS_UNSPECIFIED = 0;
|
|
43
|
-
PENDING = 1;
|
|
44
|
-
IN_PROGRESS = 2;
|
|
45
|
-
RESOLVED = 3;
|
|
46
|
-
DISMISSED = 4;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// =================================================================
|
|
50
|
-
// Reports
|
|
51
|
-
// =================================================================
|
|
52
|
-
|
|
53
|
-
message Report {
|
|
54
|
-
string id = 1;
|
|
55
|
-
ReportType type = 2;
|
|
56
|
-
string object_id = 3;
|
|
57
|
-
string user_id = 4;
|
|
58
|
-
string product_id = 5;
|
|
59
|
-
repeated ReportCategory categories = 6;
|
|
60
|
-
string message = 7;
|
|
61
|
-
ReportStatus status = 8;
|
|
62
|
-
string created_at = 9;
|
|
63
|
-
string updated_at = 10;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
message ReportResponse {
|
|
67
|
-
Report report = 1;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
message CreateReportRequest {
|
|
71
|
-
string user_id = 1;
|
|
72
|
-
ReportType type = 2;
|
|
73
|
-
string object_id = 3;
|
|
74
|
-
repeated string categories = 4; // names
|
|
75
|
-
string message = 5;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
message ListReportsRequest {
|
|
79
|
-
ReportType type = 1;
|
|
80
|
-
ReportStatus status = 2;
|
|
81
|
-
string user_id = 3;
|
|
82
|
-
string object_id = 4;
|
|
83
|
-
int32 page = 5;
|
|
84
|
-
int32 limit = 6;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
message ReportsListResponse {
|
|
88
|
-
repeated Report items = 1;
|
|
89
|
-
int32 total = 2;
|
|
90
|
-
int32 page = 3;
|
|
91
|
-
int32 limit = 4;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
message ReportIdRequest {
|
|
95
|
-
string id = 1;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
message ModerateReportRequest {
|
|
99
|
-
string id = 1;
|
|
100
|
-
string action = 2; // 'accept' | 'reject'
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// =================================================================
|
|
104
|
-
// Report categories
|
|
105
|
-
// =================================================================
|
|
106
|
-
|
|
107
|
-
message ReportCategory {
|
|
108
|
-
string id = 1;
|
|
109
|
-
string name = 2;
|
|
110
|
-
ReportType type = 3;
|
|
111
|
-
string icon = 4;
|
|
112
|
-
string description = 5;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
message ReportCategoryResponse {
|
|
116
|
-
ReportCategory category = 1;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
message CreateReportCategoryRequest {
|
|
120
|
-
string name = 1;
|
|
121
|
-
ReportType type = 2;
|
|
122
|
-
string icon = 3;
|
|
123
|
-
string description = 4;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
message UpdateReportCategoryRequest {
|
|
127
|
-
string id = 1;
|
|
128
|
-
string name = 2;
|
|
129
|
-
string icon = 3;
|
|
130
|
-
string description = 4;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
message ListReportCategoriesRequest {
|
|
134
|
-
ReportType type = 1;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
message ReportCategoriesListResponse {
|
|
138
|
-
repeated ReportCategory items = 1;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
message ReportCategoryIdRequest {
|
|
142
|
-
string id = 1;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// =================================================================
|
|
146
|
-
// Reviews
|
|
147
|
-
// =================================================================
|
|
148
|
-
|
|
149
|
-
message ReviewUser {
|
|
150
|
-
string id = 1;
|
|
151
|
-
string username = 2;
|
|
152
|
-
string avatar_url = 3;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
message Review {
|
|
156
|
-
reserved 4, 8, 9; // retired flat user_id / user_username / user_avatar_url
|
|
157
|
-
string id = 1;
|
|
158
|
-
int32 rating = 2;
|
|
159
|
-
string text = 3;
|
|
160
|
-
string product_id = 5;
|
|
161
|
-
string created_at = 6;
|
|
162
|
-
string updated_at = 7;
|
|
163
|
-
ReviewUser user = 10;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
message ReviewResponse {
|
|
167
|
-
Review review = 1;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
message CreateReviewRequest {
|
|
171
|
-
string user_id = 1;
|
|
172
|
-
string product_id = 2;
|
|
173
|
-
int32 rating = 3;
|
|
174
|
-
string text = 4;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
message GetProductReviewsRequest {
|
|
178
|
-
string product_id = 1;
|
|
179
|
-
int32 page = 2;
|
|
180
|
-
int32 limit = 3;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
message ReviewsListResponse {
|
|
184
|
-
repeated Review items = 1;
|
|
185
|
-
int32 total = 2;
|
|
186
|
-
int32 page = 3;
|
|
187
|
-
int32 limit = 4;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// =================================================================
|
|
191
|
-
// Subscriptions
|
|
192
|
-
// =================================================================
|
|
193
|
-
|
|
194
|
-
// =================================================================
|
|
195
|
-
// Misc
|
|
196
|
-
// =================================================================
|
|
197
|
-
|
|
198
|
-
message Ok {
|
|
199
|
-
bool ok = 1;
|
|
200
|
-
}
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package activity.v1;
|
|
4
|
+
|
|
5
|
+
service ActivityService {
|
|
6
|
+
// Reports
|
|
7
|
+
rpc ReportCreate(CreateReportRequest) returns (ReportResponse);
|
|
8
|
+
rpc ReportList(ListReportsRequest) returns (ReportsListResponse);
|
|
9
|
+
rpc ReportGet(ReportIdRequest) returns (ReportResponse);
|
|
10
|
+
rpc ReportModerate(ModerateReportRequest) returns (ReportResponse);
|
|
11
|
+
|
|
12
|
+
// Report categories
|
|
13
|
+
rpc ReportCategoryCreate(CreateReportCategoryRequest) returns (ReportCategoryResponse);
|
|
14
|
+
rpc ReportCategoryList(ListReportCategoriesRequest) returns (ReportCategoriesListResponse);
|
|
15
|
+
rpc ReportCategoryGet(ReportCategoryIdRequest) returns (ReportCategoryResponse);
|
|
16
|
+
rpc ReportCategoryUpdate(UpdateReportCategoryRequest) returns (ReportCategoryResponse);
|
|
17
|
+
rpc ReportCategoryDelete(ReportCategoryIdRequest) returns (Ok);
|
|
18
|
+
|
|
19
|
+
// Reviews
|
|
20
|
+
rpc ReviewCreate(CreateReviewRequest) returns (ReviewResponse);
|
|
21
|
+
rpc GetProductReviews(GetProductReviewsRequest) returns (ReviewsListResponse);
|
|
22
|
+
|
|
23
|
+
// NOTE: subscriptions live in users-service (CreateSubscription/DeleteSubscription).
|
|
24
|
+
// The former activity.ToggleSubscription was a duplicate write path — removed.
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// =================================================================
|
|
28
|
+
// Enums
|
|
29
|
+
// =================================================================
|
|
30
|
+
|
|
31
|
+
// Member names match the DB enum string values exactly (enums: String on the
|
|
32
|
+
// wire), so DB values pass straight through with no mapping. UNSPECIFIED=0
|
|
33
|
+
// represents "no value / not provided" (e.g. an optional list filter).
|
|
34
|
+
enum ReportType {
|
|
35
|
+
REPORT_TYPE_UNSPECIFIED = 0;
|
|
36
|
+
PRODUCT = 1;
|
|
37
|
+
PROFILE = 2;
|
|
38
|
+
REVIEW = 3;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
enum ReportStatus {
|
|
42
|
+
REPORT_STATUS_UNSPECIFIED = 0;
|
|
43
|
+
PENDING = 1;
|
|
44
|
+
IN_PROGRESS = 2;
|
|
45
|
+
RESOLVED = 3;
|
|
46
|
+
DISMISSED = 4;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// =================================================================
|
|
50
|
+
// Reports
|
|
51
|
+
// =================================================================
|
|
52
|
+
|
|
53
|
+
message Report {
|
|
54
|
+
string id = 1;
|
|
55
|
+
ReportType type = 2;
|
|
56
|
+
string object_id = 3;
|
|
57
|
+
string user_id = 4;
|
|
58
|
+
string product_id = 5;
|
|
59
|
+
repeated ReportCategory categories = 6;
|
|
60
|
+
string message = 7;
|
|
61
|
+
ReportStatus status = 8;
|
|
62
|
+
string created_at = 9;
|
|
63
|
+
string updated_at = 10;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
message ReportResponse {
|
|
67
|
+
Report report = 1;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
message CreateReportRequest {
|
|
71
|
+
string user_id = 1;
|
|
72
|
+
ReportType type = 2;
|
|
73
|
+
string object_id = 3;
|
|
74
|
+
repeated string categories = 4; // names
|
|
75
|
+
string message = 5;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
message ListReportsRequest {
|
|
79
|
+
ReportType type = 1;
|
|
80
|
+
ReportStatus status = 2;
|
|
81
|
+
string user_id = 3;
|
|
82
|
+
string object_id = 4;
|
|
83
|
+
int32 page = 5;
|
|
84
|
+
int32 limit = 6;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
message ReportsListResponse {
|
|
88
|
+
repeated Report items = 1;
|
|
89
|
+
int32 total = 2;
|
|
90
|
+
int32 page = 3;
|
|
91
|
+
int32 limit = 4;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
message ReportIdRequest {
|
|
95
|
+
string id = 1;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
message ModerateReportRequest {
|
|
99
|
+
string id = 1;
|
|
100
|
+
string action = 2; // 'accept' | 'reject'
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// =================================================================
|
|
104
|
+
// Report categories
|
|
105
|
+
// =================================================================
|
|
106
|
+
|
|
107
|
+
message ReportCategory {
|
|
108
|
+
string id = 1;
|
|
109
|
+
string name = 2;
|
|
110
|
+
ReportType type = 3;
|
|
111
|
+
string icon = 4;
|
|
112
|
+
string description = 5;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
message ReportCategoryResponse {
|
|
116
|
+
ReportCategory category = 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
message CreateReportCategoryRequest {
|
|
120
|
+
string name = 1;
|
|
121
|
+
ReportType type = 2;
|
|
122
|
+
string icon = 3;
|
|
123
|
+
string description = 4;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
message UpdateReportCategoryRequest {
|
|
127
|
+
string id = 1;
|
|
128
|
+
string name = 2;
|
|
129
|
+
string icon = 3;
|
|
130
|
+
string description = 4;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
message ListReportCategoriesRequest {
|
|
134
|
+
ReportType type = 1;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
message ReportCategoriesListResponse {
|
|
138
|
+
repeated ReportCategory items = 1;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
message ReportCategoryIdRequest {
|
|
142
|
+
string id = 1;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// =================================================================
|
|
146
|
+
// Reviews
|
|
147
|
+
// =================================================================
|
|
148
|
+
|
|
149
|
+
message ReviewUser {
|
|
150
|
+
string id = 1;
|
|
151
|
+
string username = 2;
|
|
152
|
+
string avatar_url = 3;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
message Review {
|
|
156
|
+
reserved 4, 8, 9; // retired flat user_id / user_username / user_avatar_url
|
|
157
|
+
string id = 1;
|
|
158
|
+
int32 rating = 2;
|
|
159
|
+
string text = 3;
|
|
160
|
+
string product_id = 5;
|
|
161
|
+
string created_at = 6;
|
|
162
|
+
string updated_at = 7;
|
|
163
|
+
ReviewUser user = 10;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
message ReviewResponse {
|
|
167
|
+
Review review = 1;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
message CreateReviewRequest {
|
|
171
|
+
string user_id = 1;
|
|
172
|
+
string product_id = 2;
|
|
173
|
+
int32 rating = 3;
|
|
174
|
+
string text = 4;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
message GetProductReviewsRequest {
|
|
178
|
+
string product_id = 1;
|
|
179
|
+
int32 page = 2;
|
|
180
|
+
int32 limit = 3;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
message ReviewsListResponse {
|
|
184
|
+
repeated Review items = 1;
|
|
185
|
+
int32 total = 2;
|
|
186
|
+
int32 page = 3;
|
|
187
|
+
int32 limit = 4;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// =================================================================
|
|
191
|
+
// Subscriptions
|
|
192
|
+
// =================================================================
|
|
193
|
+
|
|
194
|
+
// =================================================================
|
|
195
|
+
// Misc
|
|
196
|
+
// =================================================================
|
|
197
|
+
|
|
198
|
+
message Ok {
|
|
199
|
+
bool ok = 1;
|
|
200
|
+
}
|
package/proto/auth.proto
CHANGED
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
package auth.v1;
|
|
4
|
-
|
|
5
|
-
// Ported from legacy auth-service (@MessagePattern → @GrpcMethod).
|
|
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.
|
|
11
|
-
service AuthService {
|
|
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);
|
|
20
|
-
rpc CleanupExpiredTotpSetups(Empty) returns (Empty);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
enum TwoFactorType {
|
|
24
|
-
NONE = 0;
|
|
25
|
-
APP = 1;
|
|
26
|
-
EMAIL = 2;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// ---------------------------------------------------------------------------
|
|
30
|
-
// Requests
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
|
|
33
|
-
// Login by username OR email (one of the two must be set).
|
|
34
|
-
message LoginRequest {
|
|
35
|
-
string password = 1;
|
|
36
|
-
string credentials = 2; // username OR email — resolved by the service
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
message RegisterRequest {
|
|
40
|
-
string email = 1;
|
|
41
|
-
string username = 2;
|
|
42
|
-
string password = 3;
|
|
43
|
-
string ip = 4; // optional, attached by gateway from req
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// type ∈ { twofa, reset, totp_generate, totp_activate, confirm } (legacy strings)
|
|
47
|
-
message CreateCodeRequest {
|
|
48
|
-
string email = 1;
|
|
49
|
-
string type = 2;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// type ∈ { twofa, twofa_deactivate, reset, totp, totp_deactivate, backup, confirm }
|
|
53
|
-
// new_password is only used by the 'reset' flow.
|
|
54
|
-
message VerifyCodeRequest {
|
|
55
|
-
string email = 1;
|
|
56
|
-
string code = 2;
|
|
57
|
-
string type = 3;
|
|
58
|
-
string new_password = 4; // optional
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
message CheckTokenRequest {
|
|
62
|
-
string token = 1;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
message RefreshTokenRequest {
|
|
66
|
-
string refresh_token = 1;
|
|
67
|
-
string user_agent = 2; // optional
|
|
68
|
-
string ip = 3; // optional
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
message Get2faStatusRequest {
|
|
72
|
-
string username = 1;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
message GetProfileRequest {
|
|
76
|
-
string user_id = 1;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// ---------------------------------------------------------------------------
|
|
80
|
-
// Responses
|
|
81
|
-
// ---------------------------------------------------------------------------
|
|
82
|
-
|
|
83
|
-
message AuthUser {
|
|
84
|
-
string id = 1;
|
|
85
|
-
string username = 2;
|
|
86
|
-
string email = 3;
|
|
87
|
-
string avatar_url = 4;
|
|
88
|
-
string banner_url = 5;
|
|
89
|
-
repeated string roles = 6;
|
|
90
|
-
string role = 7; // primary role (roles[0])
|
|
91
|
-
bool is_verified = 8;
|
|
92
|
-
TwoFactorType two_factor_type = 9;
|
|
93
|
-
bool two_factor_enabled = 10;
|
|
94
|
-
string balance = 11; // Decimal as string (D7)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Unified result for login/register/createCode/verifyCode/refresh. Which fields
|
|
98
|
-
// are populated depends on the flow:
|
|
99
|
-
// - fully authenticated → access_token + refresh_token + expires_in + user
|
|
100
|
-
// - 2FA required / pending confirm → message + requires_2fa + two_factor_type + user (no tokens)
|
|
101
|
-
// - totp_generate → secret + otpauth + qr (+ user)
|
|
102
|
-
// - totp_activate → backup_codes (+ tokens/user)
|
|
103
|
-
message AuthResult {
|
|
104
|
-
string access_token = 1;
|
|
105
|
-
string refresh_token = 2;
|
|
106
|
-
int32 expires_in = 3;
|
|
107
|
-
AuthUser user = 4;
|
|
108
|
-
|
|
109
|
-
string message = 5;
|
|
110
|
-
bool requires_2fa = 6;
|
|
111
|
-
TwoFactorType two_factor_type = 7;
|
|
112
|
-
|
|
113
|
-
// TOTP setup extras
|
|
114
|
-
string secret = 8;
|
|
115
|
-
string otpauth = 9;
|
|
116
|
-
string qr = 10; // data URL (PNG)
|
|
117
|
-
repeated string backup_codes = 11;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
message TwoFactorStatusResponse {
|
|
121
|
-
TwoFactorType two_factor_type = 1;
|
|
122
|
-
bool has_2fa = 2;
|
|
123
|
-
bool is_verified = 3;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
message Empty {}
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package auth.v1;
|
|
4
|
+
|
|
5
|
+
// Ported from legacy auth-service (@MessagePattern → @GrpcMethod).
|
|
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.
|
|
11
|
+
service AuthService {
|
|
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);
|
|
20
|
+
rpc CleanupExpiredTotpSetups(Empty) returns (Empty);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
enum TwoFactorType {
|
|
24
|
+
NONE = 0;
|
|
25
|
+
APP = 1;
|
|
26
|
+
EMAIL = 2;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Requests
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
// Login by username OR email (one of the two must be set).
|
|
34
|
+
message LoginRequest {
|
|
35
|
+
string password = 1;
|
|
36
|
+
string credentials = 2; // username OR email — resolved by the service
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
message RegisterRequest {
|
|
40
|
+
string email = 1;
|
|
41
|
+
string username = 2;
|
|
42
|
+
string password = 3;
|
|
43
|
+
string ip = 4; // optional, attached by gateway from req
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// type ∈ { twofa, reset, totp_generate, totp_activate, confirm } (legacy strings)
|
|
47
|
+
message CreateCodeRequest {
|
|
48
|
+
string email = 1;
|
|
49
|
+
string type = 2;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// type ∈ { twofa, twofa_deactivate, reset, totp, totp_deactivate, backup, confirm }
|
|
53
|
+
// new_password is only used by the 'reset' flow.
|
|
54
|
+
message VerifyCodeRequest {
|
|
55
|
+
string email = 1;
|
|
56
|
+
string code = 2;
|
|
57
|
+
string type = 3;
|
|
58
|
+
string new_password = 4; // optional
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
message CheckTokenRequest {
|
|
62
|
+
string token = 1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
message RefreshTokenRequest {
|
|
66
|
+
string refresh_token = 1;
|
|
67
|
+
string user_agent = 2; // optional
|
|
68
|
+
string ip = 3; // optional
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
message Get2faStatusRequest {
|
|
72
|
+
string username = 1;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
message GetProfileRequest {
|
|
76
|
+
string user_id = 1;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// Responses
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
|
|
83
|
+
message AuthUser {
|
|
84
|
+
string id = 1;
|
|
85
|
+
string username = 2;
|
|
86
|
+
string email = 3;
|
|
87
|
+
string avatar_url = 4;
|
|
88
|
+
string banner_url = 5;
|
|
89
|
+
repeated string roles = 6;
|
|
90
|
+
string role = 7; // primary role (roles[0])
|
|
91
|
+
bool is_verified = 8;
|
|
92
|
+
TwoFactorType two_factor_type = 9;
|
|
93
|
+
bool two_factor_enabled = 10;
|
|
94
|
+
string balance = 11; // Decimal as string (D7)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Unified result for login/register/createCode/verifyCode/refresh. Which fields
|
|
98
|
+
// are populated depends on the flow:
|
|
99
|
+
// - fully authenticated → access_token + refresh_token + expires_in + user
|
|
100
|
+
// - 2FA required / pending confirm → message + requires_2fa + two_factor_type + user (no tokens)
|
|
101
|
+
// - totp_generate → secret + otpauth + qr (+ user)
|
|
102
|
+
// - totp_activate → backup_codes (+ tokens/user)
|
|
103
|
+
message AuthResult {
|
|
104
|
+
string access_token = 1;
|
|
105
|
+
string refresh_token = 2;
|
|
106
|
+
int32 expires_in = 3;
|
|
107
|
+
AuthUser user = 4;
|
|
108
|
+
|
|
109
|
+
string message = 5;
|
|
110
|
+
bool requires_2fa = 6;
|
|
111
|
+
TwoFactorType two_factor_type = 7;
|
|
112
|
+
|
|
113
|
+
// TOTP setup extras
|
|
114
|
+
string secret = 8;
|
|
115
|
+
string otpauth = 9;
|
|
116
|
+
string qr = 10; // data URL (PNG)
|
|
117
|
+
repeated string backup_codes = 11;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
message TwoFactorStatusResponse {
|
|
121
|
+
TwoFactorType two_factor_type = 1;
|
|
122
|
+
bool has_2fa = 2;
|
|
123
|
+
bool is_verified = 3;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
message Empty {}
|