@getastro/contracts 1.0.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.
@@ -0,0 +1 @@
1
+ export * from "./proto";
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./proto"), exports);
@@ -0,0 +1 @@
1
+ export * from "./paths";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./paths"), exports);
@@ -0,0 +1,3 @@
1
+ export declare const PROTO_PATHS: {
2
+ readonly AUTH: string;
3
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PROTO_PATHS = void 0;
4
+ const path_1 = require("path");
5
+ exports.PROTO_PATHS = {
6
+ AUTH: (0, path_1.join)(__dirname, '../../proto/auth.proto'),
7
+ };
package/gen/auth.ts ADDED
@@ -0,0 +1,74 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.2
4
+ // protoc v3.21.12
5
+ // source: auth.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "auth.v1";
12
+
13
+ export interface SendOtpRequest {
14
+ identifier: string;
15
+ type: string;
16
+ }
17
+
18
+ export interface SendOtpResponse {
19
+ ok: boolean;
20
+ }
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
+
33
+ export const AUTH_V1_PACKAGE_NAME = "auth.v1";
34
+
35
+ /** Сервис аутентификации для управления одноразовыми паролями (OTP) и токенами. */
36
+
37
+ export interface AuthServiceClient {
38
+ /** Отправляет код подтверждения на указанный идентификатор (email/phone). */
39
+
40
+ sendOtp(request: SendOtpRequest): Observable<SendOtpResponse>;
41
+
42
+ /** Проверяет код и возвращает пару JWT токенов при успехе. */
43
+
44
+ verifyOtp(request: VerifyOtpRequest): Observable<VerifyOtpResponse>;
45
+ }
46
+
47
+ /** Сервис аутентификации для управления одноразовыми паролями (OTP) и токенами. */
48
+
49
+ export interface AuthServiceController {
50
+ /** Отправляет код подтверждения на указанный идентификатор (email/phone). */
51
+
52
+ sendOtp(request: SendOtpRequest): Promise<SendOtpResponse> | Observable<SendOtpResponse> | SendOtpResponse;
53
+
54
+ /** Проверяет код и возвращает пару JWT токенов при успехе. */
55
+
56
+ verifyOtp(request: VerifyOtpRequest): Promise<VerifyOtpResponse> | Observable<VerifyOtpResponse> | VerifyOtpResponse;
57
+ }
58
+
59
+ export function AuthServiceControllerMethods() {
60
+ return function (constructor: Function) {
61
+ const grpcMethods: string[] = ["sendOtp", "verifyOtp"];
62
+ for (const method of grpcMethods) {
63
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
64
+ GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
65
+ }
66
+ const grpcStreamMethods: string[] = [];
67
+ for (const method of grpcStreamMethods) {
68
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
69
+ GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
70
+ }
71
+ };
72
+ }
73
+
74
+ export const AUTH_SERVICE_NAME = "AuthService";
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@getastro/contracts",
3
+ "version": "1.0.0",
4
+ "description": "Protobuf definitions and generated TypeScript types",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc -p tsconfig.build.json",
9
+ "generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "proto",
14
+ "gen"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "dependencies": {
20
+ "@nestjs/microservices": "^11.1.14",
21
+ "rxjs": "^7.8.2",
22
+ "ts-proto": "^2.11.2"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^25.3.2",
26
+ "typescript": "^5.9.3"
27
+ }
28
+ }
@@ -0,0 +1,32 @@
1
+ syntax = "proto3";
2
+
3
+ package auth.v1;
4
+
5
+ // Сервис аутентификации для управления одноразовыми паролями (OTP) и токенами.
6
+ service AuthService {
7
+ // Отправляет код подтверждения на указанный идентификатор (email/phone).
8
+ rpc SendOtp (SendOtpRequest) returns (SendOtpResponse);
9
+
10
+ // Проверяет код и возвращает пару JWT токенов при успехе.
11
+ rpc VerifyOtp (VerifyOtpRequest) returns (VerifyOtpResponse);
12
+ }
13
+
14
+ message SendOtpRequest {
15
+ string identifier = 1;
16
+ string type = 2;
17
+ }
18
+
19
+ message SendOtpResponse {
20
+ bool ok = 1;
21
+ }
22
+
23
+ message VerifyOtpRequest {
24
+ string identifier = 1;
25
+ string type = 2;
26
+ string code = 3;
27
+ }
28
+
29
+ message VerifyOtpResponse {
30
+ string access_token = 1;
31
+ string refresh_token = 2;
32
+ }