@xwing-dev/shared 1.0.8 → 1.0.10
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/dist/contracts/gen/auth.d.ts +29 -0
- package/dist/contracts/gen/auth.js +23 -0
- package/dist/contracts/gen/auth.js.map +1 -0
- package/dist/exceptions/rpc/index.d.ts +2 -0
- package/{src/exceptions/rpc/rpc-status.enum.ts → dist/exceptions/rpc/rpc-status.enum.d.ts} +3 -3
- package/dist/exceptions/rpc/rpc.exception.d.ts +32 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/package.json +6 -9
- package/src/contracts/gen/auth.ts +0 -66
- package/src/contracts/proto/auth.proto +0 -28
- package/src/exceptions/rpc/index.ts +0 -2
- package/src/exceptions/rpc/rpc.exception.ts +0 -53
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
export declare const protobufPackage = "auth.v1";
|
|
3
|
+
export interface SendOtpRequestDto {
|
|
4
|
+
identifier: string;
|
|
5
|
+
type: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SendOtpResponseDto {
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
export interface VerifyOtpRequestDto {
|
|
11
|
+
identifier: string;
|
|
12
|
+
type: string;
|
|
13
|
+
code: string;
|
|
14
|
+
}
|
|
15
|
+
export interface VerifyOtpResponseDto {
|
|
16
|
+
accessToken: string;
|
|
17
|
+
refreshToken: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const AUTH_V1_PACKAGE_NAME = "auth.v1";
|
|
20
|
+
export interface AuthServiceClient {
|
|
21
|
+
sendOtp(request: SendOtpRequestDto): Observable<SendOtpResponseDto>;
|
|
22
|
+
verifyOtp(request: VerifyOtpRequestDto): Observable<VerifyOtpResponseDto>;
|
|
23
|
+
}
|
|
24
|
+
export interface AuthServiceController {
|
|
25
|
+
sendOtp(request: SendOtpRequestDto): Promise<SendOtpResponseDto> | Observable<SendOtpResponseDto> | SendOtpResponseDto;
|
|
26
|
+
verifyOtp(request: VerifyOtpRequestDto): Promise<VerifyOtpResponseDto> | Observable<VerifyOtpResponseDto> | VerifyOtpResponseDto;
|
|
27
|
+
}
|
|
28
|
+
export declare function AuthServiceControllerMethods(): (constructor: Function) => void;
|
|
29
|
+
export declare const AUTH_SERVICE_NAME = "AuthService";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUTH_SERVICE_NAME = exports.AUTH_V1_PACKAGE_NAME = exports.protobufPackage = void 0;
|
|
4
|
+
exports.AuthServiceControllerMethods = AuthServiceControllerMethods;
|
|
5
|
+
const microservices_1 = require("@nestjs/microservices");
|
|
6
|
+
exports.protobufPackage = "auth.v1";
|
|
7
|
+
exports.AUTH_V1_PACKAGE_NAME = "auth.v1";
|
|
8
|
+
function AuthServiceControllerMethods() {
|
|
9
|
+
return function (constructor) {
|
|
10
|
+
const grpcMethods = ["sendOtp", "verifyOtp"];
|
|
11
|
+
for (const method of grpcMethods) {
|
|
12
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
13
|
+
(0, microservices_1.GrpcMethod)("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
14
|
+
}
|
|
15
|
+
const grpcStreamMethods = [];
|
|
16
|
+
for (const method of grpcStreamMethods) {
|
|
17
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
18
|
+
(0, microservices_1.GrpcStreamMethod)("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.AUTH_SERVICE_NAME = "AuthService";
|
|
23
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/contracts/gen/auth.ts"],"names":[],"mappings":";;;AAkDA,oEAaC;AAxDD,yDAAqE;AAGxD,QAAA,eAAe,GAAG,SAAS,CAAC;AAsB5B,QAAA,oBAAoB,GAAG,SAAS,CAAC;AAkB9C,SAAgB,4BAA4B;IAC1C,OAAO,UAAU,WAAqB;QACpC,MAAM,WAAW,GAAa,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACvD,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE,CAAC;YACjC,MAAM,UAAU,GAAQ,OAAO,CAAC,wBAAwB,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YACxF,IAAA,0BAAU,EAAC,aAAa,EAAE,MAAM,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QACvF,CAAC;QACD,MAAM,iBAAiB,GAAa,EAAE,CAAC;QACvC,KAAK,MAAM,MAAM,IAAI,iBAAiB,EAAE,CAAC;YACvC,MAAM,UAAU,GAAQ,OAAO,CAAC,wBAAwB,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YACxF,IAAA,gCAAgB,EAAC,aAAa,EAAE,MAAM,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAEY,QAAA,iBAAiB,GAAG,aAAa,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export enum RpcStatus {
|
|
1
|
+
export declare enum RpcStatus {
|
|
2
2
|
OK = 0,
|
|
3
3
|
CANCELLED = 1,
|
|
4
4
|
UNKNOWN = 2,
|
|
@@ -15,5 +15,5 @@ export enum RpcStatus {
|
|
|
15
15
|
INTERNAL = 13,
|
|
16
16
|
UNAVAILABLE = 14,
|
|
17
17
|
DATA_LOSS = 15,
|
|
18
|
-
UNAUTHENTICATED = 16
|
|
19
|
-
}
|
|
18
|
+
UNAUTHENTICATED = 16
|
|
19
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RpcException } from "@nestjs/microservices";
|
|
2
|
+
import { RpcStatus } from "./rpc-status.enum";
|
|
3
|
+
export declare enum RpcDefaultMessages {
|
|
4
|
+
NOT_FOUND = "Not found",
|
|
5
|
+
UNAUTHORIZED = "Unauthorized",
|
|
6
|
+
FORBIDDEN = "Forbidden",
|
|
7
|
+
INTERNAL_SERVER_ERROR = "Internal server error",
|
|
8
|
+
TOO_MANY_REQUESTS = "Too many requests",
|
|
9
|
+
BAD_REQUEST = "Bad request"
|
|
10
|
+
}
|
|
11
|
+
declare class BaseRpcException extends RpcException {
|
|
12
|
+
constructor(code: RpcStatus, message: string, data?: any);
|
|
13
|
+
}
|
|
14
|
+
export declare class BadRequestRpcException extends BaseRpcException {
|
|
15
|
+
constructor(message?: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class UnauthorizedRpcException extends BaseRpcException {
|
|
18
|
+
constructor(message?: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class ForbiddenRpcException extends BaseRpcException {
|
|
21
|
+
constructor(message?: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class NotFoundRpcException extends BaseRpcException {
|
|
24
|
+
constructor(message?: string);
|
|
25
|
+
}
|
|
26
|
+
export declare class TooManyRequestsRpcException extends BaseRpcException {
|
|
27
|
+
constructor(message?: string);
|
|
28
|
+
}
|
|
29
|
+
export declare class UnexpectedErrorRpcException extends BaseRpcException {
|
|
30
|
+
constructor(message?: string);
|
|
31
|
+
}
|
|
32
|
+
export {};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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("./contracts/gen/auth"), exports);
|
|
18
|
+
__exportStar(require("./exceptions/rpc"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,mDAAiC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xwing-dev/shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -21,20 +21,17 @@
|
|
|
21
21
|
},
|
|
22
22
|
"./biome": "./biome.json",
|
|
23
23
|
"./contracts/gen/auth": {
|
|
24
|
-
"types": "./
|
|
25
|
-
"import": "./
|
|
24
|
+
"types": "./dist/contracts/gen/auth.d.ts",
|
|
25
|
+
"import": "./dist/contracts/gen/auth.js"
|
|
26
26
|
},
|
|
27
27
|
"./exceptions/rpc": {
|
|
28
|
-
"types": "./
|
|
29
|
-
"import": "./
|
|
28
|
+
"types": "./dist/exceptions/rpc/index.d.ts",
|
|
29
|
+
"import": "./dist/exceptions/rpc/index.js"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"dist",
|
|
34
|
-
"biome.json"
|
|
35
|
-
"src/contracts/gen",
|
|
36
|
-
"src/contracts/proto",
|
|
37
|
-
"src/exceptions/rpc"
|
|
34
|
+
"biome.json"
|
|
38
35
|
],
|
|
39
36
|
"devDependencies": {
|
|
40
37
|
"ts-node": "^10.9.2",
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
-
// versions:
|
|
3
|
-
// protoc-gen-ts_proto v2.11.8
|
|
4
|
-
// protoc v4.25.9
|
|
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 SendOtpRequestDto {
|
|
14
|
-
identifier: string;
|
|
15
|
-
type: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface SendOtpResponseDto {
|
|
19
|
-
message: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface VerifyOtpRequestDto {
|
|
23
|
-
identifier: string;
|
|
24
|
-
type: string;
|
|
25
|
-
code: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface VerifyOtpResponseDto {
|
|
29
|
-
accessToken: string;
|
|
30
|
-
refreshToken: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const AUTH_V1_PACKAGE_NAME = "auth.v1";
|
|
34
|
-
|
|
35
|
-
export interface AuthServiceClient {
|
|
36
|
-
sendOtp(request: SendOtpRequestDto): Observable<SendOtpResponseDto>;
|
|
37
|
-
|
|
38
|
-
verifyOtp(request: VerifyOtpRequestDto): Observable<VerifyOtpResponseDto>;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface AuthServiceController {
|
|
42
|
-
sendOtp(
|
|
43
|
-
request: SendOtpRequestDto,
|
|
44
|
-
): Promise<SendOtpResponseDto> | Observable<SendOtpResponseDto> | SendOtpResponseDto;
|
|
45
|
-
|
|
46
|
-
verifyOtp(
|
|
47
|
-
request: VerifyOtpRequestDto,
|
|
48
|
-
): Promise<VerifyOtpResponseDto> | Observable<VerifyOtpResponseDto> | VerifyOtpResponseDto;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function AuthServiceControllerMethods() {
|
|
52
|
-
return function (constructor: Function) {
|
|
53
|
-
const grpcMethods: string[] = ["sendOtp", "verifyOtp"];
|
|
54
|
-
for (const method of grpcMethods) {
|
|
55
|
-
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
56
|
-
GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
57
|
-
}
|
|
58
|
-
const grpcStreamMethods: string[] = [];
|
|
59
|
-
for (const method of grpcStreamMethods) {
|
|
60
|
-
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
61
|
-
GrpcStreamMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const AUTH_SERVICE_NAME = "AuthService";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
package auth.v1;
|
|
4
|
-
|
|
5
|
-
service AuthService {
|
|
6
|
-
rpc SendOtp(SendOtpRequestDto) returns (SendOtpResponseDto);
|
|
7
|
-
rpc VerifyOtp(VerifyOtpRequestDto) returns (VerifyOtpResponseDto);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
message SendOtpRequestDto {
|
|
11
|
-
string identifier = 1;
|
|
12
|
-
string type = 2;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
message SendOtpResponseDto {
|
|
16
|
-
string message = 1;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
message VerifyOtpRequestDto {
|
|
20
|
-
string identifier = 1;
|
|
21
|
-
string type = 2;
|
|
22
|
-
string code = 3;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
message VerifyOtpResponseDto {
|
|
26
|
-
string access_token = 1;
|
|
27
|
-
string refresh_token = 2;
|
|
28
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { RpcException } from "@nestjs/microservices";
|
|
2
|
-
import { RpcStatus } from "./rpc-status.enum";
|
|
3
|
-
|
|
4
|
-
export enum RpcDefaultMessages {
|
|
5
|
-
NOT_FOUND = "Not found",
|
|
6
|
-
UNAUTHORIZED = "Unauthorized",
|
|
7
|
-
FORBIDDEN = "Forbidden",
|
|
8
|
-
INTERNAL_SERVER_ERROR = "Internal server error",
|
|
9
|
-
TOO_MANY_REQUESTS = "Too many requests",
|
|
10
|
-
BAD_REQUEST = "Bad request",
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
class BaseRpcException extends RpcException {
|
|
14
|
-
constructor(code: RpcStatus, message: string, data?: any) {
|
|
15
|
-
super({ code, details: message, data });
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class BadRequestRpcException extends BaseRpcException {
|
|
20
|
-
constructor(message: string = RpcDefaultMessages.BAD_REQUEST) {
|
|
21
|
-
super(RpcStatus.INVALID_ARGUMENT, message);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class UnauthorizedRpcException extends BaseRpcException {
|
|
26
|
-
constructor(message: string = RpcDefaultMessages.UNAUTHORIZED) {
|
|
27
|
-
super(RpcStatus.UNAUTHENTICATED, message);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class ForbiddenRpcException extends BaseRpcException {
|
|
32
|
-
constructor(message: string = RpcDefaultMessages.FORBIDDEN) {
|
|
33
|
-
super(RpcStatus.PERMISSION_DENIED, message);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export class NotFoundRpcException extends BaseRpcException {
|
|
38
|
-
constructor(message: string = RpcDefaultMessages.NOT_FOUND) {
|
|
39
|
-
super(RpcStatus.NOT_FOUND, message);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export class TooManyRequestsRpcException extends BaseRpcException {
|
|
44
|
-
constructor(message: string = RpcDefaultMessages.TOO_MANY_REQUESTS) {
|
|
45
|
-
super(RpcStatus.RESOURCE_EXHAUSTED, message);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export class UnexpectedErrorRpcException extends BaseRpcException {
|
|
50
|
-
constructor(message: string = RpcDefaultMessages.INTERNAL_SERVER_ERROR) {
|
|
51
|
-
super(RpcStatus.INTERNAL, message);
|
|
52
|
-
}
|
|
53
|
-
}
|