@nemma-training/contracts 1.0.1 → 1.0.2

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
@@ -19,6 +19,17 @@ export interface SendOtpResponse {
19
19
  message: string;
20
20
  }
21
21
 
22
+ export interface VerifyOtpRequest {
23
+ identifier: string;
24
+ type: string;
25
+ code: string;
26
+ }
27
+
28
+ export interface VerifyOtpResponse {
29
+ accessToken: string;
30
+ refreshToken: string;
31
+ }
32
+
22
33
  function createBaseSendOtpRequest(): SendOtpRequest {
23
34
  return { identifier: "", type: "" };
24
35
  }
@@ -171,8 +182,185 @@ export const SendOtpResponse: MessageFns<SendOtpResponse> = {
171
182
  },
172
183
  };
173
184
 
185
+ function createBaseVerifyOtpRequest(): VerifyOtpRequest {
186
+ return { identifier: "", type: "", code: "" };
187
+ }
188
+
189
+ export const VerifyOtpRequest: MessageFns<VerifyOtpRequest> = {
190
+ encode(message: VerifyOtpRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
191
+ if (message.identifier !== "") {
192
+ writer.uint32(10).string(message.identifier);
193
+ }
194
+ if (message.type !== "") {
195
+ writer.uint32(18).string(message.type);
196
+ }
197
+ if (message.code !== "") {
198
+ writer.uint32(26).string(message.code);
199
+ }
200
+ return writer;
201
+ },
202
+
203
+ decode(input: BinaryReader | Uint8Array, length?: number): VerifyOtpRequest {
204
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
205
+ const end = length === undefined ? reader.len : reader.pos + length;
206
+ const message = createBaseVerifyOtpRequest();
207
+ while (reader.pos < end) {
208
+ const tag = reader.uint32();
209
+ switch (tag >>> 3) {
210
+ case 1: {
211
+ if (tag !== 10) {
212
+ break;
213
+ }
214
+
215
+ message.identifier = reader.string();
216
+ continue;
217
+ }
218
+ case 2: {
219
+ if (tag !== 18) {
220
+ break;
221
+ }
222
+
223
+ message.type = reader.string();
224
+ continue;
225
+ }
226
+ case 3: {
227
+ if (tag !== 26) {
228
+ break;
229
+ }
230
+
231
+ message.code = reader.string();
232
+ continue;
233
+ }
234
+ }
235
+ if ((tag & 7) === 4 || tag === 0) {
236
+ break;
237
+ }
238
+ reader.skip(tag & 7);
239
+ }
240
+ return message;
241
+ },
242
+
243
+ fromJSON(object: any): VerifyOtpRequest {
244
+ return {
245
+ identifier: isSet(object.identifier) ? globalThis.String(object.identifier) : "",
246
+ type: isSet(object.type) ? globalThis.String(object.type) : "",
247
+ code: isSet(object.code) ? globalThis.String(object.code) : "",
248
+ };
249
+ },
250
+
251
+ toJSON(message: VerifyOtpRequest): unknown {
252
+ const obj: any = {};
253
+ if (message.identifier !== "") {
254
+ obj.identifier = message.identifier;
255
+ }
256
+ if (message.type !== "") {
257
+ obj.type = message.type;
258
+ }
259
+ if (message.code !== "") {
260
+ obj.code = message.code;
261
+ }
262
+ return obj;
263
+ },
264
+
265
+ create<I extends Exact<DeepPartial<VerifyOtpRequest>, I>>(base?: I): VerifyOtpRequest {
266
+ return VerifyOtpRequest.fromPartial(base ?? ({} as any));
267
+ },
268
+ fromPartial<I extends Exact<DeepPartial<VerifyOtpRequest>, I>>(object: I): VerifyOtpRequest {
269
+ const message = createBaseVerifyOtpRequest();
270
+ message.identifier = object.identifier ?? "";
271
+ message.type = object.type ?? "";
272
+ message.code = object.code ?? "";
273
+ return message;
274
+ },
275
+ };
276
+
277
+ function createBaseVerifyOtpResponse(): VerifyOtpResponse {
278
+ return { accessToken: "", refreshToken: "" };
279
+ }
280
+
281
+ export const VerifyOtpResponse: MessageFns<VerifyOtpResponse> = {
282
+ encode(message: VerifyOtpResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
283
+ if (message.accessToken !== "") {
284
+ writer.uint32(10).string(message.accessToken);
285
+ }
286
+ if (message.refreshToken !== "") {
287
+ writer.uint32(18).string(message.refreshToken);
288
+ }
289
+ return writer;
290
+ },
291
+
292
+ decode(input: BinaryReader | Uint8Array, length?: number): VerifyOtpResponse {
293
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
294
+ const end = length === undefined ? reader.len : reader.pos + length;
295
+ const message = createBaseVerifyOtpResponse();
296
+ while (reader.pos < end) {
297
+ const tag = reader.uint32();
298
+ switch (tag >>> 3) {
299
+ case 1: {
300
+ if (tag !== 10) {
301
+ break;
302
+ }
303
+
304
+ message.accessToken = reader.string();
305
+ continue;
306
+ }
307
+ case 2: {
308
+ if (tag !== 18) {
309
+ break;
310
+ }
311
+
312
+ message.refreshToken = reader.string();
313
+ continue;
314
+ }
315
+ }
316
+ if ((tag & 7) === 4 || tag === 0) {
317
+ break;
318
+ }
319
+ reader.skip(tag & 7);
320
+ }
321
+ return message;
322
+ },
323
+
324
+ fromJSON(object: any): VerifyOtpResponse {
325
+ return {
326
+ accessToken: isSet(object.accessToken)
327
+ ? globalThis.String(object.accessToken)
328
+ : isSet(object.access_token)
329
+ ? globalThis.String(object.access_token)
330
+ : "",
331
+ refreshToken: isSet(object.refreshToken)
332
+ ? globalThis.String(object.refreshToken)
333
+ : isSet(object.refresh_token)
334
+ ? globalThis.String(object.refresh_token)
335
+ : "",
336
+ };
337
+ },
338
+
339
+ toJSON(message: VerifyOtpResponse): unknown {
340
+ const obj: any = {};
341
+ if (message.accessToken !== "") {
342
+ obj.accessToken = message.accessToken;
343
+ }
344
+ if (message.refreshToken !== "") {
345
+ obj.refreshToken = message.refreshToken;
346
+ }
347
+ return obj;
348
+ },
349
+
350
+ create<I extends Exact<DeepPartial<VerifyOtpResponse>, I>>(base?: I): VerifyOtpResponse {
351
+ return VerifyOtpResponse.fromPartial(base ?? ({} as any));
352
+ },
353
+ fromPartial<I extends Exact<DeepPartial<VerifyOtpResponse>, I>>(object: I): VerifyOtpResponse {
354
+ const message = createBaseVerifyOtpResponse();
355
+ message.accessToken = object.accessToken ?? "";
356
+ message.refreshToken = object.refreshToken ?? "";
357
+ return message;
358
+ },
359
+ };
360
+
174
361
  export interface AuthService {
175
362
  SendOtp(request: SendOtpRequest): Promise<SendOtpResponse>;
363
+ VerifyOtp(request: VerifyOtpRequest): Promise<VerifyOtpResponse>;
176
364
  }
177
365
 
178
366
  export const AuthServiceServiceName = "auth.v1.AuthService";
@@ -183,12 +371,19 @@ export class AuthServiceClientImpl implements AuthService {
183
371
  this.service = opts?.service || AuthServiceServiceName;
184
372
  this.rpc = rpc;
185
373
  this.SendOtp = this.SendOtp.bind(this);
374
+ this.VerifyOtp = this.VerifyOtp.bind(this);
186
375
  }
187
376
  SendOtp(request: SendOtpRequest): Promise<SendOtpResponse> {
188
377
  const data = SendOtpRequest.encode(request).finish();
189
378
  const promise = this.rpc.request(this.service, "SendOtp", data);
190
379
  return promise.then((data) => SendOtpResponse.decode(new BinaryReader(data)));
191
380
  }
381
+
382
+ VerifyOtp(request: VerifyOtpRequest): Promise<VerifyOtpResponse> {
383
+ const data = VerifyOtpRequest.encode(request).finish();
384
+ const promise = this.rpc.request(this.service, "VerifyOtp", data);
385
+ return promise.then((data) => VerifyOtpResponse.decode(new BinaryReader(data)));
386
+ }
192
387
  }
193
388
 
194
389
  interface Rpc {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nemma-training/contracts",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Protobuf contract definitions for Nemma microservices",
5
5
  "scripts": {
6
6
  "generate": "mkdir -p gen && protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestjs=true,package=omit"
package/proto/auth.proto CHANGED
@@ -4,6 +4,7 @@ package auth.v1;
4
4
 
5
5
  service AuthService {
6
6
  rpc SendOtp (SendOtpRequest) returns (SendOtpResponse);
7
+ rpc VerifyOtp (VerifyOtpRequest) returns (VerifyOtpResponse);
7
8
  }
8
9
 
9
10
  message SendOtpRequest {
@@ -16,3 +17,13 @@ message SendOtpResponse {
16
17
  string message = 2;
17
18
  }
18
19
 
20
+ message VerifyOtpRequest {
21
+ string identifier = 1;
22
+ string type = 2;
23
+ string code = 3;
24
+ }
25
+
26
+ message VerifyOtpResponse {
27
+ string access_token = 1;
28
+ string refresh_token = 2;
29
+ }