@arbiwallet/contracts 1.0.4 → 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.
package/gen/auth.ts CHANGED
@@ -11,47 +11,129 @@ import { Observable } from "rxjs";
11
11
  export const protobufPackage = "auth";
12
12
 
13
13
  export interface TelegramAuthRequest {
14
- /**
15
- * Telegram.WebApp.initData (raw query string).
16
- * Contains auth_date, hash, user (JSON), query_id, etc.
17
- */
18
- initData: string;
19
- }
20
-
21
- export interface TelegramAuthResponse {
22
- token: string;
23
- telegramId: number;
14
+ id: string;
15
+ hash: string;
24
16
  username: string;
25
17
  firstName: string;
26
18
  lastName: string;
19
+ authDate: string;
27
20
  photoUrl: string;
28
21
  }
29
22
 
23
+ export interface GoogleAuthRequest {
24
+ idToken: string;
25
+ }
26
+
27
+ export interface AppleAuthRequest {
28
+ identityToken: string;
29
+ }
30
+
31
+ export interface PhoneRequestCodeRequest {
32
+ phone: string;
33
+ }
34
+
35
+ export interface PhoneVerifyCodeRequest {
36
+ phone: string;
37
+ code: string;
38
+ }
39
+
40
+ export interface RefreshTokenRequest {
41
+ refreshToken: string;
42
+ }
43
+
44
+ export interface AccessTokenRequest {
45
+ accessToken: string;
46
+ }
47
+
48
+ export interface AuthTokensResponse {
49
+ accessToken: string;
50
+ refreshToken: string;
51
+ }
52
+
53
+ export interface AccessTokenResponse {
54
+ accessToken: string;
55
+ }
56
+
57
+ export interface MessageResponse {
58
+ message: string;
59
+ }
60
+
61
+ export interface MeResponse {
62
+ sub: string;
63
+ }
64
+
30
65
  export const AUTH_PACKAGE_NAME = "auth";
31
66
 
32
- export interface TelegramAuthServiceClient {
33
- telegramAuth(request: TelegramAuthRequest): Observable<TelegramAuthResponse>;
67
+ export interface AuthServiceClient {
68
+ telegramAuth(request: TelegramAuthRequest): Observable<AuthTokensResponse>;
69
+
70
+ googleAuth(request: GoogleAuthRequest): Observable<AuthTokensResponse>;
71
+
72
+ appleAuth(request: AppleAuthRequest): Observable<AuthTokensResponse>;
73
+
74
+ requestPhoneCode(request: PhoneRequestCodeRequest): Observable<MessageResponse>;
75
+
76
+ verifyPhoneCode(request: PhoneVerifyCodeRequest): Observable<AuthTokensResponse>;
77
+
78
+ refreshToken(request: RefreshTokenRequest): Observable<AccessTokenResponse>;
79
+
80
+ logout(request: RefreshTokenRequest): Observable<MessageResponse>;
81
+
82
+ getMe(request: AccessTokenRequest): Observable<MeResponse>;
34
83
  }
35
84
 
36
- export interface TelegramAuthServiceController {
85
+ export interface AuthServiceController {
37
86
  telegramAuth(
38
87
  request: TelegramAuthRequest,
39
- ): Promise<TelegramAuthResponse> | Observable<TelegramAuthResponse> | TelegramAuthResponse;
88
+ ): Promise<AuthTokensResponse> | Observable<AuthTokensResponse> | AuthTokensResponse;
89
+
90
+ googleAuth(
91
+ request: GoogleAuthRequest,
92
+ ): Promise<AuthTokensResponse> | Observable<AuthTokensResponse> | AuthTokensResponse;
93
+
94
+ appleAuth(
95
+ request: AppleAuthRequest,
96
+ ): Promise<AuthTokensResponse> | Observable<AuthTokensResponse> | AuthTokensResponse;
97
+
98
+ requestPhoneCode(
99
+ request: PhoneRequestCodeRequest,
100
+ ): Promise<MessageResponse> | Observable<MessageResponse> | MessageResponse;
101
+
102
+ verifyPhoneCode(
103
+ request: PhoneVerifyCodeRequest,
104
+ ): Promise<AuthTokensResponse> | Observable<AuthTokensResponse> | AuthTokensResponse;
105
+
106
+ refreshToken(
107
+ request: RefreshTokenRequest,
108
+ ): Promise<AccessTokenResponse> | Observable<AccessTokenResponse> | AccessTokenResponse;
109
+
110
+ logout(request: RefreshTokenRequest): Promise<MessageResponse> | Observable<MessageResponse> | MessageResponse;
111
+
112
+ getMe(request: AccessTokenRequest): Promise<MeResponse> | Observable<MeResponse> | MeResponse;
40
113
  }
41
114
 
42
- export function TelegramAuthServiceControllerMethods() {
115
+ export function AuthServiceControllerMethods() {
43
116
  return function (constructor: Function) {
44
- const grpcMethods: string[] = ["telegramAuth"];
117
+ const grpcMethods: string[] = [
118
+ "telegramAuth",
119
+ "googleAuth",
120
+ "appleAuth",
121
+ "requestPhoneCode",
122
+ "verifyPhoneCode",
123
+ "refreshToken",
124
+ "logout",
125
+ "getMe",
126
+ ];
45
127
  for (const method of grpcMethods) {
46
128
  const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
47
- GrpcMethod("TelegramAuthService", method)(constructor.prototype[method], method, descriptor);
129
+ GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
48
130
  }
49
131
  const grpcStreamMethods: string[] = [];
50
132
  for (const method of grpcStreamMethods) {
51
133
  const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
52
- GrpcStreamMethod("TelegramAuthService", method)(constructor.prototype[method], method, descriptor);
134
+ GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
53
135
  }
54
136
  };
55
137
  }
56
138
 
57
- export const TELEGRAM_AUTH_SERVICE_NAME = "TelegramAuthService";
139
+ export const AUTH_SERVICE_NAME = "AuthService";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arbiwallet/contracts",
3
3
  "descriptions": "Generate and manage smart contracts for ArbiWallet",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "scripts": {
6
6
  "generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit"
7
7
  },
package/proto/auth.proto CHANGED
@@ -1,21 +1,65 @@
1
1
  syntax = "proto3";
2
2
  package auth;
3
3
 
4
- service TelegramAuthService {
5
- rpc TelegramAuth (TelegramAuthRequest) returns (TelegramAuthResponse);
4
+ service AuthService {
5
+ rpc TelegramAuth (TelegramAuthRequest) returns (AuthTokensResponse);
6
+ rpc GoogleAuth (GoogleAuthRequest) returns (AuthTokensResponse);
7
+ rpc AppleAuth (AppleAuthRequest) returns (AuthTokensResponse);
8
+ rpc RequestPhoneCode (PhoneRequestCodeRequest) returns (MessageResponse);
9
+ rpc VerifyPhoneCode (PhoneVerifyCodeRequest) returns (AuthTokensResponse);
10
+ rpc RefreshToken (RefreshTokenRequest) returns (AccessTokenResponse);
11
+ rpc Logout (RefreshTokenRequest) returns (MessageResponse);
12
+ rpc GetMe (AccessTokenRequest) returns (MeResponse);
6
13
  }
7
14
 
8
15
  message TelegramAuthRequest {
9
- // Telegram.WebApp.initData (raw query string).
10
- // Contains auth_date, hash, user (JSON), query_id, etc.
11
- string init_data = 1;
12
- }
13
-
14
- message TelegramAuthResponse {
15
- string token = 1;
16
- int64 telegram_id = 2;
16
+ string id = 1;
17
+ string hash = 2;
17
18
  string username = 3;
18
19
  string first_name = 4;
19
20
  string last_name = 5;
20
- string photo_url = 6;
21
+ string auth_date = 6;
22
+ string photo_url = 7;
23
+ }
24
+
25
+ message GoogleAuthRequest {
26
+ string id_token = 1;
27
+ }
28
+
29
+ message AppleAuthRequest {
30
+ string identity_token = 1;
31
+ }
32
+
33
+ message PhoneRequestCodeRequest {
34
+ string phone = 1;
35
+ }
36
+
37
+ message PhoneVerifyCodeRequest {
38
+ string phone = 1;
39
+ string code = 2;
40
+ }
41
+
42
+ message RefreshTokenRequest {
43
+ string refresh_token = 1;
44
+ }
45
+
46
+ message AccessTokenRequest {
47
+ string access_token = 1;
48
+ }
49
+
50
+ message AuthTokensResponse {
51
+ string access_token = 1;
52
+ string refresh_token = 2;
53
+ }
54
+
55
+ message AccessTokenResponse {
56
+ string access_token = 1;
57
+ }
58
+
59
+ message MessageResponse {
60
+ string message = 1;
61
+ }
62
+
63
+ message MeResponse {
64
+ string sub = 1;
21
65
  }