@seatwave/contracts 1.0.0 → 1.0.1

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
@@ -10,36 +10,113 @@ import { Observable } from "rxjs";
10
10
 
11
11
  export const protobufPackage = "auth.v1";
12
12
 
13
+ /** Request to send a one-time password (OTP) to the user. */
13
14
  export interface SendOtpRequest {
15
+ /** The user identifier: either phone number or email address. */
14
16
  identifier: string;
17
+ /** The type of identifier: "phone" or "email". */
15
18
  type: string;
16
19
  }
17
20
 
21
+ /** Response for SendOtp request. */
18
22
  export interface SendOtpResponse {
23
+ /** True if OTP was successfully sent. */
19
24
  ok: boolean;
20
25
  }
21
26
 
27
+ /** Request to verify a one-time password (OTP). */
28
+ export interface VerifyOtpRequest {
29
+ /** The user identifier: either phone number or email address. */
30
+ identifier: string;
31
+ /** The type of identifier: "phone" or "email". */
32
+ type: string;
33
+ /** The OTP code sent to the user. */
34
+ code: string;
35
+ }
36
+
37
+ /** Response for VerifyOtp request. */
38
+ export interface VerifyOtpResponse {
39
+ /** JWT access token. */
40
+ accessToken: string;
41
+ /** Refresh token to obtain new access tokens. */
42
+ refreshToken: string;
43
+ }
44
+
45
+ /** Request to refresh an access token. */
46
+ export interface RefreshRequest {
47
+ /** The refresh token issued previously. */
48
+ refreshToken: string;
49
+ }
50
+
51
+ /** Response for Refresh request. */
52
+ export interface RefreshResponse {
53
+ /** New JWT access token. */
54
+ accessToken: string;
55
+ /** New refresh token. */
56
+ refreshToken: string;
57
+ }
58
+
22
59
  export const AUTH_V1_PACKAGE_NAME = "auth.v1";
23
60
 
24
- /** AuthService handles user authentication operations */
61
+ /**
62
+ * AuthService handles all user authentication operations such as sending
63
+ * OTP codes, verifying them, and refreshing access tokens.
64
+ */
25
65
 
26
66
  export interface AuthServiceClient {
27
- /** Send a verification code to the user by phone or email */
67
+ /**
68
+ * Sends a one-time verification code to the user via phone or email.
69
+ * The user provides an identifier (phone number or email) and type.
70
+ */
28
71
 
29
72
  sendOtp(request: SendOtpRequest): Observable<SendOtpResponse>;
73
+
74
+ /**
75
+ * Verifies a one-time password (OTP) sent to the user.
76
+ * The request must include the identifier, type, and OTP code.
77
+ */
78
+
79
+ verifyOtp(request: VerifyOtpRequest): Observable<VerifyOtpResponse>;
80
+
81
+ /**
82
+ * Refreshes the access token using a valid refresh token.
83
+ * Returns a new access token and refresh token.
84
+ */
85
+
86
+ refresh(request: RefreshRequest): Observable<RefreshResponse>;
30
87
  }
31
88
 
32
- /** AuthService handles user authentication operations */
89
+ /**
90
+ * AuthService handles all user authentication operations such as sending
91
+ * OTP codes, verifying them, and refreshing access tokens.
92
+ */
33
93
 
34
94
  export interface AuthServiceController {
35
- /** Send a verification code to the user by phone or email */
95
+ /**
96
+ * Sends a one-time verification code to the user via phone or email.
97
+ * The user provides an identifier (phone number or email) and type.
98
+ */
36
99
 
37
100
  sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse;
101
+
102
+ /**
103
+ * Verifies a one-time password (OTP) sent to the user.
104
+ * The request must include the identifier, type, and OTP code.
105
+ */
106
+
107
+ verifyOtp(request: VerifyOtpRequest): Promise<VerifyOtpResponse> | Observable<VerifyOtpResponse> | VerifyOtpResponse;
108
+
109
+ /**
110
+ * Refreshes the access token using a valid refresh token.
111
+ * Returns a new access token and refresh token.
112
+ */
113
+
114
+ refresh(request: RefreshRequest): Promise<RefreshResponse> | Observable<RefreshResponse> | RefreshResponse;
38
115
  }
39
116
 
40
117
  export function AuthServiceControllerMethods() {
41
118
  return function (constructor: Function) {
42
- const grpcMethods: string[] = ["sendOtp"];
119
+ const grpcMethods: string[] = ["sendOtp", "verifyOtp", "refresh"];
43
120
  for (const method of grpcMethods) {
44
121
  const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
45
122
  GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seatwave/contracts",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Protobuf definitions and generated TypeScript types",
5
5
  "scripts": {
6
6
  "generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit"
package/proto/auth.proto CHANGED
@@ -2,17 +2,69 @@ syntax = "proto3";
2
2
 
3
3
  package auth.v1;
4
4
 
5
- // AuthService handles user authentication operations
5
+ // AuthService handles all user authentication operations such as sending
6
+ // OTP codes, verifying them, and refreshing access tokens.
6
7
  service AuthService {
7
- // Send a verification code to the user by phone or email
8
+ // Sends a one-time verification code to the user via phone or email.
9
+ // The user provides an identifier (phone number or email) and type.
8
10
  rpc SendOtp (SendOtpRequest) returns (SendOtpResponse);
11
+
12
+ // Verifies a one-time password (OTP) sent to the user.
13
+ // The request must include the identifier, type, and OTP code.
14
+ rpc VerifyOtp (VerifyOtpRequest) returns (VerifyOtpResponse);
15
+
16
+ // Refreshes the access token using a valid refresh token.
17
+ // Returns a new access token and refresh token.
18
+ rpc Refresh (RefreshRequest) returns (RefreshResponse);
9
19
  }
10
20
 
21
+ // Request to send a one-time password (OTP) to the user.
11
22
  message SendOtpRequest {
23
+ // The user identifier: either phone number or email address.
12
24
  string identifier = 1;
13
- string type = 2;
25
+
26
+ // The type of identifier: "phone" or "email".
27
+ string type = 2;
14
28
  }
15
29
 
30
+ // Response for SendOtp request.
16
31
  message SendOtpResponse {
17
- bool ok = 1;
18
- }
32
+ // True if OTP was successfully sent.
33
+ bool ok = 1;
34
+ }
35
+
36
+ // Request to verify a one-time password (OTP).
37
+ message VerifyOtpRequest {
38
+ // The user identifier: either phone number or email address.
39
+ string identifier = 1;
40
+
41
+ // The type of identifier: "phone" or "email".
42
+ string type = 2;
43
+
44
+ // The OTP code sent to the user.
45
+ string code = 3;
46
+ }
47
+
48
+ // Response for VerifyOtp request.
49
+ message VerifyOtpResponse {
50
+ // JWT access token.
51
+ string access_token = 1;
52
+
53
+ // Refresh token to obtain new access tokens.
54
+ string refresh_token = 2;
55
+ }
56
+
57
+ // Request to refresh an access token.
58
+ message RefreshRequest {
59
+ // The refresh token issued previously.
60
+ string refresh_token = 1;
61
+ }
62
+
63
+ // Response for Refresh request.
64
+ message RefreshResponse {
65
+ // New JWT access token.
66
+ string access_token = 1;
67
+
68
+ // New refresh token.
69
+ string refresh_token = 2;
70
+ }