briyah 1.0.1 → 1.0.3
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/server/src/ai/LLM/deepseek.service.js +1 -1
- package/package.json +2 -2
- package/dist/ai/LLM/anthropic.module.d.ts +0 -2
- package/dist/ai/LLM/anthropic.module.js +0 -21
- package/dist/ai/LLM/anthropic.service.d.ts +0 -27
- package/dist/ai/LLM/anthropic.service.js +0 -329
- package/dist/ai/LLM/base-ai.service.d.ts +0 -45
- package/dist/ai/LLM/base-ai.service.js +0 -409
- package/dist/ai/LLM/deepseek.module.d.ts +0 -2
- package/dist/ai/LLM/deepseek.module.js +0 -21
- package/dist/ai/LLM/deepseek.service.d.ts +0 -15
- package/dist/ai/LLM/deepseek.service.js +0 -279
- package/dist/ai/LLM/fal.module.d.ts +0 -2
- package/dist/ai/LLM/fal.module.js +0 -21
- package/dist/ai/LLM/fal.service.d.ts +0 -17
- package/dist/ai/LLM/fal.service.js +0 -314
- package/dist/ai/LLM/googleai.module.d.ts +0 -2
- package/dist/ai/LLM/googleai.module.js +0 -21
- package/dist/ai/LLM/googleai.service.d.ts +0 -20
- package/dist/ai/LLM/googleai.service.js +0 -271
- package/dist/ai/LLM/grok.module.d.ts +0 -2
- package/dist/ai/LLM/grok.module.js +0 -21
- package/dist/ai/LLM/grok.service.d.ts +0 -14
- package/dist/ai/LLM/grok.service.js +0 -263
- package/dist/ai/LLM/mock.module.d.ts +0 -2
- package/dist/ai/LLM/mock.module.js +0 -21
- package/dist/ai/LLM/mock.service.d.ts +0 -13
- package/dist/ai/LLM/mock.service.js +0 -194
- package/dist/ai/LLM/openai.module.d.ts +0 -2
- package/dist/ai/LLM/openai.module.js +0 -21
- package/dist/ai/LLM/openai.service.d.ts +0 -21
- package/dist/ai/LLM/openai.service.js +0 -421
- package/dist/ai/LLM/together.module.d.ts +0 -2
- package/dist/ai/LLM/together.module.js +0 -21
- package/dist/ai/LLM/together.service.d.ts +0 -18
- package/dist/ai/LLM/together.service.js +0 -285
- package/dist/ai/LLM/vertexai.module.d.ts +0 -2
- package/dist/ai/LLM/vertexai.module.js +0 -21
- package/dist/ai/LLM/vertexai.service.d.ts +0 -17
- package/dist/ai/LLM/vertexai.service.js +0 -323
- package/dist/ai/agent-config.d.ts +0 -32
- package/dist/ai/agent-config.js +0 -2
- package/dist/ai/agent-factory.d.ts +0 -15
- package/dist/ai/agent-factory.js +0 -24
- package/dist/ai/agent-message.service.d.ts +0 -9
- package/dist/ai/agent-message.service.js +0 -56
- package/dist/ai/agent-store.module.d.ts +0 -2
- package/dist/ai/agent-store.module.js +0 -21
- package/dist/ai/agent-store.service.d.ts +0 -31
- package/dist/ai/agent-store.service.js +0 -352
- package/dist/ai/agent.d.ts +0 -75
- package/dist/ai/agent.js +0 -174
- package/dist/ai/ai-factory.module.d.ts +0 -2
- package/dist/ai/ai-factory.module.js +0 -40
- package/dist/ai/ai-factory.service.d.ts +0 -24
- package/dist/ai/ai-factory.service.js +0 -94
- package/dist/ai/artifact.module.d.ts +0 -2
- package/dist/ai/artifact.module.js +0 -22
- package/dist/ai/artifact.service.d.ts +0 -21
- package/dist/ai/artifact.service.js +0 -239
- package/dist/ai/attached-file.module.d.ts +0 -2
- package/dist/ai/attached-file.module.js +0 -22
- package/dist/ai/attached-file.service.d.ts +0 -35
- package/dist/ai/attached-file.service.js +0 -253
- package/dist/ai/model_prices.d.ts +0 -2
- package/dist/ai/model_prices.js +0 -54
- package/dist/ai/published-agents.service.d.ts +0 -13
- package/dist/ai/published-agents.service.js +0 -118
- package/dist/app/balance-message.service.d.ts +0 -8
- package/dist/app/balance-message.service.js +0 -45
- package/dist/app/balance.module.d.ts +0 -2
- package/dist/app/balance.module.js +0 -20
- package/dist/app/balance.service.d.ts +0 -18
- package/dist/app/balance.service.js +0 -158
- package/dist/app/stripe.controller.d.ts +0 -31
- package/dist/app/stripe.controller.js +0 -150
- package/dist/app/stripe.module.d.ts +0 -2
- package/dist/app/stripe.module.js +0 -22
- package/dist/app/stripe.service.d.ts +0 -28
- package/dist/app/stripe.service.js +0 -198
- package/dist/app/transaction.service.d.ts +0 -15
- package/dist/app/transaction.service.js +0 -139
- package/dist/app/user-service-factory.d.ts +0 -21
- package/dist/app/user-service-factory.js +0 -81
- package/dist/app/user-service-manager.d.ts +0 -28
- package/dist/app/user-service-manager.js +0 -102
- package/dist/app.controller.d.ts +0 -232
- package/dist/app.controller.js +0 -2536
- package/dist/app.module.d.ts +0 -2
- package/dist/app.module.js +0 -45
- package/dist/app.service.d.ts +0 -186
- package/dist/app.service.js +0 -1334
- package/dist/auth/agent-access.decorator.d.ts +0 -2
- package/dist/auth/agent-access.decorator.js +0 -10
- package/dist/auth/auth.controller.d.ts +0 -38
- package/dist/auth/auth.controller.js +0 -356
- package/dist/auth/auth.module.d.ts +0 -2
- package/dist/auth/auth.module.js +0 -55
- package/dist/auth/auth.service.d.ts +0 -14
- package/dist/auth/auth.service.js +0 -84
- package/dist/auth/dto/bot-login.dto.d.ts +0 -4
- package/dist/auth/dto/bot-login.dto.js +0 -2
- package/dist/auth/dto/password-reset.dto.d.ts +0 -11
- package/dist/auth/dto/password-reset.dto.js +0 -2
- package/dist/auth/dto/phone-login.dto.d.ts +0 -8
- package/dist/auth/dto/phone-login.dto.js +0 -2
- package/dist/auth/dto/phone-verification.dto.d.ts +0 -9
- package/dist/auth/dto/phone-verification.dto.js +0 -2
- package/dist/auth/jwt-auth.guard.d.ts +0 -13
- package/dist/auth/jwt-auth.guard.js +0 -143
- package/dist/auth/jwt.strategy.d.ts +0 -17
- package/dist/auth/jwt.strategy.js +0 -45
- package/dist/auth/phone-validation.service.d.ts +0 -7
- package/dist/auth/phone-validation.service.js +0 -50
- package/dist/auth/public.decorator.d.ts +0 -2
- package/dist/auth/public.decorator.js +0 -7
- package/dist/auth/rate-limit.service.d.ts +0 -16
- package/dist/auth/rate-limit.service.js +0 -84
- package/dist/auth/room-access.decorator.d.ts +0 -2
- package/dist/auth/room-access.decorator.js +0 -10
- package/dist/auth/scopes.decorator.d.ts +0 -2
- package/dist/auth/scopes.decorator.js +0 -7
- package/dist/auth/scopes.guard.d.ts +0 -9
- package/dist/auth/scopes.guard.js +0 -82
- package/dist/auth/session.guard.d.ts +0 -7
- package/dist/auth/session.guard.js +0 -55
- package/dist/auth/twilio.service.d.ts +0 -15
- package/dist/auth/twilio.service.js +0 -139
- package/dist/auth/users.service.d.ts +0 -24
- package/dist/auth/users.service.js +0 -149
- package/dist/common/errors.d.ts +0 -12
- package/dist/common/errors.js +0 -43
- package/dist/config/configuration.module.d.ts +0 -2
- package/dist/config/configuration.module.js +0 -20
- package/dist/config/configuration.service.d.ts +0 -26
- package/dist/config/configuration.service.js +0 -131
- package/dist/main.js +0 -15749
- package/dist/room/artifact-store.service.d.ts +0 -15
- package/dist/room/artifact-store.service.js +0 -226
- package/dist/room/artifact.d.ts +0 -6
- package/dist/room/artifact.js +0 -2
- package/dist/room/message.d.ts +0 -19
- package/dist/room/message.js +0 -70
- package/dist/room/published-rooms.service.d.ts +0 -12
- package/dist/room/published-rooms.service.js +0 -108
- package/dist/room/room-config.d.ts +0 -12
- package/dist/room/room-config.js +0 -2
- package/dist/room/room-factory.d.ts +0 -7
- package/dist/room/room-factory.js +0 -16
- package/dist/room/room-message.module.d.ts +0 -2
- package/dist/room/room-message.module.js +0 -21
- package/dist/room/room-message.service.d.ts +0 -8
- package/dist/room/room-message.service.js +0 -44
- package/dist/room/room-store.module.d.ts +0 -2
- package/dist/room/room-store.module.js +0 -25
- package/dist/room/room-store.service.d.ts +0 -38
- package/dist/room/room-store.service.js +0 -353
- package/dist/room/room.d.ts +0 -107
- package/dist/room/room.js +0 -833
- package/dist/sdk/briyah-config.d.ts +0 -13
- package/dist/sdk/briyah-config.js +0 -32
- package/dist/sdk/briyah.d.ts +0 -36
- package/dist/sdk/briyah.js +0 -122
- package/dist/sdk/index.d.ts +0 -6
- package/dist/sdk/index.js +0 -11
- package/dist/shared/shared.module.d.ts +0 -2
- package/dist/shared/shared.module.js +0 -46
- package/dist/story/story-message.service.d.ts +0 -10
- package/dist/story/story-message.service.js +0 -57
- package/dist/story/story-progress.service.d.ts +0 -8
- package/dist/story/story-progress.service.js +0 -44
- package/dist/story/story-store.module.d.ts +0 -2
- package/dist/story/story-store.module.js +0 -22
- package/dist/story/story-store.service.d.ts +0 -23
- package/dist/story/story-store.service.js +0 -392
- package/dist/story/story.service.d.ts +0 -94
- package/dist/story/story.service.js +0 -1797
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TwilioService = void 0;
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const config_1 = require("@nestjs/config");
|
|
15
|
-
let TwilioService = class TwilioService {
|
|
16
|
-
configService;
|
|
17
|
-
TWILIO_ACCOUNT_SID;
|
|
18
|
-
TWILIO_AUTH_TOKEN;
|
|
19
|
-
TWILIO_API_URL;
|
|
20
|
-
TWILIO_PHONE;
|
|
21
|
-
TWILIO_VERIFY_SID;
|
|
22
|
-
constructor(configService) {
|
|
23
|
-
this.configService = configService;
|
|
24
|
-
this.TWILIO_ACCOUNT_SID = this.configService.get('TWILIO_ACCOUNT_SID');
|
|
25
|
-
this.TWILIO_AUTH_TOKEN = this.configService.get('TWILIO_AUTH_TOKEN');
|
|
26
|
-
this.TWILIO_API_URL = this.configService.get('TWILIO_API_URL');
|
|
27
|
-
this.TWILIO_PHONE = this.configService.get('TWILIO_PHONE');
|
|
28
|
-
this.TWILIO_VERIFY_SID = this.configService.get('TWILIO_VERIFY_SID');
|
|
29
|
-
if (process.env.NODE_ENV === 'production' && process.env.TEST_MODE === 'true') {
|
|
30
|
-
throw new Error('TEST_MODE cannot be enabled in production environment');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async sendVerification(to, channel = 'sms') {
|
|
34
|
-
if (this.isTestMode() && this.isTestPhoneNumber(to)) {
|
|
35
|
-
console.log(`[TEST MODE] Skipping OTP send for test number: ${to}`);
|
|
36
|
-
return { status: 'pending', to: `+1${to}` };
|
|
37
|
-
}
|
|
38
|
-
const dialPrefix = '+1';
|
|
39
|
-
const toPhone = dialPrefix + to;
|
|
40
|
-
const url = `https://verify.twilio.com/v2/Services/${this.TWILIO_VERIFY_SID}/Verifications`;
|
|
41
|
-
const params = new URLSearchParams();
|
|
42
|
-
params.append('To', toPhone);
|
|
43
|
-
params.append('Channel', channel);
|
|
44
|
-
const auth = Buffer.from(`${this.TWILIO_ACCOUNT_SID}:${this.TWILIO_AUTH_TOKEN}`).toString('base64');
|
|
45
|
-
try {
|
|
46
|
-
const response = await fetch(url, {
|
|
47
|
-
method: 'POST',
|
|
48
|
-
headers: {
|
|
49
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
50
|
-
Authorization: `Basic ${auth}`,
|
|
51
|
-
},
|
|
52
|
-
body: params,
|
|
53
|
-
});
|
|
54
|
-
if (!response.ok) {
|
|
55
|
-
const errorText = await response.text();
|
|
56
|
-
throw new Error(`HTTP ${response.status}: ${errorText}`);
|
|
57
|
-
}
|
|
58
|
-
return await response.json();
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
throw new Error(`Failed to send verification: ${error.message}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
async checkVerification(to, code) {
|
|
65
|
-
if (this.isTestMode() && this.isTestPhoneNumber(to)) {
|
|
66
|
-
if (code.length === 6 && /^\d{6}$/.test(code)) {
|
|
67
|
-
console.log(`[TEST MODE] Accepting test code for: ${to}`);
|
|
68
|
-
return { status: 'approved', valid: true };
|
|
69
|
-
}
|
|
70
|
-
console.log(`[TEST MODE] Rejecting invalid test code format for: ${to}`);
|
|
71
|
-
return { status: 'pending', valid: false };
|
|
72
|
-
}
|
|
73
|
-
const dialPrefix = '+1';
|
|
74
|
-
const toPhone = dialPrefix + to;
|
|
75
|
-
const url = `https://verify.twilio.com/v2/Services/${this.TWILIO_VERIFY_SID}/VerificationCheck`;
|
|
76
|
-
const params = new URLSearchParams();
|
|
77
|
-
params.append('To', toPhone);
|
|
78
|
-
params.append('Code', code);
|
|
79
|
-
const auth = Buffer.from(`${this.TWILIO_ACCOUNT_SID}:${this.TWILIO_AUTH_TOKEN}`).toString('base64');
|
|
80
|
-
try {
|
|
81
|
-
const response = await fetch(url, {
|
|
82
|
-
method: 'POST',
|
|
83
|
-
headers: {
|
|
84
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
85
|
-
Authorization: `Basic ${auth}`,
|
|
86
|
-
},
|
|
87
|
-
body: params,
|
|
88
|
-
});
|
|
89
|
-
if (!response.ok) {
|
|
90
|
-
const errorText = await response.text();
|
|
91
|
-
throw new Error(`HTTP ${response.status}: ${errorText}`);
|
|
92
|
-
}
|
|
93
|
-
return await response.json();
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
throw new Error(`Failed to check verification: ${error.message}`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async sendSms(to, body) {
|
|
100
|
-
const dialPrefix = '+1';
|
|
101
|
-
const toPhone = dialPrefix + to;
|
|
102
|
-
const url = `${this.TWILIO_API_URL}/${this.TWILIO_ACCOUNT_SID}/Messages.json`;
|
|
103
|
-
const params = new URLSearchParams();
|
|
104
|
-
params.append('To', toPhone);
|
|
105
|
-
params.append('From', this.TWILIO_PHONE);
|
|
106
|
-
params.append('Body', body);
|
|
107
|
-
const auth = Buffer.from(`${this.TWILIO_ACCOUNT_SID}:${this.TWILIO_AUTH_TOKEN}`).toString('base64');
|
|
108
|
-
try {
|
|
109
|
-
const response = await fetch(url, {
|
|
110
|
-
method: 'POST',
|
|
111
|
-
headers: {
|
|
112
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
113
|
-
Authorization: `Basic ${auth}`,
|
|
114
|
-
},
|
|
115
|
-
body: params,
|
|
116
|
-
});
|
|
117
|
-
if (!response.ok) {
|
|
118
|
-
const errorText = await response.text();
|
|
119
|
-
throw new Error(`HTTP ${response.status}: ${errorText}`);
|
|
120
|
-
}
|
|
121
|
-
return await response.json();
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
throw new Error(`Failed to send SMS: ${error.message}`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
isTestMode() {
|
|
128
|
-
return process.env.TEST_MODE === 'true' || process.env.NODE_ENV === 'test';
|
|
129
|
-
}
|
|
130
|
-
isTestPhoneNumber(phoneNumber) {
|
|
131
|
-
const normalized = phoneNumber.replace(/^\+1/, '');
|
|
132
|
-
return normalized.startsWith('555');
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
exports.TwilioService = TwilioService;
|
|
136
|
-
exports.TwilioService = TwilioService = __decorate([
|
|
137
|
-
(0, common_1.Injectable)(),
|
|
138
|
-
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
139
|
-
], TwilioService);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
-
interface User {
|
|
3
|
-
userId: string;
|
|
4
|
-
phoneNumber: string;
|
|
5
|
-
phoneVerified: boolean;
|
|
6
|
-
createdAt: string;
|
|
7
|
-
}
|
|
8
|
-
interface UsersData {
|
|
9
|
-
[userId: string]: Omit<User, 'userId'>;
|
|
10
|
-
}
|
|
11
|
-
export declare class UsersService implements OnModuleInit {
|
|
12
|
-
private readonly usersFilePath;
|
|
13
|
-
private readonly dataDir;
|
|
14
|
-
constructor();
|
|
15
|
-
onModuleInit(): void;
|
|
16
|
-
loadUsers(): UsersData;
|
|
17
|
-
saveUsers(users: UsersData): void;
|
|
18
|
-
generateUserId(): string;
|
|
19
|
-
createUser(phoneNumber: string): string | null;
|
|
20
|
-
findUser(userId: string): User | null;
|
|
21
|
-
deleteUser(userId: string): void;
|
|
22
|
-
findUserByPhone(phoneNumber: string): User | null;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
@@ -1,149 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.UsersService = void 0;
|
|
46
|
-
const common_1 = require("@nestjs/common");
|
|
47
|
-
const fs = __importStar(require("fs"));
|
|
48
|
-
const path = __importStar(require("path"));
|
|
49
|
-
const uuid_1 = require("uuid");
|
|
50
|
-
let UsersService = class UsersService {
|
|
51
|
-
usersFilePath;
|
|
52
|
-
dataDir;
|
|
53
|
-
constructor() {
|
|
54
|
-
this.dataDir = path.resolve(process.cwd(), 'data');
|
|
55
|
-
const commonDir = path.resolve(this.dataDir, 'common');
|
|
56
|
-
const usersDir = path.resolve(commonDir, 'users');
|
|
57
|
-
this.usersFilePath = path.resolve(usersDir, 'users.json');
|
|
58
|
-
}
|
|
59
|
-
onModuleInit() {
|
|
60
|
-
const usersDir = path.dirname(this.usersFilePath);
|
|
61
|
-
if (!fs.existsSync(usersDir)) {
|
|
62
|
-
fs.mkdirSync(usersDir, { recursive: true });
|
|
63
|
-
}
|
|
64
|
-
if (!fs.existsSync(this.usersFilePath)) {
|
|
65
|
-
fs.writeFileSync(this.usersFilePath, JSON.stringify({}), 'utf-8');
|
|
66
|
-
}
|
|
67
|
-
console.log('UsersService initialized with phone/OTP authentication');
|
|
68
|
-
}
|
|
69
|
-
loadUsers() {
|
|
70
|
-
try {
|
|
71
|
-
const data = fs.readFileSync(this.usersFilePath, 'utf-8');
|
|
72
|
-
return JSON.parse(data);
|
|
73
|
-
}
|
|
74
|
-
catch (_error) {
|
|
75
|
-
return {};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
saveUsers(users) {
|
|
79
|
-
fs.writeFileSync(this.usersFilePath, JSON.stringify(users, null, 2), 'utf-8');
|
|
80
|
-
}
|
|
81
|
-
generateUserId() {
|
|
82
|
-
return (0, uuid_1.v4)();
|
|
83
|
-
}
|
|
84
|
-
createUser(phoneNumber) {
|
|
85
|
-
const users = this.loadUsers();
|
|
86
|
-
if (this.findUserByPhone(phoneNumber)) {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
const userId = this.generateUserId();
|
|
90
|
-
users[userId] = {
|
|
91
|
-
phoneNumber,
|
|
92
|
-
phoneVerified: true,
|
|
93
|
-
createdAt: new Date().toISOString(),
|
|
94
|
-
};
|
|
95
|
-
const userDir = path.resolve(this.dataDir, 'user', userId);
|
|
96
|
-
if (!fs.existsSync(userDir)) {
|
|
97
|
-
fs.mkdirSync(userDir, { recursive: true });
|
|
98
|
-
}
|
|
99
|
-
this.saveUsers(users);
|
|
100
|
-
return userId;
|
|
101
|
-
}
|
|
102
|
-
findUser(userId) {
|
|
103
|
-
const users = this.loadUsers();
|
|
104
|
-
const userData = users[userId];
|
|
105
|
-
if (!userData) {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
userId,
|
|
110
|
-
...userData,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
deleteUser(userId) {
|
|
114
|
-
const users = this.loadUsers();
|
|
115
|
-
if (!users[userId]) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
delete users[userId];
|
|
119
|
-
this.saveUsers(users);
|
|
120
|
-
try {
|
|
121
|
-
const userDir = path.resolve(this.dataDir, 'user', userId);
|
|
122
|
-
if (fs.existsSync(userDir)) {
|
|
123
|
-
fs.rmSync(userDir, { recursive: true, force: true });
|
|
124
|
-
console.log(`Deleted user directory: ${userDir}`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
console.error(`Error deleting user directory for ${userId}:`, error);
|
|
129
|
-
}
|
|
130
|
-
console.log(`User ${userId} deleted successfully`);
|
|
131
|
-
}
|
|
132
|
-
findUserByPhone(phoneNumber) {
|
|
133
|
-
const users = this.loadUsers();
|
|
134
|
-
for (const [userId, userData] of Object.entries(users)) {
|
|
135
|
-
if (userData.phoneNumber === phoneNumber) {
|
|
136
|
-
return {
|
|
137
|
-
userId,
|
|
138
|
-
...userData,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
exports.UsersService = UsersService;
|
|
146
|
-
exports.UsersService = UsersService = __decorate([
|
|
147
|
-
(0, common_1.Injectable)(),
|
|
148
|
-
__metadata("design:paramtypes", [])
|
|
149
|
-
], UsersService);
|
package/dist/common/errors.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare class NotFoundError extends Error {
|
|
2
|
-
constructor(message: string);
|
|
3
|
-
}
|
|
4
|
-
export declare class ValidationError extends Error {
|
|
5
|
-
constructor(message: string);
|
|
6
|
-
}
|
|
7
|
-
export declare class OperationFailedError extends Error {
|
|
8
|
-
constructor(message: string);
|
|
9
|
-
}
|
|
10
|
-
export declare class InsufficientBalanceError extends Error {
|
|
11
|
-
constructor(message: string);
|
|
12
|
-
}
|
package/dist/common/errors.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InsufficientBalanceError = exports.OperationFailedError = exports.ValidationError = exports.NotFoundError = void 0;
|
|
4
|
-
class NotFoundError extends Error {
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = 'NotFoundError';
|
|
8
|
-
if (Error.captureStackTrace) {
|
|
9
|
-
Error.captureStackTrace(this, NotFoundError);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.NotFoundError = NotFoundError;
|
|
14
|
-
class ValidationError extends Error {
|
|
15
|
-
constructor(message) {
|
|
16
|
-
super(message);
|
|
17
|
-
this.name = 'ValidationError';
|
|
18
|
-
if (Error.captureStackTrace) {
|
|
19
|
-
Error.captureStackTrace(this, ValidationError);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.ValidationError = ValidationError;
|
|
24
|
-
class OperationFailedError extends Error {
|
|
25
|
-
constructor(message) {
|
|
26
|
-
super(message);
|
|
27
|
-
this.name = 'OperationFailedError';
|
|
28
|
-
if (Error.captureStackTrace) {
|
|
29
|
-
Error.captureStackTrace(this, OperationFailedError);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.OperationFailedError = OperationFailedError;
|
|
34
|
-
class InsufficientBalanceError extends Error {
|
|
35
|
-
constructor(message) {
|
|
36
|
-
super(message);
|
|
37
|
-
this.name = 'InsufficientBalanceError';
|
|
38
|
-
if (Error.captureStackTrace) {
|
|
39
|
-
Error.captureStackTrace(this, InsufficientBalanceError);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.InsufficientBalanceError = InsufficientBalanceError;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ConfigurationModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const configuration_service_1 = require("./configuration.service");
|
|
12
|
-
let ConfigurationModule = class ConfigurationModule {
|
|
13
|
-
};
|
|
14
|
-
exports.ConfigurationModule = ConfigurationModule;
|
|
15
|
-
exports.ConfigurationModule = ConfigurationModule = __decorate([
|
|
16
|
-
(0, common_1.Module)({
|
|
17
|
-
providers: [configuration_service_1.ConfigurationService],
|
|
18
|
-
exports: [configuration_service_1.ConfigurationService],
|
|
19
|
-
})
|
|
20
|
-
], ConfigurationModule);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export declare class ConfigurationService {
|
|
2
|
-
private dataDir;
|
|
3
|
-
private credsDir;
|
|
4
|
-
private promptsDir;
|
|
5
|
-
private commonPromptsDir;
|
|
6
|
-
private userPromptsDir;
|
|
7
|
-
private uploadDir;
|
|
8
|
-
private userConfigDir;
|
|
9
|
-
private commonConfigDir;
|
|
10
|
-
private userDataDir;
|
|
11
|
-
private userId;
|
|
12
|
-
constructor(userId: string, baseDataPath?: string);
|
|
13
|
-
getDataDir(): string;
|
|
14
|
-
getCredsDir(): string;
|
|
15
|
-
getPromptsDir(): string;
|
|
16
|
-
getUploadDir(): string;
|
|
17
|
-
getUserConfigDir(): string;
|
|
18
|
-
getCommonConfigDir(): string;
|
|
19
|
-
store(configName: string, data: string): void;
|
|
20
|
-
load(configName: string): string | null;
|
|
21
|
-
exists(configName: string): boolean;
|
|
22
|
-
getCommonPromptsDir(): string;
|
|
23
|
-
getUserPromptsDir(): string;
|
|
24
|
-
getUserDataDir(): string;
|
|
25
|
-
getUserId(): string;
|
|
26
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ConfigurationService = void 0;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
class ConfigurationService {
|
|
40
|
-
dataDir;
|
|
41
|
-
credsDir;
|
|
42
|
-
promptsDir;
|
|
43
|
-
commonPromptsDir;
|
|
44
|
-
userPromptsDir;
|
|
45
|
-
uploadDir;
|
|
46
|
-
userConfigDir;
|
|
47
|
-
commonConfigDir;
|
|
48
|
-
userDataDir;
|
|
49
|
-
userId;
|
|
50
|
-
constructor(userId, baseDataPath) {
|
|
51
|
-
this.userId = userId;
|
|
52
|
-
const dataPath = baseDataPath || process.env.SERVER_DATA_PATH || path.resolve(process.cwd(), 'data');
|
|
53
|
-
this.dataDir = path.resolve(dataPath);
|
|
54
|
-
if (!fs.existsSync(this.dataDir)) {
|
|
55
|
-
fs.mkdirSync(this.dataDir, { recursive: true });
|
|
56
|
-
}
|
|
57
|
-
const commonDir = path.resolve(this.dataDir, 'common');
|
|
58
|
-
this.credsDir = path.resolve(commonDir, 'creds');
|
|
59
|
-
if (!fs.existsSync(this.credsDir)) {
|
|
60
|
-
fs.mkdirSync(this.credsDir, { recursive: true });
|
|
61
|
-
}
|
|
62
|
-
this.commonConfigDir = path.resolve(commonDir, 'config');
|
|
63
|
-
if (!fs.existsSync(this.commonConfigDir)) {
|
|
64
|
-
fs.mkdirSync(this.commonConfigDir, { recursive: true });
|
|
65
|
-
}
|
|
66
|
-
this.commonPromptsDir = path.resolve(commonDir, 'prompts');
|
|
67
|
-
if (!fs.existsSync(this.commonPromptsDir)) {
|
|
68
|
-
fs.mkdirSync(this.commonPromptsDir, { recursive: true });
|
|
69
|
-
}
|
|
70
|
-
this.userDataDir = path.resolve(this.dataDir, 'user', this.userId);
|
|
71
|
-
this.userPromptsDir = path.resolve(this.userDataDir, 'prompts');
|
|
72
|
-
if (!fs.existsSync(this.userPromptsDir)) {
|
|
73
|
-
fs.mkdirSync(this.userPromptsDir, { recursive: true });
|
|
74
|
-
}
|
|
75
|
-
this.uploadDir = path.resolve(this.userDataDir, 'upload');
|
|
76
|
-
if (!fs.existsSync(this.uploadDir)) {
|
|
77
|
-
fs.mkdirSync(this.uploadDir, { recursive: true });
|
|
78
|
-
}
|
|
79
|
-
this.userConfigDir = path.resolve(this.userDataDir, 'userconfig');
|
|
80
|
-
if (!fs.existsSync(this.userConfigDir)) {
|
|
81
|
-
fs.mkdirSync(this.userConfigDir, { recursive: true });
|
|
82
|
-
}
|
|
83
|
-
this.promptsDir = this.userPromptsDir;
|
|
84
|
-
}
|
|
85
|
-
getDataDir() {
|
|
86
|
-
return this.dataDir;
|
|
87
|
-
}
|
|
88
|
-
getCredsDir() {
|
|
89
|
-
return this.credsDir;
|
|
90
|
-
}
|
|
91
|
-
getPromptsDir() {
|
|
92
|
-
return this.promptsDir;
|
|
93
|
-
}
|
|
94
|
-
getUploadDir() {
|
|
95
|
-
return this.uploadDir;
|
|
96
|
-
}
|
|
97
|
-
getUserConfigDir() {
|
|
98
|
-
return this.userConfigDir;
|
|
99
|
-
}
|
|
100
|
-
getCommonConfigDir() {
|
|
101
|
-
return this.commonConfigDir;
|
|
102
|
-
}
|
|
103
|
-
store(configName, data) {
|
|
104
|
-
const configPath = path.join(this.getUserConfigDir(), configName);
|
|
105
|
-
fs.writeFileSync(configPath, data);
|
|
106
|
-
}
|
|
107
|
-
load(configName) {
|
|
108
|
-
const configPath = path.join(this.getUserConfigDir(), configName);
|
|
109
|
-
if (!fs.existsSync(configPath)) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
return fs.readFileSync(configPath, 'utf8');
|
|
113
|
-
}
|
|
114
|
-
exists(configName) {
|
|
115
|
-
const configPath = path.join(this.getUserConfigDir(), configName);
|
|
116
|
-
return fs.existsSync(configPath);
|
|
117
|
-
}
|
|
118
|
-
getCommonPromptsDir() {
|
|
119
|
-
return this.commonPromptsDir;
|
|
120
|
-
}
|
|
121
|
-
getUserPromptsDir() {
|
|
122
|
-
return this.userPromptsDir;
|
|
123
|
-
}
|
|
124
|
-
getUserDataDir() {
|
|
125
|
-
return this.userDataDir;
|
|
126
|
-
}
|
|
127
|
-
getUserId() {
|
|
128
|
-
return this.userId;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.ConfigurationService = ConfigurationService;
|