@vsniksnet/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,4 @@
1
+ export declare const PROTO_PATHS: {
2
+ readonly AUTH: string;
3
+ readonly ACCOUNT: string;
4
+ };
@@ -0,0 +1,8 @@
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
+ ACCOUNT: (0, path_1.join)(__dirname, '../../proto/account.proto'),
8
+ };
package/gen/account.ts ADDED
@@ -0,0 +1,160 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.4
4
+ // protoc v6.33.1
5
+ // source: account.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "account.v1";
12
+
13
+ export interface ChangeTwoFactorRequest {
14
+ isTwoFactor: boolean;
15
+ userId: string;
16
+ }
17
+
18
+ export interface ChangeTwoFactorResponse {
19
+ ok: boolean;
20
+ }
21
+
22
+ export interface ChangePasswordRequest {
23
+ oldPassword: string;
24
+ newPassword: string;
25
+ userId: string;
26
+ }
27
+
28
+ export interface ChangePasswordResponse {
29
+ ok: boolean;
30
+ }
31
+
32
+ export interface InitEmailChangeRequest {
33
+ email: string;
34
+ userId: string;
35
+ }
36
+
37
+ export interface InitEmailChangeResponse {
38
+ ok: boolean;
39
+ }
40
+
41
+ export interface ConfirmEmailChangeRequest {
42
+ email: string;
43
+ code: string;
44
+ userId: string;
45
+ }
46
+
47
+ export interface ConfirmEmailChangeResponse {
48
+ ok: boolean;
49
+ }
50
+
51
+ export interface InitPasswordResetRequest {
52
+ email: string;
53
+ }
54
+
55
+ export interface InitPasswordResetResponse {
56
+ ok: boolean;
57
+ }
58
+
59
+ export interface ConfirmPasswirdResetRequest {
60
+ password: string;
61
+ code: string;
62
+ }
63
+
64
+ export interface ConfirmPasswirdResetResponse {
65
+ ok: boolean;
66
+ }
67
+
68
+ export const ACCOUNT_V1_PACKAGE_NAME = "account.v1";
69
+
70
+ /** * User account service */
71
+
72
+ export interface AccountServiceClient {
73
+ /** Switch two factor authentication */
74
+
75
+ changeTwoFactor(request: ChangeTwoFactorRequest): Observable<ChangeTwoFactorResponse>;
76
+
77
+ /** Change User Password */
78
+
79
+ changePassword(request: ChangePasswordRequest): Observable<ChangePasswordResponse>;
80
+
81
+ /** Init email change */
82
+
83
+ initEmailChange(request: InitEmailChangeRequest): Observable<InitEmailChangeResponse>;
84
+
85
+ /** Confirn email change */
86
+
87
+ confirmEmailChange(request: ConfirmEmailChangeRequest): Observable<ConfirmEmailChangeResponse>;
88
+
89
+ /** Init password reset */
90
+
91
+ initPasswordReset(request: InitPasswordResetRequest): Observable<InitPasswordResetResponse>;
92
+
93
+ /** Confirm password reset */
94
+
95
+ confirmPasswirdReset(request: ConfirmPasswirdResetRequest): Observable<ConfirmPasswirdResetResponse>;
96
+ }
97
+
98
+ /** * User account service */
99
+
100
+ export interface AccountServiceController {
101
+ /** Switch two factor authentication */
102
+
103
+ changeTwoFactor(
104
+ request: ChangeTwoFactorRequest,
105
+ ): Promise<ChangeTwoFactorResponse> | Observable<ChangeTwoFactorResponse> | ChangeTwoFactorResponse;
106
+
107
+ /** Change User Password */
108
+
109
+ changePassword(
110
+ request: ChangePasswordRequest,
111
+ ): Promise<ChangePasswordResponse> | Observable<ChangePasswordResponse> | ChangePasswordResponse;
112
+
113
+ /** Init email change */
114
+
115
+ initEmailChange(
116
+ request: InitEmailChangeRequest,
117
+ ): Promise<InitEmailChangeResponse> | Observable<InitEmailChangeResponse> | InitEmailChangeResponse;
118
+
119
+ /** Confirn email change */
120
+
121
+ confirmEmailChange(
122
+ request: ConfirmEmailChangeRequest,
123
+ ): Promise<ConfirmEmailChangeResponse> | Observable<ConfirmEmailChangeResponse> | ConfirmEmailChangeResponse;
124
+
125
+ /** Init password reset */
126
+
127
+ initPasswordReset(
128
+ request: InitPasswordResetRequest,
129
+ ): Promise<InitPasswordResetResponse> | Observable<InitPasswordResetResponse> | InitPasswordResetResponse;
130
+
131
+ /** Confirm password reset */
132
+
133
+ confirmPasswirdReset(
134
+ request: ConfirmPasswirdResetRequest,
135
+ ): Promise<ConfirmPasswirdResetResponse> | Observable<ConfirmPasswirdResetResponse> | ConfirmPasswirdResetResponse;
136
+ }
137
+
138
+ export function AccountServiceControllerMethods() {
139
+ return function (constructor: Function) {
140
+ const grpcMethods: string[] = [
141
+ "changeTwoFactor",
142
+ "changePassword",
143
+ "initEmailChange",
144
+ "confirmEmailChange",
145
+ "initPasswordReset",
146
+ "confirmPasswirdReset",
147
+ ];
148
+ for (const method of grpcMethods) {
149
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
150
+ GrpcMethod("AccountService", method)(constructor.prototype[method], method, descriptor);
151
+ }
152
+ const grpcStreamMethods: string[] = [];
153
+ for (const method of grpcStreamMethods) {
154
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
155
+ GrpcStreamMethod("AccountService", method)(constructor.prototype[method], method, descriptor);
156
+ }
157
+ };
158
+ }
159
+
160
+ export const ACCOUNT_SERVICE_NAME = "AccountService";
package/gen/auth.ts ADDED
@@ -0,0 +1,93 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.4
4
+ // protoc v6.33.1
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 LoginRequest {
14
+ email: string;
15
+ password: string;
16
+ code?: string | undefined;
17
+ }
18
+
19
+ export interface LoginResponse {
20
+ isTwoFactor: boolean;
21
+ accessToken: string;
22
+ refreshToken: string;
23
+ }
24
+
25
+ export interface SignupRequest {
26
+ username: string;
27
+ email: string;
28
+ password: string;
29
+ }
30
+
31
+ export interface SignupResponse {
32
+ ok: boolean;
33
+ }
34
+
35
+ export interface RefreshRequest {
36
+ refreshToken: string;
37
+ }
38
+
39
+ export interface RefreshResponse {
40
+ accessToken: string;
41
+ refreshToken: string;
42
+ }
43
+
44
+ export const AUTH_V1_PACKAGE_NAME = "auth.v1";
45
+
46
+ /** Authentication service */
47
+
48
+ export interface AuthServiceClient {
49
+ /** Login user */
50
+
51
+ login(request: LoginRequest): Observable<LoginResponse>;
52
+
53
+ /** Signup user */
54
+
55
+ signup(request: SignupRequest): Observable<SignupResponse>;
56
+
57
+ /** Refresh token */
58
+
59
+ refresh(request: RefreshRequest): Observable<RefreshResponse>;
60
+ }
61
+
62
+ /** Authentication service */
63
+
64
+ export interface AuthServiceController {
65
+ /** Login user */
66
+
67
+ login(request: LoginRequest): Promise<LoginResponse> | Observable<LoginResponse> | LoginResponse;
68
+
69
+ /** Signup user */
70
+
71
+ signup(request: SignupRequest): Promise<SignupResponse> | Observable<SignupResponse> | SignupResponse;
72
+
73
+ /** Refresh token */
74
+
75
+ refresh(request: RefreshRequest): Promise<RefreshResponse> | Observable<RefreshResponse> | RefreshResponse;
76
+ }
77
+
78
+ export function AuthServiceControllerMethods() {
79
+ return function (constructor: Function) {
80
+ const grpcMethods: string[] = ["login", "signup", "refresh"];
81
+ for (const method of grpcMethods) {
82
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
83
+ GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
84
+ }
85
+ const grpcStreamMethods: string[] = [];
86
+ for (const method of grpcStreamMethods) {
87
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
88
+ GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
89
+ }
90
+ };
91
+ }
92
+
93
+ export const AUTH_SERVICE_NAME = "AuthService";
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@vsniksnet/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.4"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^25.3.3",
26
+ "typescript": "^5.9.3"
27
+ }
28
+ }
@@ -0,0 +1,84 @@
1
+ syntax = "proto3";
2
+
3
+ package account.v1;
4
+
5
+ /*** User account service */
6
+ service AccountService {
7
+ /** Switch two factor authentication */
8
+ rpc ChangeTwoFactor (ChangeTwoFactorRequest) returns (ChangeTwoFactorResponse);
9
+
10
+ /** Change User Password */
11
+ rpc ChangePassword (ChangePasswordRequest) returns (ChangePasswordResponse);
12
+
13
+ /** Init email change */
14
+ rpc InitEmailChange (InitEmailChangeRequest) returns (InitEmailChangeResponse);
15
+
16
+ /** Confirn email change */
17
+ rpc ConfirmEmailChange (ConfirmEmailChangeRequest) returns (ConfirmEmailChangeResponse);
18
+
19
+ /** Init password reset */
20
+ rpc InitPasswordReset (InitPasswordResetRequest) returns (InitPasswordResetResponse);
21
+
22
+ /** Confirm password reset */
23
+ rpc ConfirmPasswirdReset (ConfirmPasswirdResetRequest) returns (ConfirmPasswirdResetResponse);
24
+ }
25
+
26
+ message ChangeTwoFactorRequest {
27
+ bool is_two_factor = 1;
28
+ string user_id = 2;
29
+ }
30
+
31
+ message ChangeTwoFactorResponse {
32
+ bool ok = 1;
33
+ }
34
+
35
+
36
+ message ChangePasswordRequest {
37
+ string old_password = 1;
38
+ string new_password = 2;
39
+ string user_id = 3;
40
+ }
41
+
42
+ message ChangePasswordResponse {
43
+ bool ok = 1;
44
+ }
45
+
46
+
47
+ message InitEmailChangeRequest {
48
+ string email = 1;
49
+ string user_id = 2;
50
+ }
51
+
52
+ message InitEmailChangeResponse {
53
+ bool ok = 1;
54
+ }
55
+
56
+
57
+ message ConfirmEmailChangeRequest {
58
+ string email = 1;
59
+ string code = 2;
60
+ string user_id = 3;
61
+ }
62
+
63
+ message ConfirmEmailChangeResponse {
64
+ bool ok = 1;
65
+ }
66
+
67
+
68
+ message InitPasswordResetRequest {
69
+ string email = 1;
70
+ }
71
+
72
+ message InitPasswordResetResponse {
73
+ bool ok = 1;
74
+ }
75
+
76
+
77
+ message ConfirmPasswirdResetRequest {
78
+ string password = 1;
79
+ string code = 2;
80
+ }
81
+
82
+ message ConfirmPasswirdResetResponse {
83
+ bool ok = 1;
84
+ }
@@ -0,0 +1,46 @@
1
+ syntax = "proto3";
2
+
3
+ package auth.v1;
4
+
5
+ /** Authentication service */
6
+ service AuthService {
7
+ /** Login user */
8
+ rpc Login (LoginRequest) returns (LoginResponse);
9
+
10
+ /** Signup user */
11
+ rpc Signup (SignupRequest) returns (SignupResponse);
12
+
13
+ /** Refresh token */
14
+ rpc Refresh (RefreshRequest) returns (RefreshResponse);
15
+ }
16
+
17
+ message LoginRequest {
18
+ string email = 1;
19
+ string password = 2;
20
+ optional string code = 3;
21
+ }
22
+
23
+ message LoginResponse {
24
+ bool is_two_factor = 1;
25
+ string access_token = 2;
26
+ string refresh_token = 3;
27
+ }
28
+
29
+ message SignupRequest {
30
+ string username = 1;
31
+ string email = 2;
32
+ string password = 3;
33
+ }
34
+
35
+ message SignupResponse {
36
+ bool ok = 1;
37
+ }
38
+
39
+ message RefreshRequest {
40
+ string refresh_token = 1;
41
+ }
42
+
43
+ message RefreshResponse {
44
+ string access_token = 1;
45
+ string refresh_token = 2;
46
+ }