@aepstore-dev/contracts 1.59.0 → 1.61.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/proto/auth.proto CHANGED
@@ -1,198 +1,198 @@
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
- // Logout — kill refresh tokens. LogoutCurrent kills only the one whose
23
- // HMAC matches; LogoutAll wipes every row for the user.
24
- rpc LogoutCurrent(LogoutCurrentRequest) returns (LogoutResponse);
25
- rpc LogoutAll(LogoutAllRequest) returns (LogoutResponse);
26
-
27
- // Self-service restore. Verifies credentials + password against a
28
- // soft-deleted user, clears deletedAt/scheduledForHardDelete, and issues
29
- // fresh tokens — the one auth path that DOES read deletedAt accounts.
30
- rpc RestoreLogin(RestoreLoginRequest) returns (AuthResult);
31
-
32
- // Login history. Read-only audit feed for the settings page; rows come
33
- // from LoginEvent. Internal alternative: tasks-service GC.
34
- rpc ListLoginHistory(ListLoginHistoryRequest) returns (ListLoginHistoryResponse);
35
- }
36
-
37
- enum TwoFactorType {
38
- NONE = 0;
39
- APP = 1;
40
- EMAIL = 2;
41
- }
42
-
43
- // ---------------------------------------------------------------------------
44
- // Requests
45
- // ---------------------------------------------------------------------------
46
-
47
- // Login by username OR email (one of the two must be set).
48
- message LoginRequest {
49
- string password = 1;
50
- string credentials = 2; // username OR email — resolved by the service
51
- // Gateway-supplied audit context. LoginEvent rows for LOGIN /
52
- // PASSWORD_FAIL get the same ip/user-agent that REFRESH and RESTORE
53
- // already carry; the gRPC layer has no transport-level access to
54
- // either, so the gateway extracts them from the HTTP request.
55
- string user_agent = 3;
56
- string ip = 4;
57
- }
58
-
59
- message RegisterRequest {
60
- string email = 1;
61
- string username = 2;
62
- string password = 3;
63
- string ip = 4; // optional, attached by gateway from req
64
- }
65
-
66
- // type ∈ { twofa, reset, totp_generate, totp_activate, confirm } (legacy strings)
67
- message CreateCodeRequest {
68
- string email = 1;
69
- string type = 2;
70
- }
71
-
72
- // type ∈ { twofa, twofa_deactivate, reset, totp, totp_deactivate, backup, confirm }
73
- // new_password is only used by the 'reset' flow.
74
- message VerifyCodeRequest {
75
- string email = 1;
76
- string code = 2;
77
- string type = 3;
78
- string new_password = 4; // optional
79
- }
80
-
81
- message CheckTokenRequest {
82
- string token = 1;
83
- }
84
-
85
- message RefreshTokenRequest {
86
- string refresh_token = 1;
87
- string user_agent = 2; // optional
88
- string ip = 3; // optional
89
- }
90
-
91
- message Get2faStatusRequest {
92
- string username = 1;
93
- }
94
-
95
- message GetProfileRequest {
96
- string user_id = 1;
97
- }
98
-
99
- // ---------------------------------------------------------------------------
100
- // Responses
101
- // ---------------------------------------------------------------------------
102
-
103
- message AuthUser {
104
- string id = 1;
105
- string username = 2;
106
- string email = 3;
107
- string avatar_url = 4;
108
- string banner_url = 5;
109
- repeated string roles = 6;
110
- // Reserved: 7=role, 8=is_verified, 9=two_factor_type, 10=two_factor_enabled,
111
- // 11=balance. Dropped in contracts 1.51.0 — clients read 2FA flags from
112
- // AuthResult / /account/settings, balance from /payments/wallet.
113
- reserved 7, 8, 9, 10, 11;
114
- reserved "role", "is_verified", "two_factor_type", "two_factor_enabled", "balance";
115
- }
116
-
117
- // Unified result for login/register/createCode/verifyCode/refresh. Which fields
118
- // are populated depends on the flow:
119
- // - fully authenticated → access_token + refresh_token + expires_in + user
120
- // - 2FA required / pending confirm → message + two_factor_required + two_factor_type + user (no tokens)
121
- // - totp_generate → secret + otpauth + qr (+ user)
122
- // - totp_activate → backup_codes (+ tokens/user)
123
- message AuthResult {
124
- string access_token = 1;
125
- string refresh_token = 2;
126
- int32 expires_in = 3;
127
- AuthUser user = 4;
128
-
129
- string message = 5;
130
- // Renamed from `requires_2fa` in 1.52.0: the digit-after-underscore broke
131
- // the grpc proto-loader's camelCase pass (`_2` isn't `_<letter>`), so the
132
- // wire key stayed snake_case and never matched the camelCase handler output
133
- // → always serialised false. `two_factor_required` camelCases cleanly to
134
- // `twoFactorRequired` on every layer. Field number 6 is unchanged (wire-
135
- // compatible).
136
- bool two_factor_required = 6;
137
- TwoFactorType two_factor_type = 7;
138
-
139
- // TOTP setup extras
140
- string secret = 8;
141
- string otpauth = 9;
142
- string qr = 10; // data URL (PNG)
143
- repeated string backup_codes = 11;
144
- }
145
-
146
- message TwoFactorStatusResponse {
147
- TwoFactorType two_factor_type = 1;
148
- bool has_2fa = 2;
149
- bool is_verified = 3;
150
- }
151
-
152
- message Empty {}
153
-
154
- message LogoutCurrentRequest {
155
- string refresh_token = 1;
156
- }
157
-
158
- message LogoutAllRequest {
159
- string user_id = 1;
160
- // Current session's refresh token — excluded from the wipe so "log out
161
- // everywhere" keeps THIS device signed in. Empty = revoke every session.
162
- string refresh_token = 2;
163
- }
164
-
165
- message LogoutResponse {
166
- bool ok = 1;
167
- int32 removed = 2; // number of refresh-token rows deleted
168
- }
169
-
170
- message RestoreLoginRequest {
171
- string credentials = 1; // email or username
172
- string password = 2;
173
- string user_agent = 3;
174
- string ip = 4;
175
- }
176
-
177
- message ListLoginHistoryRequest {
178
- string user_id = 1;
179
- int32 page = 2;
180
- int32 limit = 3;
181
- }
182
-
183
- message LoginEventRow {
184
- string id = 1;
185
- string type = 2; // LOGIN | LOGOUT | REFRESH | TWO_FA_FAIL | PASSWORD_FAIL | BLOCKED | RESTORE
186
- bool success = 3;
187
- string reason = 4;
188
- string ip = 5;
189
- string user_agent = 6;
190
- string created_at = 7;
191
- }
192
-
193
- message ListLoginHistoryResponse {
194
- repeated LoginEventRow items = 1;
195
- int32 total = 2;
196
- int32 page = 3;
197
- int32 limit = 4;
198
- }
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
+ // Logout — kill refresh tokens. LogoutCurrent kills only the one whose
23
+ // HMAC matches; LogoutAll wipes every row for the user.
24
+ rpc LogoutCurrent(LogoutCurrentRequest) returns (LogoutResponse);
25
+ rpc LogoutAll(LogoutAllRequest) returns (LogoutResponse);
26
+
27
+ // Self-service restore. Verifies credentials + password against a
28
+ // soft-deleted user, clears deletedAt/scheduledForHardDelete, and issues
29
+ // fresh tokens — the one auth path that DOES read deletedAt accounts.
30
+ rpc RestoreLogin(RestoreLoginRequest) returns (AuthResult);
31
+
32
+ // Login history. Read-only audit feed for the settings page; rows come
33
+ // from LoginEvent. Internal alternative: tasks-service GC.
34
+ rpc ListLoginHistory(ListLoginHistoryRequest) returns (ListLoginHistoryResponse);
35
+ }
36
+
37
+ enum TwoFactorType {
38
+ NONE = 0;
39
+ APP = 1;
40
+ EMAIL = 2;
41
+ }
42
+
43
+ // ---------------------------------------------------------------------------
44
+ // Requests
45
+ // ---------------------------------------------------------------------------
46
+
47
+ // Login by username OR email (one of the two must be set).
48
+ message LoginRequest {
49
+ string password = 1;
50
+ string credentials = 2; // username OR email — resolved by the service
51
+ // Gateway-supplied audit context. LoginEvent rows for LOGIN /
52
+ // PASSWORD_FAIL get the same ip/user-agent that REFRESH and RESTORE
53
+ // already carry; the gRPC layer has no transport-level access to
54
+ // either, so the gateway extracts them from the HTTP request.
55
+ string user_agent = 3;
56
+ string ip = 4;
57
+ }
58
+
59
+ message RegisterRequest {
60
+ string email = 1;
61
+ string username = 2;
62
+ string password = 3;
63
+ string ip = 4; // optional, attached by gateway from req
64
+ }
65
+
66
+ // type ∈ { twofa, reset, totp_generate, totp_activate, confirm } (legacy strings)
67
+ message CreateCodeRequest {
68
+ string email = 1;
69
+ string type = 2;
70
+ }
71
+
72
+ // type ∈ { twofa, twofa_deactivate, reset, totp, totp_deactivate, backup, confirm }
73
+ // new_password is only used by the 'reset' flow.
74
+ message VerifyCodeRequest {
75
+ string email = 1;
76
+ string code = 2;
77
+ string type = 3;
78
+ string new_password = 4; // optional
79
+ }
80
+
81
+ message CheckTokenRequest {
82
+ string token = 1;
83
+ }
84
+
85
+ message RefreshTokenRequest {
86
+ string refresh_token = 1;
87
+ string user_agent = 2; // optional
88
+ string ip = 3; // optional
89
+ }
90
+
91
+ message Get2faStatusRequest {
92
+ string username = 1;
93
+ }
94
+
95
+ message GetProfileRequest {
96
+ string user_id = 1;
97
+ }
98
+
99
+ // ---------------------------------------------------------------------------
100
+ // Responses
101
+ // ---------------------------------------------------------------------------
102
+
103
+ message AuthUser {
104
+ string id = 1;
105
+ string username = 2;
106
+ string email = 3;
107
+ string avatar_url = 4;
108
+ string banner_url = 5;
109
+ repeated string roles = 6;
110
+ // Reserved: 7=role, 8=is_verified, 9=two_factor_type, 10=two_factor_enabled,
111
+ // 11=balance. Dropped in contracts 1.51.0 — clients read 2FA flags from
112
+ // AuthResult / /account/settings, balance from /payments/wallet.
113
+ reserved 7, 8, 9, 10, 11;
114
+ reserved "role", "is_verified", "two_factor_type", "two_factor_enabled", "balance";
115
+ }
116
+
117
+ // Unified result for login/register/createCode/verifyCode/refresh. Which fields
118
+ // are populated depends on the flow:
119
+ // - fully authenticated → access_token + refresh_token + expires_in + user
120
+ // - 2FA required / pending confirm → message + two_factor_required + two_factor_type + user (no tokens)
121
+ // - totp_generate → secret + otpauth + qr (+ user)
122
+ // - totp_activate → backup_codes (+ tokens/user)
123
+ message AuthResult {
124
+ string access_token = 1;
125
+ string refresh_token = 2;
126
+ int32 expires_in = 3;
127
+ AuthUser user = 4;
128
+
129
+ string message = 5;
130
+ // Renamed from `requires_2fa` in 1.52.0: the digit-after-underscore broke
131
+ // the grpc proto-loader's camelCase pass (`_2` isn't `_<letter>`), so the
132
+ // wire key stayed snake_case and never matched the camelCase handler output
133
+ // → always serialised false. `two_factor_required` camelCases cleanly to
134
+ // `twoFactorRequired` on every layer. Field number 6 is unchanged (wire-
135
+ // compatible).
136
+ bool two_factor_required = 6;
137
+ TwoFactorType two_factor_type = 7;
138
+
139
+ // TOTP setup extras
140
+ string secret = 8;
141
+ string otpauth = 9;
142
+ string qr = 10; // data URL (PNG)
143
+ repeated string backup_codes = 11;
144
+ }
145
+
146
+ message TwoFactorStatusResponse {
147
+ TwoFactorType two_factor_type = 1;
148
+ bool has_2fa = 2;
149
+ bool is_verified = 3;
150
+ }
151
+
152
+ message Empty {}
153
+
154
+ message LogoutCurrentRequest {
155
+ string refresh_token = 1;
156
+ }
157
+
158
+ message LogoutAllRequest {
159
+ string user_id = 1;
160
+ // Current session's refresh token — excluded from the wipe so "log out
161
+ // everywhere" keeps THIS device signed in. Empty = revoke every session.
162
+ string refresh_token = 2;
163
+ }
164
+
165
+ message LogoutResponse {
166
+ bool ok = 1;
167
+ int32 removed = 2; // number of refresh-token rows deleted
168
+ }
169
+
170
+ message RestoreLoginRequest {
171
+ string credentials = 1; // email or username
172
+ string password = 2;
173
+ string user_agent = 3;
174
+ string ip = 4;
175
+ }
176
+
177
+ message ListLoginHistoryRequest {
178
+ string user_id = 1;
179
+ int32 page = 2;
180
+ int32 limit = 3;
181
+ }
182
+
183
+ message LoginEventRow {
184
+ string id = 1;
185
+ string type = 2; // LOGIN | LOGOUT | REFRESH | TWO_FA_FAIL | PASSWORD_FAIL | BLOCKED | RESTORE
186
+ bool success = 3;
187
+ string reason = 4;
188
+ string ip = 5;
189
+ string user_agent = 6;
190
+ string created_at = 7;
191
+ }
192
+
193
+ message ListLoginHistoryResponse {
194
+ repeated LoginEventRow items = 1;
195
+ int32 total = 2;
196
+ int32 page = 3;
197
+ int32 limit = 4;
198
+ }
package/proto/mail.proto CHANGED
@@ -1,54 +1,54 @@
1
- syntax = "proto3";
2
-
3
- package mail.v1;
4
-
5
- // Legacy mail-service used @EventPattern (fire-and-forget). In the new gRPC
6
- // stack each becomes a unary RPC that returns an Ack. Callers ignore the
7
- // response if they don't care about delivery.
8
- service MailService {
9
- rpc SendReg(SendRegRequest) returns (MailAck);
10
- rpc Send2fa(Send2faRequest) returns (MailAck);
11
- rpc SendPasswordReset(SendPasswordResetRequest) returns (MailAck);
12
- rpc SendRegistrationConfirm(SendRegistrationConfirmRequest) returns (MailAck);
13
-
14
- // GDPR data-export delivery — tasks-service fires after the JSON dump
15
- // lands in S3; mail-service sends the signed URL with a sensible TTL note.
16
- rpc SendDataExportReady(SendDataExportReadyRequest) returns (MailAck);
17
- }
18
-
19
- message MailAck {
20
- bool queued = 1;
21
- }
22
-
23
- message SendRegRequest {
24
- string user_id = 1;
25
- string email = 2;
26
- string username = 3;
27
- string full_name = 4;
28
- }
29
-
30
- message Send2faRequest {
31
- string email = 1;
32
- string code = 2;
33
- string username = 3;
34
- }
35
-
36
- message SendPasswordResetRequest {
37
- string email = 1;
38
- string code = 2;
39
- string username = 3;
40
- }
41
-
42
- message SendRegistrationConfirmRequest {
43
- string email = 1;
44
- string code = 2;
45
- string username = 3;
46
- }
47
-
48
- message SendDataExportReadyRequest {
49
- string email = 1;
50
- string username = 2;
51
- string file_url = 3; // signed S3 URL
52
- int32 url_ttl_hours = 4; // for the message body
53
- int32 file_size = 5;
54
- }
1
+ syntax = "proto3";
2
+
3
+ package mail.v1;
4
+
5
+ // Legacy mail-service used @EventPattern (fire-and-forget). In the new gRPC
6
+ // stack each becomes a unary RPC that returns an Ack. Callers ignore the
7
+ // response if they don't care about delivery.
8
+ service MailService {
9
+ rpc SendReg(SendRegRequest) returns (MailAck);
10
+ rpc Send2fa(Send2faRequest) returns (MailAck);
11
+ rpc SendPasswordReset(SendPasswordResetRequest) returns (MailAck);
12
+ rpc SendRegistrationConfirm(SendRegistrationConfirmRequest) returns (MailAck);
13
+
14
+ // GDPR data-export delivery — tasks-service fires after the JSON dump
15
+ // lands in S3; mail-service sends the signed URL with a sensible TTL note.
16
+ rpc SendDataExportReady(SendDataExportReadyRequest) returns (MailAck);
17
+ }
18
+
19
+ message MailAck {
20
+ bool queued = 1;
21
+ }
22
+
23
+ message SendRegRequest {
24
+ string user_id = 1;
25
+ string email = 2;
26
+ string username = 3;
27
+ string full_name = 4;
28
+ }
29
+
30
+ message Send2faRequest {
31
+ string email = 1;
32
+ string code = 2;
33
+ string username = 3;
34
+ }
35
+
36
+ message SendPasswordResetRequest {
37
+ string email = 1;
38
+ string code = 2;
39
+ string username = 3;
40
+ }
41
+
42
+ message SendRegistrationConfirmRequest {
43
+ string email = 1;
44
+ string code = 2;
45
+ string username = 3;
46
+ }
47
+
48
+ message SendDataExportReadyRequest {
49
+ string email = 1;
50
+ string username = 2;
51
+ string file_url = 3; // signed S3 URL
52
+ int32 url_ttl_hours = 4; // for the message body
53
+ int32 file_size = 5;
54
+ }