Skip to content

Commit 8fdcc38

Browse files
Merge pull request #10 from PretendoNetwork/feat/admin-grpc
Add gRPC methods for admin panel
2 parents f275c9f + 29af08f commit 8fdcc38

44 files changed

Lines changed: 913 additions & 10 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

buf.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ lint:
55
use:
66
- STANDARD
77
ignore:
8-
# We ignore all the old files as these should remain unchanged
8+
# * We ignore all the old files as these should remain unchanged
99
- protobufs/account/account_service.proto
1010
- protobufs/account/exchange_token_for_user_data.proto
1111
- protobufs/account/get_nex_data_rpc.proto
@@ -49,4 +49,7 @@ lint:
4949
- protobufs/miiverse/smm_request_post_id_rpc.proto
5050
breaking:
5151
use:
52-
- FILE
52+
- FILE
53+
except:
54+
# TODO - Temporary for https://github.com/PretendoNetwork/grpc/pull/10, remove later
55+
- FILE_NO_DELETE

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pretendonetwork/grpc",
3-
"version": "2.3.5",
3+
"version": "2.4.0",
44
"license": "AGPL-3.0-only",
55
"repository": {
66
"type": "git",

protobufs/account/v2/account_service.proto

Lines changed: 158 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,168 @@ syntax = "proto3";
33
package account.v2;
44

55
import "account/v2/delete_account_rpc.proto";
6-
import "account/v2/exchange_token_for_user_data.proto";
6+
import "account/v2/exchange_token_for_user_data_rpc.proto";
7+
import "account/v2/exchange_oauth_token_for_user_data_rpc.proto";
8+
import "account/v2/exchange_nex_token_for_user_data_rpc.proto";
9+
import "account/v2/exchange_independent_service_token_for_user_data_rpc.proto";
10+
import "account/v2/exchange_password_reset_token_for_user_data_rpc.proto";
11+
import "account/v2/validate_independent_service_token_rpc.proto";
712
import "account/v2/get_nex_data_rpc.proto";
813
import "account/v2/get_nex_password_rpc.proto";
914
import "account/v2/get_user_data_rpc.proto";
10-
import "account/v2/update_pnid_permissions.proto";
15+
import "account/v2/update_pnid_permissions_rpc.proto";
16+
import "account/v2/list_devices_rpc.proto";
17+
import "account/v2/get_device_rpc.proto";
18+
import "account/v2/update_device_rpc.proto";
19+
import "account/v2/list_nex_accounts_rpc.proto";
20+
import "account/v2/get_nex_account_rpc.proto";
21+
import "account/v2/update_nex_account_rpc.proto";
22+
import "account/v2/list_servers_rpc.proto";
23+
import "account/v2/create_server_rpc.proto";
24+
import "account/v2/get_server_rpc.proto";
25+
import "account/v2/update_server_rpc.proto";
26+
import "account/v2/delete_server_rpc.proto";
27+
import "account/v2/list_pnids_rpc.proto";
28+
import "account/v2/get_pnid_rpc.proto"; // TODO - Replace get_user_data_rpc with this?
29+
import "account/v2/update_pnid_rpc.proto"; // TODO - Replace update_pnid_permissions_rpc with this?
30+
import "account/v2/delete_pnid_rpc.proto";
31+
import "account/v2/list_audit_logs_rpc.proto";
32+
import "account/v2/list_audit_log_comments_rpc.proto";
33+
import "account/v2/create_audit_log_comment_rpc.proto";
1134

35+
import "account/v2/list_bans_rpc.proto";
36+
import "account/v2/issue_ban_rpc.proto";
37+
import "account/v2/get_ban_rpc.proto";
38+
import "account/v2/update_ban_rpc.proto";
39+
import "account/v2/pardon_ban_rpc.proto";
40+
import "account/v2/list_ban_comments_rpc.proto";
41+
import "account/v2/create_ban_comment_rpc.proto";
42+
43+
// AccountService provides access to account server data.
44+
//
45+
// INTERNAL API: This service is intended for internal backend use by trusted servers only,
46+
// such as the admin panel, game servers, etc. It is not designed for public use.
1247
service AccountService {
13-
rpc GetUserData(GetUserDataRequest) returns (GetUserDataResponse) {}
48+
// GetUserData retrieves details for a specific PNID account.
49+
// Deprecated: Use GetPNID instead.
50+
rpc GetUserData(GetUserDataRequest) returns (GetUserDataResponse) {
51+
option deprecated = true;
52+
}
53+
54+
// GetNEXPassword retrieves a NEX accounts password. Used only by game servers for Kerberos.
1455
rpc GetNEXPassword(GetNEXPasswordRequest) returns (GetNEXPasswordResponse) {}
15-
rpc GetNEXData(GetNEXDataRequest) returns (GetNEXDataResponse) {}
16-
rpc UpdatePNIDPermissions(UpdatePNIDPermissionsRequest) returns (UpdatePNIDPermissionsResponse) {}
17-
rpc ExchangeTokenForUserData(ExchangeTokenForUserDataRequest) returns (ExchangeTokenForUserDataResponse) {}
18-
rpc DeleteAccount(DeleteAccountRequest) returns (DeleteAccountResponse) {}
56+
57+
// GetNEXData retrieves details for a specific NEX account.
58+
// Deprecated: Use GetNEXAccount instead.
59+
rpc GetNEXData(GetNEXDataRequest) returns (GetNEXDataResponse) {
60+
option deprecated = true;
61+
}
62+
63+
// UpdatePNIDPermissions updates the permissions for a PNID account.
64+
// Deprecated: Use UpdatePNID instead.
65+
rpc UpdatePNIDPermissions(UpdatePNIDPermissionsRequest) returns (UpdatePNIDPermissionsResponse) {
66+
option deprecated = true;
67+
}
68+
69+
// ExchangeTokenForUserData exchanges an authentication token for PNID data.
70+
// Deprecated: Use the type-specific methods instead.
71+
rpc ExchangeTokenForUserData(ExchangeTokenForUserDataRequest) returns (ExchangeTokenForUserDataResponse) {
72+
option deprecated = true;
73+
}
74+
75+
// ExchangeOAuthTokenForUserData exchanges an authentication token for PNID data.
76+
rpc ExchangeOAuthTokenForUserData(ExchangeOAuthTokenForUserDataRequest) returns (ExchangeOAuthTokenForUserDataResponse) {}
77+
78+
// ExchangeNEXTokenForUserData exchanges a NEX token for NEX account data.
79+
rpc ExchangeNEXTokenForUserData(ExchangeNEXTokenForUserDataRequest) returns (ExchangeNEXTokenForUserDataResponse) {}
80+
81+
// ExchangeIndependentServiceTokenForUserData exchanges a service token for user data. PNID data is not returned for NASC tokens.
82+
rpc ExchangeIndependentServiceTokenForUserData(ExchangeIndependentServiceTokenForUserDataRequest) returns (ExchangeIndependentServiceTokenForUserDataResponse) {}
83+
84+
// ExchangePasswordResetTokenForUserData exchanges a password reset token for PNID data.
85+
rpc ExchangePasswordResetTokenForUserData(ExchangePasswordResetTokenForUserDataRequest) returns (ExchangePasswordResetTokenForUserDataResponse) {}
86+
87+
// ValidateIndependentServiceToken validates that a service token data is correct, even on expired tokens.
88+
rpc ValidateIndependentServiceToken(ValidateIndependentServiceTokenRequest) returns (ValidateIndependentServiceTokenResponse) {}
89+
90+
// DeleteAccount permanently deletes a PNID account.
91+
// Deprecated: Use DeletePNID instead.
92+
rpc DeleteAccount(DeleteAccountRequest) returns (DeleteAccountResponse) {
93+
option deprecated = true;
94+
}
95+
96+
// ListDevices returns a paginated list of devices.
97+
rpc ListDevices(ListDevicesRequest) returns (ListDevicesResponse) {}
98+
99+
// GetDevice retrieves details for a specific device.
100+
rpc GetDevice(GetDeviceRequest) returns (GetDeviceResponse) {}
101+
102+
// UpdateDevice updates device information.
103+
rpc UpdateDevice(UpdateDeviceRequest) returns (UpdateDeviceResponse) {}
104+
105+
// ListNEXAccounts returns a paginated list of NEX accounts.
106+
rpc ListNEXAccounts(ListNEXAccountsRequest) returns (ListNEXAccountsResponse) {}
107+
108+
// GetNEXAccount retrieves details for a specific NEX account.
109+
rpc GetNEXAccount(GetNEXAccountRequest) returns (GetNEXAccountResponse) {}
110+
111+
// UpdateNEXAccount updates NEX account information.
112+
rpc UpdateNEXAccount(UpdateNEXAccountRequest) returns (UpdateNEXAccountResponse) {}
113+
114+
// ListServers returns a paginated list of server configurations.
115+
rpc ListServers(ListServersRequest) returns (ListServersResponse) {}
116+
117+
// CreateServer creates a new server configuration.
118+
rpc CreateServer(CreateServerRequest) returns (CreateServerResponse) {}
119+
120+
// GetServer retrieves the configuration for a specific server.
121+
rpc GetServer(GetServerRequest) returns (GetServerResponse) {}
122+
123+
// UpdateServer updates a server configuration.
124+
rpc UpdateServer(UpdateServerRequest) returns (UpdateServerResponse) {}
125+
126+
// DeleteServer removes a server configuration.
127+
rpc DeleteServer(DeleteServerRequest) returns (DeleteServerResponse) {}
128+
129+
// ListPNIDs returns a paginated list of PNID accounts.
130+
rpc ListPNIDs(ListPNIDsRequest) returns (ListPNIDsResponse) {}
131+
132+
// GetPNID retrieves details for a specific PNID account.
133+
rpc GetPNID(GetPNIDRequest) returns (GetPNIDResponse) {}
134+
135+
// UpdatePNID updates PNID account information.
136+
rpc UpdatePNID(UpdatePNIDRequest) returns (UpdatePNIDResponse) {}
137+
138+
// DeletePNID permanently deletes a PNID account.
139+
rpc DeletePNID(DeletePNIDRequest) returns (DeletePNIDResponse) {}
140+
141+
// ListAuditLogs returns a paginated list of audit log entries.
142+
rpc ListAuditLogs(ListAuditLogsRequest) returns (ListAuditLogsResponse) {}
143+
144+
// ListAuditLogComments returns comments for a specific audit log entry.
145+
rpc ListAuditLogComments(ListAuditLogCommentsRequest) returns (ListAuditLogCommentsResponse) {}
146+
147+
// CreateAuditLogComment adds a comment to an audit log entry.
148+
rpc CreateAuditLogComment(CreateAuditLogCommentRequest) returns (CreateAuditLogCommentResponse) {}
149+
150+
// ListBans returns a paginated list of bans.
151+
rpc ListBans(ListBansRequest) returns (ListBansResponse) {}
152+
153+
// IssueBan creates a new ban. Can target both users and devices.
154+
rpc IssueBan(IssueBanRequest) returns (IssueBanResponse) {}
155+
156+
// GetBan retrieves details for a specific ban.
157+
rpc GetBan(GetBanRequest) returns (GetBanResponse) {}
158+
159+
// UpdateBan modifies an existing ban.
160+
rpc UpdateBan(UpdateBanRequest) returns (UpdateBanResponse) {}
161+
162+
// PardonBan lifts a ban.
163+
rpc PardonBan(PardonBanRequest) returns (PardonBanResponse) {}
164+
165+
// ListBanComments returns comments for a specific ban.
166+
rpc ListBanComments(ListBanCommentsRequest) returns (ListBanCommentsResponse) {}
167+
168+
// CreateBanComment adds a comment to a ban entry.
169+
rpc CreateBanComment(CreateBanCommentRequest) returns (CreateBanCommentResponse) {}
19170
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
syntax = "proto3";
2+
3+
package account.v2;
4+
5+
import "account/v2/audit_log_action_type.proto";
6+
7+
message AuditLog {
8+
string id = 1;
9+
AuditLogActionType action_type = 2;
10+
uint32 executed_by_pid = 3;
11+
uint64 created_timestamp = 4;
12+
uint32 comment_count = 5;
13+
string metadata_json = 6;
14+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
syntax = "proto3";
2+
3+
package account.v2;
4+
5+
enum AuditLogActionType {
6+
AUDIT_LOG_ACTION_TYPE_UNSPECIFIED = 0;
7+
8+
AUDIT_LOG_ACTION_TYPE_CREATE_SERVER = 1;
9+
AUDIT_LOG_ACTION_TYPE_UPDATE_SERVER = 2;
10+
AUDIT_LOG_ACTION_TYPE_DELETE_SERVER = 3;
11+
12+
AUDIT_LOG_ACTION_TYPE_UPDATE_NEX_ACCOUNT = 4;
13+
AUDIT_LOG_ACTION_TYPE_DELETE_NEX_ACCOUNT = 5;
14+
AUDIT_LOG_ACTION_TYPE_BAN_NEX_ACCOUNT_PERMANENTLY = 6;
15+
AUDIT_LOG_ACTION_TYPE_BAN_NEX_ACCOUNT_TEMPORARILY = 7;
16+
17+
AUDIT_LOG_ACTION_TYPE_UPDATE_NETWORK_ACCOUNT = 8;
18+
AUDIT_LOG_ACTION_TYPE_DELETE_NETWORK_ACCOUNT = 9;
19+
AUDIT_LOG_ACTION_TYPE_BAN_NETWORK_ACCOUNT_PERMANENTLY = 10;
20+
AUDIT_LOG_ACTION_TYPE_BAN_NETWORK_ACCOUNT_TEMPORARILY = 11;
21+
22+
AUDIT_LOG_ACTION_TYPE_UPDATE_DEVICE = 12;
23+
AUDIT_LOG_ACTION_TYPE_DELETE_DEVICE = 13;
24+
AUDIT_LOG_ACTION_TYPE_BAN_DEVICE_PERMANENTLY = 14;
25+
AUDIT_LOG_ACTION_TYPE_BAN_DEVICE_TEMPORARILY = 15;
26+
27+
AUDIT_LOG_ACTION_TYPE_PARDON_BAN = 16;
28+
AUDIT_LOG_ACTION_TYPE_UPDATE_BAN = 17;
29+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
syntax = "proto3";
2+
3+
package account.v2;
4+
5+
import "google/protobuf/timestamp.proto";
6+
7+
// TODO - Move this to own file
8+
enum BanTargetType {
9+
BAN_TARGET_TYPE_UNSPECIFIED = 0;
10+
BAN_TARGET_TYPE_NEX_ACCOUNT = 1;
11+
BAN_TARGET_TYPE_NETWORK_ACCOUNT = 2;
12+
BAN_TARGET_TYPE_DEVICE = 3;
13+
}
14+
15+
// TODO - Move this to own file
16+
// * Relates to the official ban error codes:
17+
// * 102-2800 BANNED
18+
// * 102-2801 BANNED_ACCOUNT
19+
// * 102-2802 BANNED_ACCOUNT_ALL
20+
// * 102-2803 BANNED_ACCOUNT_IN_APPLICATION
21+
// * 102-2804 BANNED_ACCOUNT_IN_NEX_SERVICE
22+
// * 102-2805 BANNED_ACCOUNT_IN_INDEPENDENT_SERVICE
23+
// * 102-2811 BANNED_DEVICE
24+
// * 102-2812 BANNED_DEVICE_ALL
25+
// * 102-2813 BANNED_DEVICE_IN_APPLICATION
26+
// * 102-2814 BANNED_DEVICE_IN_NEX_SERVICE
27+
// * 102-2815 BANNED_DEVICE_IN_INDEPENDENT_SERVICE
28+
// * 102-2821 BANNED_ACCOUNT_TEMPORARILY
29+
// * 102-2822 BANNED_ACCOUNT_ALL_TEMPORARILY
30+
// * 102-2823 BANNED_ACCOUNT_IN_APPLICATION_TEMPORARILY
31+
// * 102-2824 BANNED_ACCOUNT_IN_NEX_SERVICE_TEMPORARILY
32+
// * 102-2825 BANNED_ACCOUNT_IN_INDEPENDENT_SERVICE_TEMPORARILY
33+
// * 102-2831 BANNED_DEVICE_TEMPORARILY
34+
// * 102-2832 BANNED_DEVICE_ALL_TEMPORARILY
35+
// * 102-2833 BANNED_DEVICE_IN_APPLICATION_TEMPORARILY
36+
// * 102-2834 BANNED_DEVICE_IN_NEX_SERVICE_TEMPORARILY
37+
// * 102-2835 BANNED_DEVICE_IN_INDEPENDENT_SERVICE_TEMPORARILY
38+
enum BanScopeType {
39+
BAN_SCOPE_TYPE_UNSPECIFIED = 0;
40+
BAN_SCOPE_TYPE_ALL = 1;
41+
BAN_SCOPE_TYPE_APPLICATION = 2;
42+
BAN_SCOPE_TYPE_NEX_SERVICE = 3;
43+
BAN_SCOPE_TYPE_INDEPENDENT_SERVICE = 4;
44+
}
45+
46+
message BanDetails {
47+
BanTargetType target_type = 1;
48+
string target = 2;
49+
string issuer = 3; // * Set as a string to not limit this to PIDs
50+
google.protobuf.Timestamp start_date = 4;
51+
google.protobuf.Timestamp end_date = 5;
52+
BanScopeType scope_type = 6;
53+
string scope_target = 7;
54+
string reason = 8;
55+
}
56+
57+
// TODO - Move this to own file
58+
message Ban {
59+
string id = 1;
60+
BanDetails details = 2;
61+
google.protobuf.Timestamp issued_date = 3;
62+
google.protobuf.Timestamp updated_date = 4;
63+
optional google.protobuf.Timestamp pardoned_date = 5;
64+
optional string pardoned_reason = 6;
65+
}

protobufs/account/v2/comment.proto

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
syntax = "proto3";
2+
3+
package account.v2;
4+
5+
import "google/protobuf/timestamp.proto";
6+
7+
message Comment {
8+
string parent = 1;
9+
string id = 2;
10+
uint32 pid = 3;
11+
google.protobuf.Timestamp created_timestamp = 4;
12+
string content = 5;
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
syntax = "proto3";
2+
3+
package account.v2;
4+
5+
import "account/v2/comment.proto";
6+
7+
message CreateAuditLogCommentRequest {
8+
string id = 1;
9+
string content = 2;
10+
}
11+
12+
message CreateAuditLogCommentResponse {
13+
Comment item = 1;
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
syntax = "proto3";
2+
3+
package account.v2;
4+
5+
import "account/v2/comment.proto";
6+
7+
message CreateBanCommentRequest {
8+
string id = 1;
9+
string content = 2;
10+
}
11+
12+
message CreateBanCommentResponse {
13+
Comment item = 1;
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
syntax = "proto3";
2+
3+
package account.v2;
4+
5+
import "account/v2/server.proto";
6+
7+
message CreateServerRequest {
8+
string ip = 2;
9+
uint32 port = 3;
10+
string service_name = 4;
11+
string service_type = 5;
12+
string game_server_id = 6;
13+
repeated string title_ids = 7;
14+
string access_mode = 8;
15+
bool maintenance_mode = 9;
16+
uint32 device = 10;
17+
string aes_key = 11;
18+
optional string client_id = 12;
19+
}
20+
21+
message CreateServerResponse {
22+
Server item = 1;
23+
}

0 commit comments

Comments
 (0)