@platfformx/proto-contracts 1.0.3 → 1.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.
@@ -10,36 +10,45 @@ import { Observable } from "rxjs";
10
10
 
11
11
  export const protobufPackage = "auth_service.v1";
12
12
 
13
+ /** Shared */
14
+ export enum OAuthProvider {
15
+ OAUTH_PROVIDER_UNSPECIFIED = 0,
16
+ OAUTH_PROVIDER_GOOGLE = 1,
17
+ OAUTH_PROVIDER_GITHUB = 2,
18
+ OAUTH_PROVIDER_TELEGRAM = 3,
19
+ UNRECOGNIZED = -1,
20
+ }
21
+
22
+ /** Create account */
13
23
  export interface CreateAccountRequest {
14
- credentials?: UserCredentials | undefined;
15
- oauthToken?: string | undefined;
24
+ credentials: UserCredentials | undefined;
16
25
  }
17
26
 
18
27
  export interface CreateAccountResponse {
19
- userId: string;
20
- accessToken: string;
21
- refreshToken: string;
28
+ result: AuthResult | undefined;
22
29
  }
23
30
 
31
+ /** Authenticate credentials */
24
32
  export interface AuthenticationRequest {
25
- credentials?: UserCredentials | undefined;
26
- oauthToken?: string | undefined;
33
+ credentials: UserCredentials | undefined;
27
34
  }
28
35
 
29
36
  export interface AuthenticationResponse {
30
- accessToken: string;
31
- refreshToken: string;
32
- user: UserInfo | undefined;
37
+ result: AuthResult | undefined;
33
38
  }
34
39
 
35
- export interface UserCredentials {
36
- email: string;
37
- phone: string;
38
- username: string;
39
- password: string;
40
+ /** AuthenticateWithOAuth */
41
+ export interface OAuthSessionRequest {
42
+ provider: OAuthProvider;
43
+ token: string;
44
+ }
45
+
46
+ export interface OAuthSessionResponse {
47
+ result: AuthResult | undefined;
48
+ isNewUser: boolean;
40
49
  }
41
50
 
42
- /** Токены */
51
+ /** Tokens */
43
52
  export interface TokenRefreshRequest {
44
53
  refreshToken: string;
45
54
  }
@@ -49,14 +58,27 @@ export interface TokenRefreshResponse {
49
58
  refreshToken: string;
50
59
  }
51
60
 
52
- export interface UserInfo {
53
- userId: string;
61
+ export interface UserCredentials {
62
+ email?: string | undefined;
63
+ phone?: string | undefined;
64
+ username?: string | undefined;
65
+ password: string;
66
+ }
67
+
68
+ export interface UserProfile {
54
69
  email?: string | undefined;
55
70
  phone?: string | undefined;
56
71
  username?: string | undefined;
57
72
  displayName?: string | undefined;
58
73
  }
59
74
 
75
+ export interface AuthResult {
76
+ userId: string;
77
+ accessToken: string;
78
+ refreshToken: string;
79
+ user: UserProfile | undefined;
80
+ }
81
+
60
82
  export const AUTH_SERVICE_V1_PACKAGE_NAME = "auth_service.v1";
61
83
 
62
84
  export interface AuthServiceClient {
@@ -64,6 +86,8 @@ export interface AuthServiceClient {
64
86
 
65
87
  authenticate(request: AuthenticationRequest): Observable<AuthenticationResponse>;
66
88
 
89
+ authenticateWithOAuth(request: OAuthSessionRequest): Observable<OAuthSessionResponse>;
90
+
67
91
  refreshTokens(request: TokenRefreshRequest): Observable<TokenRefreshResponse>;
68
92
  }
69
93
 
@@ -76,6 +100,10 @@ export interface AuthServiceController {
76
100
  request: AuthenticationRequest,
77
101
  ): Promise<AuthenticationResponse> | Observable<AuthenticationResponse> | AuthenticationResponse;
78
102
 
103
+ authenticateWithOAuth(
104
+ request: OAuthSessionRequest,
105
+ ): Promise<OAuthSessionResponse> | Observable<OAuthSessionResponse> | OAuthSessionResponse;
106
+
79
107
  refreshTokens(
80
108
  request: TokenRefreshRequest,
81
109
  ): Promise<TokenRefreshResponse> | Observable<TokenRefreshResponse> | TokenRefreshResponse;
@@ -83,7 +111,7 @@ export interface AuthServiceController {
83
111
 
84
112
  export function AuthServiceControllerMethods() {
85
113
  return function (constructor: Function) {
86
- const grpcMethods: string[] = ["createAccount", "authenticate", "refreshTokens"];
114
+ const grpcMethods: string[] = ["createAccount", "authenticate", "authenticateWithOAuth", "refreshTokens"];
87
115
  for (const method of grpcMethods) {
88
116
  const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
89
117
  GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platfformx/proto-contracts",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -5,45 +5,38 @@ package auth_service.v1;
5
5
  service AuthService {
6
6
  rpc CreateAccount (CreateAccountRequest) returns (CreateAccountResponse);
7
7
  rpc Authenticate (AuthenticationRequest) returns (AuthenticationResponse);
8
+ rpc AuthenticateWithOAuth (OAuthSessionRequest) returns (OAuthSessionResponse);
8
9
  rpc RefreshTokens (TokenRefreshRequest) returns (TokenRefreshResponse);
9
10
  }
10
11
 
11
-
12
+ // Create account
12
13
  message CreateAccountRequest {
13
- oneof register_method {
14
- UserCredentials credentials = 1;
15
- string oauth_token = 2;
16
- }
14
+ UserCredentials credentials = 1;
17
15
  }
18
16
 
19
17
  message CreateAccountResponse {
20
- string user_id = 1;
21
- string access_token = 2;
22
- string refresh_token = 3;
18
+ AuthResult result = 1;
23
19
  }
24
20
 
21
+ // Authenticate credentials
25
22
  message AuthenticationRequest {
26
- oneof auth_method {
27
- UserCredentials credentials = 1;
28
- string oauth_token = 2;
29
- }
23
+ UserCredentials credentials = 1;
30
24
  }
31
25
 
32
26
  message AuthenticationResponse {
33
- string access_token = 1;
34
- string refresh_token = 2;
35
- UserInfo user = 3;
27
+ AuthResult result = 1;
36
28
  }
37
29
 
38
-
39
- message UserCredentials {
40
- string email = 1;
41
- string phone = 2;
42
- string username = 3;
43
- string password = 4;
30
+ // AuthenticateWithOAuth
31
+ message OAuthSessionRequest {
32
+ OAuthProvider provider = 1;
33
+ string token = 2;
44
34
  }
45
-
46
- //Токены
35
+ message OAuthSessionResponse {
36
+ AuthResult result = 1;
37
+ bool is_new_user = 2;
38
+ }
39
+ // Tokens
47
40
  message TokenRefreshRequest {
48
41
  string refresh_token = 1;
49
42
  }
@@ -53,10 +46,31 @@ message TokenRefreshResponse {
53
46
  string refresh_token = 2;
54
47
  }
55
48
 
56
- message UserInfo {
49
+ // Shared
50
+ enum OAuthProvider {
51
+ OAUTH_PROVIDER_UNSPECIFIED = 0;
52
+ OAUTH_PROVIDER_GOOGLE = 1;
53
+ OAUTH_PROVIDER_GITHUB = 2;
54
+ OAUTH_PROVIDER_TELEGRAM = 3;
55
+ }
56
+ message UserCredentials {
57
+ oneof identifier {
58
+ string email = 1;
59
+ string phone = 2;
60
+ string username = 3;
61
+ }
62
+ string password = 4;
63
+ }
64
+ message UserProfile {
65
+ optional string email = 1;
66
+ optional string phone = 2;
67
+ optional string username = 3;
68
+ optional string display_name = 4;
69
+ }
70
+
71
+ message AuthResult {
57
72
  string user_id = 1;
58
- optional string email = 2;
59
- optional string phone = 3;
60
- optional string username = 4;
61
- optional string display_name = 5;
73
+ string access_token = 2;
74
+ string refresh_token = 3;
75
+ UserProfile user = 4;
62
76
  }