briyah 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.
Files changed (354) hide show
  1. package/.prettierrc +7 -0
  2. package/dist/ai/LLM/anthropic.module.d.ts +2 -0
  3. package/dist/ai/LLM/anthropic.module.js +21 -0
  4. package/dist/ai/LLM/anthropic.service.d.ts +27 -0
  5. package/dist/ai/LLM/anthropic.service.js +329 -0
  6. package/dist/ai/LLM/base-ai.service.d.ts +45 -0
  7. package/dist/ai/LLM/base-ai.service.js +409 -0
  8. package/dist/ai/LLM/deepseek.module.d.ts +2 -0
  9. package/dist/ai/LLM/deepseek.module.js +21 -0
  10. package/dist/ai/LLM/deepseek.service.d.ts +15 -0
  11. package/dist/ai/LLM/deepseek.service.js +279 -0
  12. package/dist/ai/LLM/fal.module.d.ts +2 -0
  13. package/dist/ai/LLM/fal.module.js +21 -0
  14. package/dist/ai/LLM/fal.service.d.ts +17 -0
  15. package/dist/ai/LLM/fal.service.js +314 -0
  16. package/dist/ai/LLM/googleai.module.d.ts +2 -0
  17. package/dist/ai/LLM/googleai.module.js +21 -0
  18. package/dist/ai/LLM/googleai.service.d.ts +20 -0
  19. package/dist/ai/LLM/googleai.service.js +271 -0
  20. package/dist/ai/LLM/grok.module.d.ts +2 -0
  21. package/dist/ai/LLM/grok.module.js +21 -0
  22. package/dist/ai/LLM/grok.service.d.ts +14 -0
  23. package/dist/ai/LLM/grok.service.js +263 -0
  24. package/dist/ai/LLM/mock.module.d.ts +2 -0
  25. package/dist/ai/LLM/mock.module.js +21 -0
  26. package/dist/ai/LLM/mock.service.d.ts +13 -0
  27. package/dist/ai/LLM/mock.service.js +194 -0
  28. package/dist/ai/LLM/openai.module.d.ts +2 -0
  29. package/dist/ai/LLM/openai.module.js +21 -0
  30. package/dist/ai/LLM/openai.service.d.ts +21 -0
  31. package/dist/ai/LLM/openai.service.js +421 -0
  32. package/dist/ai/LLM/together.module.d.ts +2 -0
  33. package/dist/ai/LLM/together.module.js +21 -0
  34. package/dist/ai/LLM/together.service.d.ts +18 -0
  35. package/dist/ai/LLM/together.service.js +285 -0
  36. package/dist/ai/LLM/vertexai.module.d.ts +2 -0
  37. package/dist/ai/LLM/vertexai.module.js +21 -0
  38. package/dist/ai/LLM/vertexai.service.d.ts +17 -0
  39. package/dist/ai/LLM/vertexai.service.js +323 -0
  40. package/dist/ai/agent-config.d.ts +32 -0
  41. package/dist/ai/agent-config.js +2 -0
  42. package/dist/ai/agent-factory.d.ts +15 -0
  43. package/dist/ai/agent-factory.js +24 -0
  44. package/dist/ai/agent-message.service.d.ts +9 -0
  45. package/dist/ai/agent-message.service.js +56 -0
  46. package/dist/ai/agent-store.module.d.ts +2 -0
  47. package/dist/ai/agent-store.module.js +21 -0
  48. package/dist/ai/agent-store.service.d.ts +31 -0
  49. package/dist/ai/agent-store.service.js +352 -0
  50. package/dist/ai/agent.d.ts +75 -0
  51. package/dist/ai/agent.js +174 -0
  52. package/dist/ai/ai-factory.module.d.ts +2 -0
  53. package/dist/ai/ai-factory.module.js +40 -0
  54. package/dist/ai/ai-factory.service.d.ts +24 -0
  55. package/dist/ai/ai-factory.service.js +94 -0
  56. package/dist/ai/artifact.module.d.ts +2 -0
  57. package/dist/ai/artifact.module.js +22 -0
  58. package/dist/ai/artifact.service.d.ts +21 -0
  59. package/dist/ai/artifact.service.js +239 -0
  60. package/dist/ai/attached-file.module.d.ts +2 -0
  61. package/dist/ai/attached-file.module.js +22 -0
  62. package/dist/ai/attached-file.service.d.ts +35 -0
  63. package/dist/ai/attached-file.service.js +253 -0
  64. package/dist/ai/model_prices.d.ts +2 -0
  65. package/dist/ai/model_prices.js +54 -0
  66. package/dist/ai/published-agents.service.d.ts +13 -0
  67. package/dist/ai/published-agents.service.js +118 -0
  68. package/dist/app/balance-message.service.d.ts +8 -0
  69. package/dist/app/balance-message.service.js +45 -0
  70. package/dist/app/balance.module.d.ts +2 -0
  71. package/dist/app/balance.module.js +20 -0
  72. package/dist/app/balance.service.d.ts +18 -0
  73. package/dist/app/balance.service.js +158 -0
  74. package/dist/app/stripe.controller.d.ts +31 -0
  75. package/dist/app/stripe.controller.js +150 -0
  76. package/dist/app/stripe.module.d.ts +2 -0
  77. package/dist/app/stripe.module.js +22 -0
  78. package/dist/app/stripe.service.d.ts +28 -0
  79. package/dist/app/stripe.service.js +198 -0
  80. package/dist/app/transaction.service.d.ts +15 -0
  81. package/dist/app/transaction.service.js +139 -0
  82. package/dist/app/user-service-factory.d.ts +21 -0
  83. package/dist/app/user-service-factory.js +81 -0
  84. package/dist/app/user-service-manager.d.ts +28 -0
  85. package/dist/app/user-service-manager.js +102 -0
  86. package/dist/app.controller.d.ts +232 -0
  87. package/dist/app.controller.js +2536 -0
  88. package/dist/app.module.d.ts +2 -0
  89. package/dist/app.module.js +45 -0
  90. package/dist/app.service.d.ts +186 -0
  91. package/dist/app.service.js +1334 -0
  92. package/dist/auth/agent-access.decorator.d.ts +2 -0
  93. package/dist/auth/agent-access.decorator.js +10 -0
  94. package/dist/auth/auth.controller.d.ts +38 -0
  95. package/dist/auth/auth.controller.js +356 -0
  96. package/dist/auth/auth.module.d.ts +2 -0
  97. package/dist/auth/auth.module.js +55 -0
  98. package/dist/auth/auth.service.d.ts +14 -0
  99. package/dist/auth/auth.service.js +84 -0
  100. package/dist/auth/dto/bot-login.dto.d.ts +4 -0
  101. package/dist/auth/dto/bot-login.dto.js +2 -0
  102. package/dist/auth/dto/password-reset.dto.d.ts +11 -0
  103. package/dist/auth/dto/password-reset.dto.js +2 -0
  104. package/dist/auth/dto/phone-login.dto.d.ts +8 -0
  105. package/dist/auth/dto/phone-login.dto.js +2 -0
  106. package/dist/auth/dto/phone-verification.dto.d.ts +9 -0
  107. package/dist/auth/dto/phone-verification.dto.js +2 -0
  108. package/dist/auth/jwt-auth.guard.d.ts +13 -0
  109. package/dist/auth/jwt-auth.guard.js +143 -0
  110. package/dist/auth/jwt.strategy.d.ts +17 -0
  111. package/dist/auth/jwt.strategy.js +45 -0
  112. package/dist/auth/phone-validation.service.d.ts +7 -0
  113. package/dist/auth/phone-validation.service.js +50 -0
  114. package/dist/auth/public.decorator.d.ts +2 -0
  115. package/dist/auth/public.decorator.js +7 -0
  116. package/dist/auth/rate-limit.service.d.ts +16 -0
  117. package/dist/auth/rate-limit.service.js +84 -0
  118. package/dist/auth/room-access.decorator.d.ts +2 -0
  119. package/dist/auth/room-access.decorator.js +10 -0
  120. package/dist/auth/scopes.decorator.d.ts +2 -0
  121. package/dist/auth/scopes.decorator.js +7 -0
  122. package/dist/auth/scopes.guard.d.ts +9 -0
  123. package/dist/auth/scopes.guard.js +82 -0
  124. package/dist/auth/session.guard.d.ts +7 -0
  125. package/dist/auth/session.guard.js +55 -0
  126. package/dist/auth/twilio.service.d.ts +15 -0
  127. package/dist/auth/twilio.service.js +139 -0
  128. package/dist/auth/users.service.d.ts +24 -0
  129. package/dist/auth/users.service.js +149 -0
  130. package/dist/common/errors.d.ts +12 -0
  131. package/dist/common/errors.js +43 -0
  132. package/dist/config/configuration.module.d.ts +2 -0
  133. package/dist/config/configuration.module.js +20 -0
  134. package/dist/config/configuration.service.d.ts +26 -0
  135. package/dist/config/configuration.service.js +131 -0
  136. package/dist/main.js +15749 -0
  137. package/dist/room/artifact-store.service.d.ts +15 -0
  138. package/dist/room/artifact-store.service.js +226 -0
  139. package/dist/room/artifact.d.ts +6 -0
  140. package/dist/room/artifact.js +2 -0
  141. package/dist/room/message.d.ts +19 -0
  142. package/dist/room/message.js +70 -0
  143. package/dist/room/published-rooms.service.d.ts +12 -0
  144. package/dist/room/published-rooms.service.js +108 -0
  145. package/dist/room/room-config.d.ts +12 -0
  146. package/dist/room/room-config.js +2 -0
  147. package/dist/room/room-factory.d.ts +7 -0
  148. package/dist/room/room-factory.js +16 -0
  149. package/dist/room/room-message.module.d.ts +2 -0
  150. package/dist/room/room-message.module.js +21 -0
  151. package/dist/room/room-message.service.d.ts +8 -0
  152. package/dist/room/room-message.service.js +44 -0
  153. package/dist/room/room-store.module.d.ts +2 -0
  154. package/dist/room/room-store.module.js +25 -0
  155. package/dist/room/room-store.service.d.ts +38 -0
  156. package/dist/room/room-store.service.js +353 -0
  157. package/dist/room/room.d.ts +107 -0
  158. package/dist/room/room.js +833 -0
  159. package/dist/sdk/briyah-config.d.ts +13 -0
  160. package/dist/sdk/briyah-config.js +32 -0
  161. package/dist/sdk/briyah.d.ts +36 -0
  162. package/dist/sdk/briyah.js +122 -0
  163. package/dist/sdk/index.d.ts +6 -0
  164. package/dist/sdk/index.js +11 -0
  165. package/dist/server/src/ai/LLM/anthropic.module.d.ts +2 -0
  166. package/dist/server/src/ai/LLM/anthropic.module.js +21 -0
  167. package/dist/server/src/ai/LLM/anthropic.service.d.ts +27 -0
  168. package/dist/server/src/ai/LLM/anthropic.service.js +329 -0
  169. package/dist/server/src/ai/LLM/base-ai.service.d.ts +45 -0
  170. package/dist/server/src/ai/LLM/base-ai.service.js +409 -0
  171. package/dist/server/src/ai/LLM/deepseek.module.d.ts +2 -0
  172. package/dist/server/src/ai/LLM/deepseek.module.js +21 -0
  173. package/dist/server/src/ai/LLM/deepseek.service.d.ts +15 -0
  174. package/dist/server/src/ai/LLM/deepseek.service.js +279 -0
  175. package/dist/server/src/ai/LLM/fal.module.d.ts +2 -0
  176. package/dist/server/src/ai/LLM/fal.module.js +21 -0
  177. package/dist/server/src/ai/LLM/fal.service.d.ts +17 -0
  178. package/dist/server/src/ai/LLM/fal.service.js +314 -0
  179. package/dist/server/src/ai/LLM/googleai.module.d.ts +2 -0
  180. package/dist/server/src/ai/LLM/googleai.module.js +21 -0
  181. package/dist/server/src/ai/LLM/googleai.service.d.ts +20 -0
  182. package/dist/server/src/ai/LLM/googleai.service.js +271 -0
  183. package/dist/server/src/ai/LLM/grok.module.d.ts +2 -0
  184. package/dist/server/src/ai/LLM/grok.module.js +21 -0
  185. package/dist/server/src/ai/LLM/grok.service.d.ts +14 -0
  186. package/dist/server/src/ai/LLM/grok.service.js +263 -0
  187. package/dist/server/src/ai/LLM/mock.module.d.ts +2 -0
  188. package/dist/server/src/ai/LLM/mock.module.js +21 -0
  189. package/dist/server/src/ai/LLM/mock.service.d.ts +13 -0
  190. package/dist/server/src/ai/LLM/mock.service.js +194 -0
  191. package/dist/server/src/ai/LLM/openai.module.d.ts +2 -0
  192. package/dist/server/src/ai/LLM/openai.module.js +21 -0
  193. package/dist/server/src/ai/LLM/openai.service.d.ts +21 -0
  194. package/dist/server/src/ai/LLM/openai.service.js +421 -0
  195. package/dist/server/src/ai/LLM/together.module.d.ts +2 -0
  196. package/dist/server/src/ai/LLM/together.module.js +21 -0
  197. package/dist/server/src/ai/LLM/together.service.d.ts +18 -0
  198. package/dist/server/src/ai/LLM/together.service.js +285 -0
  199. package/dist/server/src/ai/LLM/vertexai.module.d.ts +2 -0
  200. package/dist/server/src/ai/LLM/vertexai.module.js +21 -0
  201. package/dist/server/src/ai/LLM/vertexai.service.d.ts +17 -0
  202. package/dist/server/src/ai/LLM/vertexai.service.js +323 -0
  203. package/dist/server/src/ai/agent-config.d.ts +32 -0
  204. package/dist/server/src/ai/agent-config.js +2 -0
  205. package/dist/server/src/ai/agent-factory.d.ts +15 -0
  206. package/dist/server/src/ai/agent-factory.js +24 -0
  207. package/dist/server/src/ai/agent-message.service.d.ts +9 -0
  208. package/dist/server/src/ai/agent-message.service.js +56 -0
  209. package/dist/server/src/ai/agent-store.module.d.ts +2 -0
  210. package/dist/server/src/ai/agent-store.module.js +21 -0
  211. package/dist/server/src/ai/agent-store.service.d.ts +31 -0
  212. package/dist/server/src/ai/agent-store.service.js +352 -0
  213. package/dist/server/src/ai/agent.d.ts +75 -0
  214. package/dist/server/src/ai/agent.js +174 -0
  215. package/dist/server/src/ai/ai-factory.module.d.ts +2 -0
  216. package/dist/server/src/ai/ai-factory.module.js +40 -0
  217. package/dist/server/src/ai/ai-factory.service.d.ts +24 -0
  218. package/dist/server/src/ai/ai-factory.service.js +94 -0
  219. package/dist/server/src/ai/artifact.module.d.ts +2 -0
  220. package/dist/server/src/ai/artifact.module.js +22 -0
  221. package/dist/server/src/ai/artifact.service.d.ts +21 -0
  222. package/dist/server/src/ai/artifact.service.js +239 -0
  223. package/dist/server/src/ai/attached-file.module.d.ts +2 -0
  224. package/dist/server/src/ai/attached-file.module.js +22 -0
  225. package/dist/server/src/ai/attached-file.service.d.ts +35 -0
  226. package/dist/server/src/ai/attached-file.service.js +253 -0
  227. package/dist/server/src/ai/model_prices.d.ts +2 -0
  228. package/dist/server/src/ai/model_prices.js +54 -0
  229. package/dist/server/src/ai/published-agents.service.d.ts +13 -0
  230. package/dist/server/src/ai/published-agents.service.js +118 -0
  231. package/dist/server/src/app/balance-message.service.d.ts +8 -0
  232. package/dist/server/src/app/balance-message.service.js +45 -0
  233. package/dist/server/src/app/balance.module.d.ts +2 -0
  234. package/dist/server/src/app/balance.module.js +20 -0
  235. package/dist/server/src/app/balance.service.d.ts +18 -0
  236. package/dist/server/src/app/balance.service.js +158 -0
  237. package/dist/server/src/app/stripe.controller.d.ts +31 -0
  238. package/dist/server/src/app/stripe.controller.js +148 -0
  239. package/dist/server/src/app/stripe.module.d.ts +2 -0
  240. package/dist/server/src/app/stripe.module.js +22 -0
  241. package/dist/server/src/app/stripe.service.d.ts +28 -0
  242. package/dist/server/src/app/stripe.service.js +198 -0
  243. package/dist/server/src/app/transaction.service.d.ts +15 -0
  244. package/dist/server/src/app/transaction.service.js +139 -0
  245. package/dist/server/src/app/user-service-factory.d.ts +21 -0
  246. package/dist/server/src/app/user-service-factory.js +81 -0
  247. package/dist/server/src/app/user-service-manager.d.ts +28 -0
  248. package/dist/server/src/app/user-service-manager.js +102 -0
  249. package/dist/server/src/app.controller.d.ts +232 -0
  250. package/dist/server/src/app.controller.js +2534 -0
  251. package/dist/server/src/app.module.d.ts +2 -0
  252. package/dist/server/src/app.module.js +45 -0
  253. package/dist/server/src/app.service.d.ts +186 -0
  254. package/dist/server/src/app.service.js +1334 -0
  255. package/dist/server/src/auth/agent-access.decorator.d.ts +2 -0
  256. package/dist/server/src/auth/agent-access.decorator.js +10 -0
  257. package/dist/server/src/auth/auth.controller.d.ts +38 -0
  258. package/dist/server/src/auth/auth.controller.js +356 -0
  259. package/dist/server/src/auth/auth.module.d.ts +2 -0
  260. package/dist/server/src/auth/auth.module.js +55 -0
  261. package/dist/server/src/auth/auth.service.d.ts +14 -0
  262. package/dist/server/src/auth/auth.service.js +84 -0
  263. package/dist/server/src/auth/dto/bot-login.dto.d.ts +4 -0
  264. package/dist/server/src/auth/dto/bot-login.dto.js +2 -0
  265. package/dist/server/src/auth/dto/password-reset.dto.d.ts +11 -0
  266. package/dist/server/src/auth/dto/password-reset.dto.js +2 -0
  267. package/dist/server/src/auth/dto/phone-login.dto.d.ts +8 -0
  268. package/dist/server/src/auth/dto/phone-login.dto.js +2 -0
  269. package/dist/server/src/auth/dto/phone-verification.dto.d.ts +9 -0
  270. package/dist/server/src/auth/dto/phone-verification.dto.js +2 -0
  271. package/dist/server/src/auth/jwt-auth.guard.d.ts +13 -0
  272. package/dist/server/src/auth/jwt-auth.guard.js +143 -0
  273. package/dist/server/src/auth/jwt.strategy.d.ts +17 -0
  274. package/dist/server/src/auth/jwt.strategy.js +45 -0
  275. package/dist/server/src/auth/phone-validation.service.d.ts +7 -0
  276. package/dist/server/src/auth/phone-validation.service.js +50 -0
  277. package/dist/server/src/auth/public.decorator.d.ts +2 -0
  278. package/dist/server/src/auth/public.decorator.js +7 -0
  279. package/dist/server/src/auth/rate-limit.service.d.ts +16 -0
  280. package/dist/server/src/auth/rate-limit.service.js +84 -0
  281. package/dist/server/src/auth/room-access.decorator.d.ts +2 -0
  282. package/dist/server/src/auth/room-access.decorator.js +10 -0
  283. package/dist/server/src/auth/scopes.decorator.d.ts +2 -0
  284. package/dist/server/src/auth/scopes.decorator.js +7 -0
  285. package/dist/server/src/auth/scopes.guard.d.ts +9 -0
  286. package/dist/server/src/auth/scopes.guard.js +82 -0
  287. package/dist/server/src/auth/session.guard.d.ts +7 -0
  288. package/dist/server/src/auth/session.guard.js +55 -0
  289. package/dist/server/src/auth/twilio.service.d.ts +15 -0
  290. package/dist/server/src/auth/twilio.service.js +139 -0
  291. package/dist/server/src/auth/users.service.d.ts +24 -0
  292. package/dist/server/src/auth/users.service.js +149 -0
  293. package/dist/server/src/common/errors.d.ts +12 -0
  294. package/dist/server/src/common/errors.js +43 -0
  295. package/dist/server/src/config/configuration.module.d.ts +2 -0
  296. package/dist/server/src/config/configuration.module.js +20 -0
  297. package/dist/server/src/config/configuration.service.d.ts +26 -0
  298. package/dist/server/src/config/configuration.service.js +131 -0
  299. package/dist/server/src/room/artifact-store.service.d.ts +15 -0
  300. package/dist/server/src/room/artifact-store.service.js +226 -0
  301. package/dist/server/src/room/artifact.d.ts +6 -0
  302. package/dist/server/src/room/artifact.js +2 -0
  303. package/dist/server/src/room/message.d.ts +19 -0
  304. package/dist/server/src/room/message.js +70 -0
  305. package/dist/server/src/room/published-rooms.service.d.ts +12 -0
  306. package/dist/server/src/room/published-rooms.service.js +108 -0
  307. package/dist/server/src/room/room-config.d.ts +12 -0
  308. package/dist/server/src/room/room-config.js +2 -0
  309. package/dist/server/src/room/room-factory.d.ts +7 -0
  310. package/dist/server/src/room/room-factory.js +16 -0
  311. package/dist/server/src/room/room-message.module.d.ts +2 -0
  312. package/dist/server/src/room/room-message.module.js +21 -0
  313. package/dist/server/src/room/room-message.service.d.ts +8 -0
  314. package/dist/server/src/room/room-message.service.js +44 -0
  315. package/dist/server/src/room/room-store.module.d.ts +2 -0
  316. package/dist/server/src/room/room-store.module.js +25 -0
  317. package/dist/server/src/room/room-store.service.d.ts +38 -0
  318. package/dist/server/src/room/room-store.service.js +353 -0
  319. package/dist/server/src/room/room.d.ts +107 -0
  320. package/dist/server/src/room/room.js +833 -0
  321. package/dist/server/src/sdk/briyah-config.d.ts +13 -0
  322. package/dist/server/src/sdk/briyah-config.js +32 -0
  323. package/dist/server/src/sdk/briyah.d.ts +36 -0
  324. package/dist/server/src/sdk/briyah.js +122 -0
  325. package/dist/server/src/sdk/index.d.ts +6 -0
  326. package/dist/server/src/sdk/index.js +11 -0
  327. package/dist/server/src/shared/shared.module.d.ts +2 -0
  328. package/dist/server/src/shared/shared.module.js +46 -0
  329. package/dist/server/src/story/story-message.service.d.ts +10 -0
  330. package/dist/server/src/story/story-message.service.js +57 -0
  331. package/dist/server/src/story/story-progress.service.d.ts +8 -0
  332. package/dist/server/src/story/story-progress.service.js +44 -0
  333. package/dist/server/src/story/story-store.module.d.ts +2 -0
  334. package/dist/server/src/story/story-store.module.js +22 -0
  335. package/dist/server/src/story/story-store.service.d.ts +23 -0
  336. package/dist/server/src/story/story-store.service.js +392 -0
  337. package/dist/server/src/story/story.service.d.ts +94 -0
  338. package/dist/server/src/story/story.service.js +1797 -0
  339. package/dist/shared/shared.module.d.ts +2 -0
  340. package/dist/shared/shared.module.js +46 -0
  341. package/dist/shared/types/app.types.d.ts +296 -0
  342. package/dist/shared/types/app.types.js +17 -0
  343. package/dist/story/story-message.service.d.ts +10 -0
  344. package/dist/story/story-message.service.js +57 -0
  345. package/dist/story/story-progress.service.d.ts +8 -0
  346. package/dist/story/story-progress.service.js +44 -0
  347. package/dist/story/story-store.module.d.ts +2 -0
  348. package/dist/story/story-store.module.js +22 -0
  349. package/dist/story/story-store.service.d.ts +23 -0
  350. package/dist/story/story-store.service.js +392 -0
  351. package/dist/story/story.service.d.ts +94 -0
  352. package/dist/story/story.service.js +1797 -0
  353. package/eslint.config.js +29 -0
  354. package/package.json +125 -0
@@ -0,0 +1,139 @@
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);
@@ -0,0 +1,24 @@
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 {};
@@ -0,0 +1,149 @@
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);
@@ -0,0 +1,12 @@
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
+ }
@@ -0,0 +1,43 @@
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;
@@ -0,0 +1,2 @@
1
+ export declare class ConfigurationModule {
2
+ }
@@ -0,0 +1,20 @@
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);
@@ -0,0 +1,26 @@
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
+ }
@@ -0,0 +1,131 @@
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;