@candesk/contracts 3.1.0 → 3.3.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.
@@ -14,6 +14,7 @@ export interface GetAccountResponse {
14
14
  isPhoneVerified: boolean;
15
15
  isEmailVerified: boolean;
16
16
  role: Role;
17
+ isTelegramLinked: boolean;
17
18
  }
18
19
  export interface InitEmailChangeRequest {
19
20
  email: string;
@@ -31,8 +32,24 @@ export interface ConfirmEmailChangeRequest {
31
32
  export interface ConfirmEmailChangeResponse {
32
33
  ok: boolean;
33
34
  }
35
+ export interface LinkTelegramRequest {
36
+ userId: string;
37
+ query: {
38
+ [key: string]: string;
39
+ };
40
+ }
41
+ export interface LinkTelegramRequest_QueryEntry {
42
+ key: string;
43
+ value: string;
44
+ }
45
+ export interface LinkTelegramResponse {
46
+ linked: boolean;
47
+ /** bot link where the user shares the phone number, set only when not linked yet */
48
+ url: string;
49
+ }
34
50
  export interface AccountService {
35
51
  getAccount(request: GetAccountRequest): Promise<GetAccountResponse>;
36
52
  initEmailChange(request: InitEmailChangeRequest): Promise<InitEmailChangeResponse>;
37
53
  confirmEmailChange(request: ConfirmEmailChangeRequest): Promise<ConfirmEmailChangeResponse>;
54
+ linkTelegram(request: LinkTelegramRequest): Promise<LinkTelegramResponse>;
38
55
  }
@@ -40,9 +40,10 @@ export interface TelegramVerifyRequest_QueryEntry {
40
40
  value: string;
41
41
  }
42
42
  export interface TelegramVerifyResponse {
43
- url?: string | undefined;
44
- accessToken?: string | undefined;
45
- refreshToken?: string | undefined;
43
+ /** bot link when the phone number is still needed, the tokens are empty then */
44
+ url: string;
45
+ accessToken: string;
46
+ refreshToken: string;
46
47
  /** secret for the browser that started the login, set only together with url */
47
48
  pollToken: string;
48
49
  }
@@ -53,6 +54,8 @@ export interface TelegramCompleteRequest {
53
54
  }
54
55
  export interface TelegramCompleteResponse {
55
56
  sessionId: string;
57
+ /** true when the bot finished linking Telegram to a logged-in account, session_id is empty then */
58
+ linked: boolean;
56
59
  }
57
60
  export interface TelegramConsumeRequest {
58
61
  sessionId: string;
@@ -69,6 +72,13 @@ export interface TelegramPollResponse {
69
72
  accessToken: string;
70
73
  refreshToken: string;
71
74
  }
75
+ export interface TelegramStatusRequest {
76
+ telegramId: string;
77
+ }
78
+ export interface TelegramStatusResponse {
79
+ /** true when Telegram login lets this user in right away */
80
+ linked: boolean;
81
+ }
72
82
  export interface AuthService {
73
83
  sendOtp(request: SendOtpRequest): Promise<SendOtpResponse>;
74
84
  verifyOtp(request: VerifyOtpRequest): Promise<VerifyOtpResponse>;
@@ -79,4 +89,5 @@ export interface AuthService {
79
89
  telegramComplete(request: TelegramCompleteRequest): Promise<TelegramCompleteResponse>;
80
90
  telegramConsume(request: TelegramConsumeRequest): Promise<TelegramConsumeResponse>;
81
91
  telegramPoll(request: TelegramPollRequest): Promise<TelegramPollResponse>;
92
+ telegramStatus(request: TelegramStatusRequest): Promise<TelegramStatusResponse>;
82
93
  }
@@ -15,6 +15,7 @@ export interface GetAccountResponse {
15
15
  isPhoneVerified: boolean;
16
16
  isEmailVerified: boolean;
17
17
  role: Role;
18
+ isTelegramLinked: boolean;
18
19
  }
19
20
  export interface InitEmailChangeRequest {
20
21
  email: string;
@@ -32,16 +33,33 @@ export interface ConfirmEmailChangeRequest {
32
33
  export interface ConfirmEmailChangeResponse {
33
34
  ok: boolean;
34
35
  }
36
+ export interface LinkTelegramRequest {
37
+ userId: string;
38
+ query: {
39
+ [key: string]: string;
40
+ };
41
+ }
42
+ export interface LinkTelegramRequest_QueryEntry {
43
+ key: string;
44
+ value: string;
45
+ }
46
+ export interface LinkTelegramResponse {
47
+ linked: boolean;
48
+ /** bot link where the user shares the phone number, set only when not linked yet */
49
+ url: string;
50
+ }
35
51
  export declare const ACCOUNT_V1_PACKAGE_NAME = "account.v1";
36
52
  export interface AccountServiceClient {
37
53
  getAccount(request: GetAccountRequest): Observable<GetAccountResponse>;
38
54
  initEmailChange(request: InitEmailChangeRequest): Observable<InitEmailChangeResponse>;
39
55
  confirmEmailChange(request: ConfirmEmailChangeRequest): Observable<ConfirmEmailChangeResponse>;
56
+ linkTelegram(request: LinkTelegramRequest): Observable<LinkTelegramResponse>;
40
57
  }
41
58
  export interface AccountServiceController {
42
59
  getAccount(request: GetAccountRequest): Promise<GetAccountResponse> | Observable<GetAccountResponse> | GetAccountResponse;
43
60
  initEmailChange(request: InitEmailChangeRequest): Promise<InitEmailChangeResponse> | Observable<InitEmailChangeResponse> | InitEmailChangeResponse;
44
61
  confirmEmailChange(request: ConfirmEmailChangeRequest): Promise<ConfirmEmailChangeResponse> | Observable<ConfirmEmailChangeResponse> | ConfirmEmailChangeResponse;
62
+ linkTelegram(request: LinkTelegramRequest): Promise<LinkTelegramResponse> | Observable<LinkTelegramResponse> | LinkTelegramResponse;
45
63
  }
46
64
  export declare function AccountServiceControllerMethods(): (constructor: Function) => void;
47
65
  export declare const ACCOUNT_SERVICE_NAME = "AccountService";
@@ -19,7 +19,7 @@ var Role;
19
19
  exports.ACCOUNT_V1_PACKAGE_NAME = "account.v1";
20
20
  function AccountServiceControllerMethods() {
21
21
  return function (constructor) {
22
- const grpcMethods = ["getAccount", "initEmailChange", "confirmEmailChange"];
22
+ const grpcMethods = ["getAccount", "initEmailChange", "confirmEmailChange", "linkTelegram"];
23
23
  for (const method of grpcMethods) {
24
24
  const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
25
25
  (0, microservices_1.GrpcMethod)("AccountService", method)(constructor.prototype[method], method, descriptor);
@@ -41,9 +41,10 @@ export interface TelegramVerifyRequest_QueryEntry {
41
41
  value: string;
42
42
  }
43
43
  export interface TelegramVerifyResponse {
44
- url?: string | undefined;
45
- accessToken?: string | undefined;
46
- refreshToken?: string | undefined;
44
+ /** bot link when the phone number is still needed, the tokens are empty then */
45
+ url: string;
46
+ accessToken: string;
47
+ refreshToken: string;
47
48
  /** secret for the browser that started the login, set only together with url */
48
49
  pollToken: string;
49
50
  }
@@ -54,6 +55,8 @@ export interface TelegramCompleteRequest {
54
55
  }
55
56
  export interface TelegramCompleteResponse {
56
57
  sessionId: string;
58
+ /** true when the bot finished linking Telegram to a logged-in account, session_id is empty then */
59
+ linked: boolean;
57
60
  }
58
61
  export interface TelegramConsumeRequest {
59
62
  sessionId: string;
@@ -70,6 +73,13 @@ export interface TelegramPollResponse {
70
73
  accessToken: string;
71
74
  refreshToken: string;
72
75
  }
76
+ export interface TelegramStatusRequest {
77
+ telegramId: string;
78
+ }
79
+ export interface TelegramStatusResponse {
80
+ /** true when Telegram login lets this user in right away */
81
+ linked: boolean;
82
+ }
73
83
  export declare const AUTH_V1_PACKAGE_NAME = "auth.v1";
74
84
  export interface AuthServiceClient {
75
85
  sendOtp(request: SendOtpRequest): Observable<SendOtpResponse>;
@@ -81,6 +91,7 @@ export interface AuthServiceClient {
81
91
  telegramComplete(request: TelegramCompleteRequest): Observable<TelegramCompleteResponse>;
82
92
  telegramConsume(request: TelegramConsumeRequest): Observable<TelegramConsumeResponse>;
83
93
  telegramPoll(request: TelegramPollRequest): Observable<TelegramPollResponse>;
94
+ telegramStatus(request: TelegramStatusRequest): Observable<TelegramStatusResponse>;
84
95
  }
85
96
  export interface AuthServiceController {
86
97
  sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse;
@@ -92,6 +103,7 @@ export interface AuthServiceController {
92
103
  telegramComplete(request: TelegramCompleteRequest): Promise<TelegramCompleteResponse> | Observable<TelegramCompleteResponse> | TelegramCompleteResponse;
93
104
  telegramConsume(request: TelegramConsumeRequest): Promise<TelegramConsumeResponse> | Observable<TelegramConsumeResponse> | TelegramConsumeResponse;
94
105
  telegramPoll(request: TelegramPollRequest): Promise<TelegramPollResponse> | Observable<TelegramPollResponse> | TelegramPollResponse;
106
+ telegramStatus(request: TelegramStatusRequest): Promise<TelegramStatusResponse> | Observable<TelegramStatusResponse> | TelegramStatusResponse;
95
107
  }
96
108
  export declare function AuthServiceControllerMethods(): (constructor: Function) => void;
97
109
  export declare const AUTH_SERVICE_NAME = "AuthService";
package/dist/nest/auth.js CHANGED
@@ -23,6 +23,7 @@ function AuthServiceControllerMethods() {
23
23
  "telegramComplete",
24
24
  "telegramConsume",
25
25
  "telegramPoll",
26
+ "telegramStatus",
26
27
  ];
27
28
  for (const method of grpcMethods) {
28
29
  const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candesk/contracts",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "Protobuf contracts for Candesk microservices",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -7,6 +7,8 @@ service AccountService {
7
7
 
8
8
  rpc InitEmailChange(InitEmailChangeRequest) returns (InitEmailChangeResponse);
9
9
  rpc ConfirmEmailChange(ConfirmEmailChangeRequest) returns (ConfirmEmailChangeResponse);
10
+
11
+ rpc LinkTelegram(LinkTelegramRequest) returns (LinkTelegramResponse);
10
12
  }
11
13
 
12
14
  message GetAccountRequest {
@@ -20,6 +22,7 @@ message GetAccountResponse {
20
22
  bool is_phone_verified = 4;
21
23
  bool is_email_verified = 5;
22
24
  Role role = 6;
25
+ bool is_telegram_linked = 7;
23
26
  }
24
27
 
25
28
  message InitEmailChangeRequest {
@@ -42,6 +45,17 @@ message ConfirmEmailChangeResponse {
42
45
  bool ok = 1;
43
46
  }
44
47
 
48
+ message LinkTelegramRequest {
49
+ string user_id = 1;
50
+ map<string, string> query = 2;
51
+ }
52
+
53
+ message LinkTelegramResponse {
54
+ bool linked = 1;
55
+ // bot link where the user shares the phone number, set only when not linked yet
56
+ string url = 2;
57
+ }
58
+
45
59
  enum Role {
46
60
  USER = 0;
47
61
  ADMIN = 1;
package/proto/auth.proto CHANGED
@@ -15,6 +15,7 @@ service AuthService {
15
15
  rpc TelegramComplete (TelegramCompleteRequest) returns (TelegramCompleteResponse);
16
16
  rpc TelegramConsume (TelegramConsumeRequest) returns (TelegramConsumeResponse);
17
17
  rpc TelegramPoll (TelegramPollRequest) returns (TelegramPollResponse);
18
+ rpc TelegramStatus (TelegramStatusRequest) returns (TelegramStatusResponse);
18
19
  }
19
20
 
20
21
  message SendOtpRequest {
@@ -65,11 +66,10 @@ message TelegramVerifyRequest {
65
66
  }
66
67
 
67
68
  message TelegramVerifyResponse {
68
- oneof result {
69
- string url = 1;
70
- string access_token = 2;
71
- string refresh_token = 3;
72
- }
69
+ // bot link when the phone number is still needed, the tokens are empty then
70
+ string url = 1;
71
+ string access_token = 2;
72
+ string refresh_token = 3;
73
73
  // secret for the browser that started the login, set only together with url
74
74
  string poll_token = 4;
75
75
  }
@@ -82,6 +82,8 @@ message TelegramCompleteRequest {
82
82
 
83
83
  message TelegramCompleteResponse {
84
84
  string session_id = 1;
85
+ // true when the bot finished linking Telegram to a logged-in account, session_id is empty then
86
+ bool linked = 2;
85
87
  }
86
88
 
87
89
  message TelegramConsumeRequest {
@@ -101,4 +103,13 @@ message TelegramPollResponse {
101
103
  bool ready = 1;
102
104
  string access_token = 2;
103
105
  string refresh_token = 3;
106
+ }
107
+
108
+ message TelegramStatusRequest {
109
+ string telegram_id = 1;
110
+ }
111
+
112
+ message TelegramStatusResponse {
113
+ // true when Telegram login lets this user in right away
114
+ bool linked = 1;
104
115
  }