@candesk/contracts 3.2.0 → 3.4.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.
@@ -2,4 +2,5 @@ export declare const AUTH_EVENTS: {
2
2
  readonly OTP_REQUESTED: 'auth.otp.requested';
3
3
  readonly EMAIL_CHANGE_REQUESTED: 'auth.email-change.requested';
4
4
  readonly EMAIL_CHANGED: 'auth.email.changed';
5
+ readonly TELEGRAM_LINKED: 'auth.telegram.linked';
5
6
  };
@@ -4,5 +4,6 @@ exports.AUTH_EVENTS = void 0;
4
4
  exports.AUTH_EVENTS = {
5
5
  OTP_REQUESTED: 'auth.otp.requested',
6
6
  EMAIL_CHANGE_REQUESTED: 'auth.email-change.requested',
7
- EMAIL_CHANGED: 'auth.email.changed'
7
+ EMAIL_CHANGED: 'auth.email.changed',
8
+ TELEGRAM_LINKED: 'auth.telegram.linked'
8
9
  };
@@ -2,3 +2,4 @@ export * from './auth.events';
2
2
  export * from './email-change-requested.interface';
3
3
  export * from './email-changed.interface';
4
4
  export * from './otp-requested.interface';
5
+ export * from './telegram-linked.interface';
@@ -18,3 +18,4 @@ __exportStar(require("./auth.events"), exports);
18
18
  __exportStar(require("./email-change-requested.interface"), exports);
19
19
  __exportStar(require("./email-changed.interface"), exports);
20
20
  __exportStar(require("./otp-requested.interface"), exports);
21
+ __exportStar(require("./telegram-linked.interface"), exports);
@@ -0,0 +1,3 @@
1
+ export interface TelegramLinkedEvent {
2
+ email: string;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -47,9 +47,16 @@ export interface LinkTelegramResponse {
47
47
  /** bot link where the user shares the phone number, set only when not linked yet */
48
48
  url: string;
49
49
  }
50
+ export interface UnlinkTelegramRequest {
51
+ userId: string;
52
+ }
53
+ export interface UnlinkTelegramResponse {
54
+ ok: boolean;
55
+ }
50
56
  export interface AccountService {
51
57
  getAccount(request: GetAccountRequest): Promise<GetAccountResponse>;
52
58
  initEmailChange(request: InitEmailChangeRequest): Promise<InitEmailChangeResponse>;
53
59
  confirmEmailChange(request: ConfirmEmailChangeRequest): Promise<ConfirmEmailChangeResponse>;
54
60
  linkTelegram(request: LinkTelegramRequest): Promise<LinkTelegramResponse>;
61
+ unlinkTelegram(request: UnlinkTelegramRequest): Promise<UnlinkTelegramResponse>;
55
62
  }
@@ -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
  }
@@ -71,6 +72,13 @@ export interface TelegramPollResponse {
71
72
  accessToken: string;
72
73
  refreshToken: string;
73
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
+ }
74
82
  export interface AuthService {
75
83
  sendOtp(request: SendOtpRequest): Promise<SendOtpResponse>;
76
84
  verifyOtp(request: VerifyOtpRequest): Promise<VerifyOtpResponse>;
@@ -81,4 +89,5 @@ export interface AuthService {
81
89
  telegramComplete(request: TelegramCompleteRequest): Promise<TelegramCompleteResponse>;
82
90
  telegramConsume(request: TelegramConsumeRequest): Promise<TelegramConsumeResponse>;
83
91
  telegramPoll(request: TelegramPollRequest): Promise<TelegramPollResponse>;
92
+ telegramStatus(request: TelegramStatusRequest): Promise<TelegramStatusResponse>;
84
93
  }
@@ -48,18 +48,26 @@ export interface LinkTelegramResponse {
48
48
  /** bot link where the user shares the phone number, set only when not linked yet */
49
49
  url: string;
50
50
  }
51
+ export interface UnlinkTelegramRequest {
52
+ userId: string;
53
+ }
54
+ export interface UnlinkTelegramResponse {
55
+ ok: boolean;
56
+ }
51
57
  export declare const ACCOUNT_V1_PACKAGE_NAME = "account.v1";
52
58
  export interface AccountServiceClient {
53
59
  getAccount(request: GetAccountRequest): Observable<GetAccountResponse>;
54
60
  initEmailChange(request: InitEmailChangeRequest): Observable<InitEmailChangeResponse>;
55
61
  confirmEmailChange(request: ConfirmEmailChangeRequest): Observable<ConfirmEmailChangeResponse>;
56
62
  linkTelegram(request: LinkTelegramRequest): Observable<LinkTelegramResponse>;
63
+ unlinkTelegram(request: UnlinkTelegramRequest): Observable<UnlinkTelegramResponse>;
57
64
  }
58
65
  export interface AccountServiceController {
59
66
  getAccount(request: GetAccountRequest): Promise<GetAccountResponse> | Observable<GetAccountResponse> | GetAccountResponse;
60
67
  initEmailChange(request: InitEmailChangeRequest): Promise<InitEmailChangeResponse> | Observable<InitEmailChangeResponse> | InitEmailChangeResponse;
61
68
  confirmEmailChange(request: ConfirmEmailChangeRequest): Promise<ConfirmEmailChangeResponse> | Observable<ConfirmEmailChangeResponse> | ConfirmEmailChangeResponse;
62
69
  linkTelegram(request: LinkTelegramRequest): Promise<LinkTelegramResponse> | Observable<LinkTelegramResponse> | LinkTelegramResponse;
70
+ unlinkTelegram(request: UnlinkTelegramRequest): Promise<UnlinkTelegramResponse> | Observable<UnlinkTelegramResponse> | UnlinkTelegramResponse;
63
71
  }
64
72
  export declare function AccountServiceControllerMethods(): (constructor: Function) => void;
65
73
  export declare const ACCOUNT_SERVICE_NAME = "AccountService";
@@ -19,7 +19,13 @@ 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", "linkTelegram"];
22
+ const grpcMethods = [
23
+ "getAccount",
24
+ "initEmailChange",
25
+ "confirmEmailChange",
26
+ "linkTelegram",
27
+ "unlinkTelegram",
28
+ ];
23
29
  for (const method of grpcMethods) {
24
30
  const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
25
31
  (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
  }
@@ -72,6 +73,13 @@ export interface TelegramPollResponse {
72
73
  accessToken: string;
73
74
  refreshToken: string;
74
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
+ }
75
83
  export declare const AUTH_V1_PACKAGE_NAME = "auth.v1";
76
84
  export interface AuthServiceClient {
77
85
  sendOtp(request: SendOtpRequest): Observable<SendOtpResponse>;
@@ -83,6 +91,7 @@ export interface AuthServiceClient {
83
91
  telegramComplete(request: TelegramCompleteRequest): Observable<TelegramCompleteResponse>;
84
92
  telegramConsume(request: TelegramConsumeRequest): Observable<TelegramConsumeResponse>;
85
93
  telegramPoll(request: TelegramPollRequest): Observable<TelegramPollResponse>;
94
+ telegramStatus(request: TelegramStatusRequest): Observable<TelegramStatusResponse>;
86
95
  }
87
96
  export interface AuthServiceController {
88
97
  sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse;
@@ -94,6 +103,7 @@ export interface AuthServiceController {
94
103
  telegramComplete(request: TelegramCompleteRequest): Promise<TelegramCompleteResponse> | Observable<TelegramCompleteResponse> | TelegramCompleteResponse;
95
104
  telegramConsume(request: TelegramConsumeRequest): Promise<TelegramConsumeResponse> | Observable<TelegramConsumeResponse> | TelegramConsumeResponse;
96
105
  telegramPoll(request: TelegramPollRequest): Promise<TelegramPollResponse> | Observable<TelegramPollResponse> | TelegramPollResponse;
106
+ telegramStatus(request: TelegramStatusRequest): Promise<TelegramStatusResponse> | Observable<TelegramStatusResponse> | TelegramStatusResponse;
97
107
  }
98
108
  export declare function AuthServiceControllerMethods(): (constructor: Function) => void;
99
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.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "Protobuf contracts for Candesk microservices",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -9,6 +9,7 @@ service AccountService {
9
9
  rpc ConfirmEmailChange(ConfirmEmailChangeRequest) returns (ConfirmEmailChangeResponse);
10
10
 
11
11
  rpc LinkTelegram(LinkTelegramRequest) returns (LinkTelegramResponse);
12
+ rpc UnlinkTelegram(UnlinkTelegramRequest) returns (UnlinkTelegramResponse);
12
13
  }
13
14
 
14
15
  message GetAccountRequest {
@@ -56,6 +57,14 @@ message LinkTelegramResponse {
56
57
  string url = 2;
57
58
  }
58
59
 
60
+ message UnlinkTelegramRequest {
61
+ string user_id = 1;
62
+ }
63
+
64
+ message UnlinkTelegramResponse {
65
+ bool ok = 1;
66
+ }
67
+
59
68
  enum Role {
60
69
  USER = 0;
61
70
  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
  }
@@ -103,4 +103,13 @@ message TelegramPollResponse {
103
103
  bool ready = 1;
104
104
  string access_token = 2;
105
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;
106
115
  }