@solidstarters/solid-core 1.2.153 → 1.2.155

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 (137) hide show
  1. package/dist/config/iam.config.d.ts +6 -0
  2. package/dist/config/iam.config.d.ts.map +1 -1
  3. package/dist/config/iam.config.js +3 -0
  4. package/dist/config/iam.config.js.map +1 -1
  5. package/dist/constants/error-messages.js +1 -1
  6. package/dist/constants/error-messages.js.map +1 -1
  7. package/dist/controllers/ai-interaction.controller.d.ts +2 -1
  8. package/dist/controllers/ai-interaction.controller.d.ts.map +1 -1
  9. package/dist/controllers/ai-interaction.controller.js +5 -3
  10. package/dist/controllers/ai-interaction.controller.js.map +1 -1
  11. package/dist/controllers/authentication.controller.d.ts +6 -6
  12. package/dist/controllers/authentication.controller.d.ts.map +1 -1
  13. package/dist/controllers/authentication.controller.js +15 -7
  14. package/dist/controllers/authentication.controller.js.map +1 -1
  15. package/dist/controllers/email-template.controller.d.ts.map +1 -1
  16. package/dist/controllers/email-template.controller.js +3 -0
  17. package/dist/controllers/email-template.controller.js.map +1 -1
  18. package/dist/controllers/google-authentication.controller.d.ts.map +1 -1
  19. package/dist/controllers/google-authentication.controller.js +3 -0
  20. package/dist/controllers/google-authentication.controller.js.map +1 -1
  21. package/dist/controllers/media.controller.d.ts.map +1 -1
  22. package/dist/controllers/media.controller.js +4 -0
  23. package/dist/controllers/media.controller.js.map +1 -1
  24. package/dist/controllers/model-metadata.controller.d.ts.map +1 -1
  25. package/dist/controllers/model-metadata.controller.js +5 -0
  26. package/dist/controllers/model-metadata.controller.js.map +1 -1
  27. package/dist/controllers/otp-authentication.controller.d.ts.map +1 -1
  28. package/dist/controllers/otp-authentication.controller.js +3 -0
  29. package/dist/controllers/otp-authentication.controller.js.map +1 -1
  30. package/dist/controllers/service.controller.d.ts.map +1 -1
  31. package/dist/controllers/service.controller.js +4 -0
  32. package/dist/controllers/service.controller.js.map +1 -1
  33. package/dist/controllers/sms-template.controller.d.ts +1 -1
  34. package/dist/controllers/sms-template.controller.d.ts.map +1 -1
  35. package/dist/controllers/sms-template.controller.js +6 -3
  36. package/dist/controllers/sms-template.controller.js.map +1 -1
  37. package/dist/decorators/solid-password.decorator.d.ts +12 -0
  38. package/dist/decorators/solid-password.decorator.d.ts.map +1 -0
  39. package/dist/decorators/solid-password.decorator.js +43 -0
  40. package/dist/decorators/solid-password.decorator.js.map +1 -0
  41. package/dist/dtos/change-password.dto.d.ts.map +1 -1
  42. package/dist/dtos/change-password.dto.js +2 -0
  43. package/dist/dtos/change-password.dto.js.map +1 -1
  44. package/dist/dtos/confirm-forgot-password.dto.d.ts.map +1 -1
  45. package/dist/dtos/confirm-forgot-password.dto.js +2 -0
  46. package/dist/dtos/confirm-forgot-password.dto.js.map +1 -1
  47. package/dist/helpers/cors.helper.d.ts +4 -0
  48. package/dist/helpers/cors.helper.d.ts.map +1 -0
  49. package/dist/helpers/cors.helper.js +33 -0
  50. package/dist/helpers/cors.helper.js.map +1 -0
  51. package/dist/helpers/security.helper.d.ts +9 -0
  52. package/dist/helpers/security.helper.d.ts.map +1 -0
  53. package/dist/helpers/security.helper.js +46 -0
  54. package/dist/helpers/security.helper.js.map +1 -0
  55. package/dist/index.d.ts +3 -0
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +3 -0
  58. package/dist/index.js.map +1 -1
  59. package/dist/repository/chatter-message-details.repository.d.ts +16 -0
  60. package/dist/repository/chatter-message-details.repository.d.ts.map +1 -0
  61. package/dist/repository/chatter-message-details.repository.js +62 -0
  62. package/dist/repository/chatter-message-details.repository.js.map +1 -0
  63. package/dist/repository/chatter-message.repository.d.ts +16 -0
  64. package/dist/repository/chatter-message.repository.d.ts.map +1 -0
  65. package/dist/repository/chatter-message.repository.js +61 -0
  66. package/dist/repository/chatter-message.repository.js.map +1 -0
  67. package/dist/repository/security-rule.repository.d.ts +1 -1
  68. package/dist/repository/security-rule.repository.d.ts.map +1 -1
  69. package/dist/repository/security-rule.repository.js +2 -2
  70. package/dist/repository/security-rule.repository.js.map +1 -1
  71. package/dist/repository/solid-base.repository.d.ts +6 -1
  72. package/dist/repository/solid-base.repository.d.ts.map +1 -1
  73. package/dist/repository/solid-base.repository.js +35 -0
  74. package/dist/repository/solid-base.repository.js.map +1 -1
  75. package/dist/seeders/seed-data/solid-core-metadata.json +9 -0
  76. package/dist/services/ai-interaction.service.d.ts +2 -4
  77. package/dist/services/ai-interaction.service.d.ts.map +1 -1
  78. package/dist/services/ai-interaction.service.js +4 -8
  79. package/dist/services/ai-interaction.service.js.map +1 -1
  80. package/dist/services/authentication.service.d.ts +6 -2
  81. package/dist/services/authentication.service.d.ts.map +1 -1
  82. package/dist/services/authentication.service.js +94 -43
  83. package/dist/services/authentication.service.js.map +1 -1
  84. package/dist/services/chatter-message-details.service.d.ts +4 -3
  85. package/dist/services/chatter-message-details.service.d.ts.map +1 -1
  86. package/dist/services/chatter-message-details.service.js +2 -3
  87. package/dist/services/chatter-message-details.service.js.map +1 -1
  88. package/dist/services/chatter-message.service.d.ts +3 -2
  89. package/dist/services/chatter-message.service.d.ts.map +1 -1
  90. package/dist/services/chatter-message.service.js +2 -2
  91. package/dist/services/chatter-message.service.js.map +1 -1
  92. package/dist/services/crud.service.d.ts.map +1 -1
  93. package/dist/services/crud.service.js +4 -1
  94. package/dist/services/crud.service.js.map +1 -1
  95. package/dist/services/model-metadata.service.d.ts.map +1 -1
  96. package/dist/services/model-metadata.service.js +4 -1
  97. package/dist/services/model-metadata.service.js.map +1 -1
  98. package/dist/services/request-context.service.d.ts +3 -0
  99. package/dist/services/request-context.service.d.ts.map +1 -1
  100. package/dist/services/request-context.service.js +6 -0
  101. package/dist/services/request-context.service.js.map +1 -1
  102. package/dist/solid-core.module.d.ts.map +1 -1
  103. package/dist/solid-core.module.js +23 -5
  104. package/dist/solid-core.module.js.map +1 -1
  105. package/dist/tsconfig.tsbuildinfo +1 -1
  106. package/package.json +3 -1
  107. package/src/config/iam.config.ts +3 -0
  108. package/src/constants/error-messages.ts +1 -1
  109. package/src/controllers/ai-interaction.controller.ts +4 -2
  110. package/src/controllers/authentication.controller.ts +16 -10
  111. package/src/controllers/email-template.controller.ts +4 -1
  112. package/src/controllers/google-authentication.controller.ts +4 -0
  113. package/src/controllers/media.controller.ts +5 -1
  114. package/src/controllers/model-metadata.controller.ts +7 -2
  115. package/src/controllers/otp-authentication.controller.ts +4 -1
  116. package/src/controllers/service.controller.ts +5 -1
  117. package/src/controllers/sms-template.controller.ts +8 -7
  118. package/src/decorators/solid-password.decorator.ts +51 -0
  119. package/src/dtos/change-password.dto.ts +2 -0
  120. package/src/dtos/confirm-forgot-password.dto.ts +2 -0
  121. package/src/helpers/cors.helper.ts +34 -0
  122. package/src/helpers/security.helper.ts +53 -0
  123. package/src/index.ts +3 -0
  124. package/src/repository/chatter-message-details.repository.ts +109 -0
  125. package/src/repository/chatter-message.repository.ts +68 -0
  126. package/src/repository/security-rule.repository.ts +2 -2
  127. package/src/repository/solid-base.repository.ts +66 -0
  128. package/src/seeders/seed-data/email-templates/password-changed.handlebars.html +158 -0
  129. package/src/seeders/seed-data/solid-core-metadata.json +9 -0
  130. package/src/services/ai-interaction.service.ts +5 -5
  131. package/src/services/authentication.service.ts +181 -56
  132. package/src/services/chatter-message-details.service.ts +3 -2
  133. package/src/services/chatter-message.service.ts +3 -2
  134. package/src/services/crud.service.ts +7 -2
  135. package/src/services/model-metadata.service.ts +15 -1
  136. package/src/services/request-context.service.ts +9 -0
  137. package/src/solid-core.module.ts +29 -5
@@ -1 +1 @@
1
- {"version":3,"file":"ai-interaction.service.d.ts","sourceRoot":"","sources":["../../src/services/ai-interaction.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,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ExD,aAAa,CAAC,QAAQ,EAAE,MAAM;IAexB,uBAAuB,CAAC,EAAE,EAAE,MAAM;CAiDzC"}
@@ -61,11 +61,10 @@ const child_process_1 = require("child_process");
61
61
  const ai_interaction_entity_1 = require("../entities/ai-interaction.entity");
62
62
  const fs = __importStar(require("fs/promises"));
63
63
  const publisher_factory_service_1 = require("./queues/publisher-factory.service");
64
- const request_context_service_1 = require("./request-context.service");
65
64
  const mcp_tool_response_handler_factory_service_1 = require("./mcp-tool-response-handlers/mcp-tool-response-handler-factory.service");
66
65
  const error_messages_1 = require("../constants/error-messages");
67
66
  let AiInteractionService = AiInteractionService_1 = class AiInteractionService extends crud_service_1.CRUDService {
68
- constructor(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, moduleRef, publisherFactory, requestContextService, mcpToolResponseHandlerFactory) {
67
+ constructor(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, moduleRef, publisherFactory, mcpToolResponseHandlerFactory) {
69
68
  super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'aiInteraction', 'solid-core', moduleRef);
70
69
  this.modelMetadataService = modelMetadataService;
71
70
  this.moduleMetadataService = moduleMetadataService;
@@ -77,15 +76,13 @@ let AiInteractionService = AiInteractionService_1 = class AiInteractionService e
77
76
  this.repo = repo;
78
77
  this.moduleRef = moduleRef;
79
78
  this.publisherFactory = publisherFactory;
80
- this.requestContextService = requestContextService;
81
79
  this.mcpToolResponseHandlerFactory = mcpToolResponseHandlerFactory;
82
80
  this.logger = new common_1.Logger(AiInteractionService_1.name);
83
81
  }
84
- async triggerMcpClientJob(prompt, isAutoApply = false, threadId = null) {
85
- const activeUser = this.requestContextService.getActiveUser();
82
+ async triggerMcpClientJob(prompt, userId, isAutoApply = false, threadId = null) {
86
83
  const aiInteraction = await this.create({
87
- userId: activeUser.sub,
88
- threadId: threadId ? threadId : `thread-${activeUser.sub}`,
84
+ userId: userId,
85
+ threadId: threadId ? threadId : `thread-${userId}`,
89
86
  role: 'human',
90
87
  message: prompt,
91
88
  contentType: '',
@@ -213,7 +210,6 @@ exports.AiInteractionService = AiInteractionService = AiInteractionService_1 = _
213
210
  typeorm_2.Repository,
214
211
  core_1.ModuleRef,
215
212
  publisher_factory_service_1.PublisherFactory,
216
- request_context_service_1.RequestContextService,
217
213
  mcp_tool_response_handler_factory_service_1.McpToolResponseHandlerFactory])
218
214
  ], AiInteractionService);
219
215
  //# sourceMappingURL=ai-interaction.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-interaction.service.js","sourceRoot":"","sources":["../../src/services/ai-interaction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyE;AACzE,6CAAwE;AACxE,uCAA2D;AAC3D,qCAAoD;AAEpD,iDAAwD;AACxD,qEAA2E;AAC3E,uEAA6E;AAC7E,2CAA+C;AAC/C,iDAAwD;AACxD,+DAAqE;AACrE,iDAAsC;AACtC,6EAAkE;AAClE,gDAAkC;AAElC,kFAAsE;AACtE,uEAAkE;AAElE,sIAAuH;AACvH,gEAA8D;AAGvD,IAAM,oBAAoB,4BAA1B,MAAM,oBAAqB,SAAQ,0BAA0B;IAGlE,YACW,oBAA0C,EAC1C,qBAA4C,EAC5C,aAA4B,EAC5B,WAAwB,EACxB,gBAAkC,EAClC,iBAAoC,EAE7C,aAAqC,EAErC,IAAwC,EAC/B,SAAoB,EACpB,gBAA2D,EAC3D,qBAA4C,EAC5C,6BAA4D;QAGrE,KAAK,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QAhB1K,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,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CAAC,+BAA+B,CAAC,CAAC;QAClE,CAAC;QAGD,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAIpC,MAAM,cAAc,GAAG,IAAI,CAAC,6BAA6B,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QACnF,IAAI,CAAC,cAAc,EAAE,CAAC;YAEpB,MAAM,IAAI,KAAK,CAAC,+BAAc,CAAC,6BAA6B,CAAC,CAAC;QAChE,CAAC;QAED,MAAM,0BAA0B,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAM7E,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QAEnE,OAAO,0BAA0B,CAAC;IACpC,CAAC;CACF,CAAA;AAtMY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAWR,WAAA,IAAA,6BAAmB,GAAE,CAAA;IAErB,WAAA,IAAA,0BAAgB,EAAC,qCAAa,EAAE,SAAS,CAAC,CAAA;qCARZ,6CAAoB;QACnB,+CAAqB;QAC7B,sBAAa;QACf,0BAAW;QACN,uBAAgB;QACf,uCAAiB;QAErB,uBAAa;QAEtB,oBAAU;QACL,gBAAS;QACF,4CAAgB;QACX,+CAAqB;QACb,yEAA6B;GAjB5D,oBAAoB,CAsMhC","sourcesContent":["import { BadRequestException, Logger, Injectable } from '@nestjs/common';\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { EntityManager, Repository } from 'typeorm';\n\nimport { CRUDService } from 'src/services/crud.service';\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\nimport { ConfigService } from '@nestjs/config';\nimport { FileService } from 'src/services/file.service';\nimport { CrudHelperService } from 'src/services/crud-helper.service';\nimport { spawn } from 'child_process';\nimport { AiInteraction } from '../entities/ai-interaction.entity';\nimport * as fs from 'fs/promises';\nimport { McpResponse, TriggerMcpClientOptions } from 'src/interfaces';\nimport { PublisherFactory } from './queues/publisher-factory.service';\nimport { RequestContextService } from './request-context.service';\nimport { ActiveUserData } from 'src/interfaces/active-user-data.interface';\nimport { McpToolResponseHandlerFactory } from './mcp-tool-response-handlers/mcp-tool-response-handler-factory.service';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\n\n@Injectable()\nexport class AiInteractionService extends CRUDService<AiInteraction> {\n private readonly logger = new Logger(AiInteractionService.name);\n\n constructor(\n readonly modelMetadataService: ModelMetadataService,\n readonly moduleMetadataService: ModuleMetadataService,\n readonly configService: ConfigService,\n readonly fileService: FileService,\n readonly discoveryService: DiscoveryService,\n readonly crudHelperService: CrudHelperService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n @InjectRepository(AiInteraction, 'default')\n readonly repo: Repository<AiInteraction>,\n readonly moduleRef: ModuleRef,\n readonly publisherFactory: PublisherFactory<TriggerMcpClientOptions>,\n readonly requestContextService: RequestContextService,\n readonly mcpToolResponseHandlerFactory: McpToolResponseHandlerFactory,\n\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'aiInteraction', 'solid-core', moduleRef);\n }\n\n async triggerMcpClientJob(prompt: string, isAutoApply: boolean = false, threadId: string = null): Promise<any> {\n const activeUser: ActiveUserData = this.requestContextService.getActiveUser();\n\n const aiInteraction = await this.create({\n userId: activeUser.sub,\n threadId: threadId ? threadId : `thread-${activeUser.sub}`,\n role: 'human',\n message: prompt,\n contentType: '',\n errorMessage: '',\n modelUsed: '',\n responseTimeMs: 0,\n metadata: '',\n isAutoApply: isAutoApply\n });\n const m = {\n payload: {\n aiInteractionId: aiInteraction.id,\n },\n parentEntity: 'aiInteraction',\n parentEntityId: aiInteraction.id,\n };\n\n const queueMessageId = await this.publisherFactory.publish(m, 'TriggerMcpClientPublisher');\n\n return {\n queueMessageId: queueMessageId,\n aiInteractionId: aiInteraction.id\n }\n }\n\n /**\n * Runs the Python MCP client with a prompt and returns the parsed JSON embedded in the 'response'.\n * @param prompt - The question or instruction to send to the MCP client.\n * @returns The parsed object inside the 'response' field of the JSON output.\n */\n async runMcpPrompt(prompt: string): Promise<McpResponse> {\n const pythonExecutable = process.env.MCP_PYTHON_EXECUTABLE;\n const mcpClient = process.env.MCP_CLIENT;\n\n // TODO: We can return an error if the above env variables are not properly setup...\n if (!pythonExecutable || !mcpClient) {\n throw new BadRequestException(ERROR_MESSAGES.PYTHON_EXECUTABLE_NOT_CONFIGURED);\n }\n\n // Check if both paths are valid and accessible\n try {\n const [pyStat, clientStat] = await Promise.all([\n fs.stat(pythonExecutable),\n fs.stat(mcpClient),\n ]);\n\n if (!pyStat.isFile()) {\n throw new BadRequestException(`MCP_PYTHON_EXECUTABLE path is not a file: ${pythonExecutable}`);\n }\n\n if (!clientStat.isFile()) {\n throw new BadRequestException(`MCP_CLIENT path is not a file: ${mcpClient}`);\n }\n\n } catch (err: any) {\n throw new BadRequestException(`Invalid MCP executable or client path: ${err.message}`);\n }\n\n // TODO: Refactor to use the command.service.ts instead...\n return new Promise((resolve, reject) => {\n this.logger.log(`Attempting to run command:`)\n this.logger.log(`${pythonExecutable} ${mcpClient} \"${prompt}\"`);\n\n const python = spawn(pythonExecutable, [mcpClient, `\"${prompt}\"`]);\n\n let stdout = '';\n let stderr = '';\n\n python.stdout.on('data', (data) => {\n stdout += data.toString();\n });\n\n python.stderr.on('data', (data) => {\n stderr += data.toString();\n });\n\n python.on('close', (code) => {\n this.logger.log(`Python script exited with code ${code}`);\n\n if (code !== 0) {\n this.logger.error(`Python script exited with a non-zero exit code: ${stderr}`);\n return reject(new Error(`Python script exited with a non-zero exit code: ${stderr}`));\n }\n\n try {\n this.logger.log(`Python script exited with zero exit code: ${stdout}`);\n const raw: McpResponse = JSON.parse(stdout);\n\n // if (!raw.success) {\n // return reject(new Error(`MCP error: ${raw.errors?.join(', ')}`));\n // }\n // let cleaned = raw.response.trim();\n\n // Don't need to re-parse this...\n // const parsed = JSON.parse(cleaned);\n // resolve(cleaned);\n\n resolve(raw);\n } catch (err: any) {\n reject(new Error(`Mcp Invocation Failed: ${err.message}`));\n }\n });\n });\n }\n\n cleanResponse(response: string) {\n this.logger.log(`mcp server response is: ${response}`);\n\n // Remove markdown-style code block wrapper\n if (response.startsWith('```json')) {\n response = response.replace(/^```json/, '').trim();\n }\n if (response.endsWith('```')) {\n response = response.replace(/```$/, '').trim();\n }\n this.logger.log(`mcp server response after removing doc tags is: ${response}`);\n\n return response;\n }\n\n async applySolidAiInteraction(id: number) {\n // Fetch the aiInteraction\n const aiInteraction = await this.findOne(id, {\n populate: ['user']\n });\n if (!aiInteraction) {\n const m = `Unable to identified the aiInteraction entry that triggered this job... using id: ${id}`\n\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(m);\n }\n\n // TODO: Validation: Check if JSON.parse(metadata).tools_invoked starts with solid_\n let metadata = {};\n try {\n metadata = JSON.parse(aiInteraction.metadata);\n }\n catch (e) {\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(e);\n }\n\n const toolsInvoked = metadata['tools_invoked'];\n if (!toolsInvoked) {\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(ERROR_MESSAGES.UNABLE_TO_RESOLVE_SOLID_COMMAND);\n }\n\n // TODO: OPTIMISATION for chained tool invocation, for now we are assuming only 1 tool was used.\n const toolInvoked = toolsInvoked[0];\n\n // TODO: use the toolInvoked to identify a service using some convention.\n // TODO: Eg. if toolInvoked is solid_create_module <> SolidCreateModuleMcpToolHandler ... create a factory class to do this mapping and identify the relevant provider. \n const mcpToolHandler = this.mcpToolResponseHandlerFactory.getInstance(toolInvoked);\n if (!mcpToolHandler) {\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(ERROR_MESSAGES.UNABLE_TO_RESOLVE_MCP_HANDLER);\n }\n\n const handlerApplicationResponse = await mcpToolHandler.apply(aiInteraction);\n\n // TODO: This provider to implement an interface - IMcpToolResponseHandler ... apply(aiInteraction: AiInteraction)\n // throw new Error('Method not implemented.');\n\n // Mark the interaction as applied\n await this.update(aiInteraction.id, { isApplied: true }, [], true);\n\n return handlerApplicationResponse;\n }\n}\n"]}
1
+ {"version":3,"file":"ai-interaction.service.js","sourceRoot":"","sources":["../../src/services/ai-interaction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyE;AACzE,6CAAwE;AACxE,uCAA2D;AAC3D,qCAAoD;AAEpD,iDAAwD;AACxD,qEAA2E;AAC3E,uEAA6E;AAC7E,2CAA+C;AAC/C,iDAAwD;AACxD,+DAAqE;AACrE,iDAAsC;AACtC,6EAAkE;AAClE,gDAAkC;AAElC,kFAAsE;AAGtE,sIAAuH;AACvH,gEAA8D;AAGvD,IAAM,oBAAoB,4BAA1B,MAAM,oBAAqB,SAAQ,0BAA0B;IAGlE,YACW,oBAA0C,EAC1C,qBAA4C,EAC5C,aAA4B,EAC5B,WAAwB,EACxB,gBAAkC,EAClC,iBAAoC,EAE7C,aAAqC,EAErC,IAAwC,EAC/B,SAAoB,EACpB,gBAA2D,EAE3D,6BAA4D;QAGrE,KAAK,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QAhB1K,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,kBAAa,GAAb,aAAa,CAAe;QAC5B,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,sBAAiB,GAAjB,iBAAiB,CAAmB;QAE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A6B,CAAC,CAAC;QAChE,CAAC;QAED,MAAM,0BAA0B,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAM7E,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QAEnE,OAAO,0BAA0B,CAAC;IACpC,CAAC;CACF,CAAA;AAtMY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAWR,WAAA,IAAA,6BAAmB,GAAE,CAAA;IAErB,WAAA,IAAA,0BAAgB,EAAC,qCAAa,EAAE,SAAS,CAAC,CAAA;qCARZ,6CAAoB;QACnB,+CAAqB;QAC7B,sBAAa;QACf,0BAAW;QACN,uBAAgB;QACf,uCAAiB;QAErB,uBAAa;QAEtB,oBAAU;QACL,gBAAS;QACF,4CAAgB;QAEH,yEAA6B;GAjB5D,oBAAoB,CAsMhC","sourcesContent":["import { BadRequestException, Logger, Injectable } from '@nestjs/common';\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { EntityManager, Repository } from 'typeorm';\n\nimport { CRUDService } from 'src/services/crud.service';\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\nimport { ConfigService } from '@nestjs/config';\nimport { FileService } from 'src/services/file.service';\nimport { CrudHelperService } from 'src/services/crud-helper.service';\nimport { spawn } from 'child_process';\nimport { AiInteraction } from '../entities/ai-interaction.entity';\nimport * as fs from 'fs/promises';\nimport { McpResponse, TriggerMcpClientOptions } from 'src/interfaces';\nimport { PublisherFactory } from './queues/publisher-factory.service';\nimport { RequestContextService } from './request-context.service';\nimport { ActiveUserData } from 'src/interfaces/active-user-data.interface';\nimport { McpToolResponseHandlerFactory } from './mcp-tool-response-handlers/mcp-tool-response-handler-factory.service';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\n\n@Injectable()\nexport class AiInteractionService extends CRUDService<AiInteraction> {\n private readonly logger = new Logger(AiInteractionService.name);\n\n constructor(\n readonly modelMetadataService: ModelMetadataService,\n readonly moduleMetadataService: ModuleMetadataService,\n readonly configService: ConfigService,\n readonly fileService: FileService,\n readonly discoveryService: DiscoveryService,\n readonly crudHelperService: CrudHelperService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n @InjectRepository(AiInteraction, 'default')\n readonly repo: Repository<AiInteraction>,\n readonly moduleRef: ModuleRef,\n readonly publisherFactory: PublisherFactory<TriggerMcpClientOptions>,\n // readonly requestContextService: RequestContextService,\n readonly mcpToolResponseHandlerFactory: McpToolResponseHandlerFactory,\n\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'aiInteraction', 'solid-core', moduleRef);\n }\n\n async triggerMcpClientJob(prompt: string, userId: number, isAutoApply: boolean = false, threadId: string = null): Promise<any> {\n // const activeUser: ActiveUserData = this.requestContextService.getActiveUser();\n\n const aiInteraction = await this.create({\n userId: userId,\n threadId: threadId ? threadId : `thread-${userId}`,\n role: 'human',\n message: prompt,\n contentType: '',\n errorMessage: '',\n modelUsed: '',\n responseTimeMs: 0,\n metadata: '',\n isAutoApply: isAutoApply\n });\n const m = {\n payload: {\n aiInteractionId: aiInteraction.id,\n },\n parentEntity: 'aiInteraction',\n parentEntityId: aiInteraction.id,\n };\n\n const queueMessageId = await this.publisherFactory.publish(m, 'TriggerMcpClientPublisher');\n\n return {\n queueMessageId: queueMessageId,\n aiInteractionId: aiInteraction.id\n }\n }\n\n /**\n * Runs the Python MCP client with a prompt and returns the parsed JSON embedded in the 'response'.\n * @param prompt - The question or instruction to send to the MCP client.\n * @returns The parsed object inside the 'response' field of the JSON output.\n */\n async runMcpPrompt(prompt: string): Promise<McpResponse> {\n const pythonExecutable = process.env.MCP_PYTHON_EXECUTABLE;\n const mcpClient = process.env.MCP_CLIENT;\n\n // TODO: We can return an error if the above env variables are not properly setup...\n if (!pythonExecutable || !mcpClient) {\n throw new BadRequestException(ERROR_MESSAGES.PYTHON_EXECUTABLE_NOT_CONFIGURED);\n }\n\n // Check if both paths are valid and accessible\n try {\n const [pyStat, clientStat] = await Promise.all([\n fs.stat(pythonExecutable),\n fs.stat(mcpClient),\n ]);\n\n if (!pyStat.isFile()) {\n throw new BadRequestException(`MCP_PYTHON_EXECUTABLE path is not a file: ${pythonExecutable}`);\n }\n\n if (!clientStat.isFile()) {\n throw new BadRequestException(`MCP_CLIENT path is not a file: ${mcpClient}`);\n }\n\n } catch (err: any) {\n throw new BadRequestException(`Invalid MCP executable or client path: ${err.message}`);\n }\n\n // TODO: Refactor to use the command.service.ts instead...\n return new Promise((resolve, reject) => {\n this.logger.log(`Attempting to run command:`)\n this.logger.log(`${pythonExecutable} ${mcpClient} \"${prompt}\"`);\n\n const python = spawn(pythonExecutable, [mcpClient, `\"${prompt}\"`]);\n\n let stdout = '';\n let stderr = '';\n\n python.stdout.on('data', (data) => {\n stdout += data.toString();\n });\n\n python.stderr.on('data', (data) => {\n stderr += data.toString();\n });\n\n python.on('close', (code) => {\n this.logger.log(`Python script exited with code ${code}`);\n\n if (code !== 0) {\n this.logger.error(`Python script exited with a non-zero exit code: ${stderr}`);\n return reject(new Error(`Python script exited with a non-zero exit code: ${stderr}`));\n }\n\n try {\n this.logger.log(`Python script exited with zero exit code: ${stdout}`);\n const raw: McpResponse = JSON.parse(stdout);\n\n // if (!raw.success) {\n // return reject(new Error(`MCP error: ${raw.errors?.join(', ')}`));\n // }\n // let cleaned = raw.response.trim();\n\n // Don't need to re-parse this...\n // const parsed = JSON.parse(cleaned);\n // resolve(cleaned);\n\n resolve(raw);\n } catch (err: any) {\n reject(new Error(`Mcp Invocation Failed: ${err.message}`));\n }\n });\n });\n }\n\n cleanResponse(response: string) {\n this.logger.log(`mcp server response is: ${response}`);\n\n // Remove markdown-style code block wrapper\n if (response.startsWith('```json')) {\n response = response.replace(/^```json/, '').trim();\n }\n if (response.endsWith('```')) {\n response = response.replace(/```$/, '').trim();\n }\n this.logger.log(`mcp server response after removing doc tags is: ${response}`);\n\n return response;\n }\n\n async applySolidAiInteraction(id: number) {\n // Fetch the aiInteraction\n const aiInteraction = await this.findOne(id, {\n populate: ['user']\n });\n if (!aiInteraction) {\n const m = `Unable to identified the aiInteraction entry that triggered this job... using id: ${id}`\n\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(m);\n }\n\n // TODO: Validation: Check if JSON.parse(metadata).tools_invoked starts with solid_\n let metadata = {};\n try {\n metadata = JSON.parse(aiInteraction.metadata);\n }\n catch (e) {\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(e);\n }\n\n const toolsInvoked = metadata['tools_invoked'];\n if (!toolsInvoked) {\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(ERROR_MESSAGES.UNABLE_TO_RESOLVE_SOLID_COMMAND);\n }\n\n // TODO: OPTIMISATION for chained tool invocation, for now we are assuming only 1 tool was used.\n const toolInvoked = toolsInvoked[0];\n\n // TODO: use the toolInvoked to identify a service using some convention.\n // TODO: Eg. if toolInvoked is solid_create_module <> SolidCreateModuleMcpToolHandler ... create a factory class to do this mapping and identify the relevant provider. \n const mcpToolHandler = this.mcpToolResponseHandlerFactory.getInstance(toolInvoked);\n if (!mcpToolHandler) {\n // TODO: RESPONSE SHAPE ALERT Check if we want to control the shape of the response....\n throw new Error(ERROR_MESSAGES.UNABLE_TO_RESOLVE_MCP_HANDLER);\n }\n\n const handlerApplicationResponse = await mcpToolHandler.apply(aiInteraction);\n\n // TODO: This provider to implement an interface - IMcpToolResponseHandler ... apply(aiInteraction: AiInteraction)\n // throw new Error('Method not implemented.');\n\n // Mark the interaction as applied\n await this.update(aiInteraction.id, { isApplied: true }, [], true);\n\n return handlerApplicationResponse;\n }\n}\n"]}
@@ -3,7 +3,7 @@ import { ConfigType } from '@nestjs/config';
3
3
  import { EventEmitter2 } from '@nestjs/event-emitter';
4
4
  import { JwtService } from '@nestjs/jwt';
5
5
  import { Msg91OTPService } from 'src/services/sms/Msg91OTPService';
6
- import { Repository } from 'typeorm';
6
+ import { DataSource, Repository } from 'typeorm';
7
7
  import { iamConfig, jwtConfig } from '../config/iam.config';
8
8
  import { ChangePasswordDto } from "../dtos/change-password.dto";
9
9
  import { ConfirmForgotPasswordDto } from '../dtos/confirm-forgot-password.dto';
@@ -45,11 +45,13 @@ export declare class AuthenticationService {
45
45
  private readonly commonConfiguration;
46
46
  private readonly userActivityHistoryService;
47
47
  private readonly requestContextService;
48
+ private readonly dataSource;
48
49
  private readonly logger;
49
- constructor(userService: UserService, userRepository: Repository<User>, userPasswordHistoryRepository: Repository<UserPasswordHistory>, hashingService: HashingService, jwtService: JwtService, jwtConfiguration: ConfigType<typeof jwtConfig>, iamConfiguration: ConfigType<typeof iamConfig>, refreshTokenIdsStorage: RefreshTokenIdsStorageService, httpService: HttpService, mailServiceFactory: MailFactory, smsService: Msg91OTPService, eventEmitter: EventEmitter2, settingService: SettingService, roleMetadataService: RoleMetadataService, commonConfiguration: ConfigType<typeof commonConfig>, userActivityHistoryService: UserActivityHistoryService, requestContextService: RequestContextService);
50
+ constructor(userService: UserService, userRepository: Repository<User>, userPasswordHistoryRepository: Repository<UserPasswordHistory>, hashingService: HashingService, jwtService: JwtService, jwtConfiguration: ConfigType<typeof jwtConfig>, iamConfiguration: ConfigType<typeof iamConfig>, refreshTokenIdsStorage: RefreshTokenIdsStorageService, httpService: HttpService, mailServiceFactory: MailFactory, smsService: Msg91OTPService, eventEmitter: EventEmitter2, settingService: SettingService, roleMetadataService: RoleMetadataService, commonConfiguration: ConfigType<typeof commonConfig>, userActivityHistoryService: UserActivityHistoryService, requestContextService: RequestContextService, dataSource: DataSource);
50
51
  private getConfig;
51
52
  private getCompanyLogo;
52
53
  resolveUser(username: string, email: string): Promise<User>;
54
+ resolveUserByVerificationToken(token: string): Promise<User>;
53
55
  validateUser(signInDto: SignInDto): Promise<User>;
54
56
  signUp(signUpDto: SignUpDto, activeUser?: ActiveUserData): Promise<User>;
55
57
  signupForExtensionUser<T extends User, U extends CreateUserDto>(signUpDto: SignUpDto, extensionUserDto: U, extensionUserRepo: Repository<T>): Promise<T>;
@@ -100,6 +102,7 @@ export declare class AuthenticationService {
100
102
  };
101
103
  }>;
102
104
  changePassword(changePasswordDto: ChangePasswordDto, activeUser: ActiveUserData): Promise<boolean>;
105
+ private generateForgotPasswordToken;
103
106
  initiateForgotPassword(initiateForgotPasswordDto: InitiateForgotPasswordDto): Promise<{
104
107
  status: string;
105
108
  message: string;
@@ -121,6 +124,7 @@ export declare class AuthenticationService {
121
124
  errorCode: string;
122
125
  data: {};
123
126
  }>;
127
+ private notifyUserOnPasswordChanged;
124
128
  private isPasswordDuplicate;
125
129
  private deleteOldPasswords;
126
130
  generateTokens(user: User): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.service.d.ts","sourceRoot":"","sources":["../../src/services/authentication.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAW5C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6B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,CAAC,UAAU;IAUlB,OAAO,CAAC,4BAA4B;IASpC,OAAO,CAAC,0BAA0B;YAwBpB,mCAAmC;IAwC3C,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB;;;;IAsD/D,OAAO,CAAC,wBAAwB;IAMhC,wCAAwC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAe7D,OAAO,CAAC,GAAG;IASL,MAAM,CAAC,SAAS,EAAE,SAAS;;;;;;;;;;;;IAqB3B,gBAAgB,CAAC,SAAS,EAAE,YAAY;;;YA6ChC,6BAA6B;IAyCrC,eAAe,CAAC,gBAAgB,EAAE,gBAAgB;;;;;;;;;;;;IA+DlD,cAAc,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc;IA4DrF,OAAO,CAAC,2BAA2B;IAY7B,sBAAsB,CAAC,yBAAyB,EAAE,yBAAyB;;;;;;;;;;;;;YA4CnE,0BAA0B;IA0ClC,qBAAqB,CAAC,wBAAwB,EAAE,wBAAwB;;;;;;;YA4DhE,2BAA2B;YAsG3B,mBAAmB;YAoBnB,kBAAkB;IAgB1B,cAAc,CAAC,IAAI,EAAE,IAAI;;;;IAazB,mBAAmB,CAAC,IAAI,EAAE,IAAI;IAc9B,oBAAoB,CAAC,IAAI,EAAE,IAAI;IAa/B,aAAa,CAAC,eAAe,EAAE,eAAe;;;;YA+CtC,SAAS;IAgBjB,uBAAuB,CAAC,IAAI,EAAE,IAAI;IAkBlC,iBAAiB,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;YA8B5B,iCAAiC;IAWzC,MAAM;;;IAyBN,YAAY,CAAC,MAAM,EAAE,MAAM;IAS3B,EAAE,CAAC,UAAU,EAAE,cAAc;;;;;;;;;;;CAyBtC"}
@@ -42,6 +42,7 @@ const request_context_service_1 = require("./request-context.service");
42
42
  const error_messages_1 = require("../constants/error-messages");
43
43
  const success_messages_1 = require("../constants/success-messages");
44
44
  const mail_factory_1 = require("../factories/mail.factory");
45
+ const uuid_1 = require("uuid");
45
46
  var LoginProvider;
46
47
  (function (LoginProvider) {
47
48
  LoginProvider["LOCAL"] = "local";
@@ -49,7 +50,7 @@ var LoginProvider;
49
50
  LoginProvider["OTP"] = "otp";
50
51
  })(LoginProvider || (LoginProvider = {}));
51
52
  let AuthenticationService = AuthenticationService_1 = class AuthenticationService {
52
- constructor(userService, userRepository, userPasswordHistoryRepository, hashingService, jwtService, jwtConfiguration, iamConfiguration, refreshTokenIdsStorage, httpService, mailServiceFactory, smsService, eventEmitter, settingService, roleMetadataService, commonConfiguration, userActivityHistoryService, requestContextService) {
53
+ constructor(userService, userRepository, userPasswordHistoryRepository, hashingService, jwtService, jwtConfiguration, iamConfiguration, refreshTokenIdsStorage, httpService, mailServiceFactory, smsService, eventEmitter, settingService, roleMetadataService, commonConfiguration, userActivityHistoryService, requestContextService, dataSource) {
53
54
  this.userService = userService;
54
55
  this.userRepository = userRepository;
55
56
  this.userPasswordHistoryRepository = userPasswordHistoryRepository;
@@ -67,6 +68,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
67
68
  this.commonConfiguration = commonConfiguration;
68
69
  this.userActivityHistoryService = userActivityHistoryService;
69
70
  this.requestContextService = requestContextService;
71
+ this.dataSource = dataSource;
70
72
  this.logger = new common_1.Logger(AuthenticationService_1.name);
71
73
  }
72
74
  async getConfig(key) {
@@ -86,6 +88,12 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
86
88
  }
87
89
  });
88
90
  }
91
+ async resolveUserByVerificationToken(token) {
92
+ return await this.userRepository.findOne({
93
+ where: { verificationTokenOnForgotPassword: token },
94
+ relations: { roles: true }
95
+ });
96
+ }
89
97
  async validateUser(signInDto) {
90
98
  const user = await this.resolveUser(signInDto.username, signInDto.email);
91
99
  if (!user) {
@@ -580,18 +588,28 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
580
588
  await this.userPasswordHistoryRepository.save(userPasswordHistory);
581
589
  return true;
582
590
  }
591
+ generateForgotPasswordToken() {
592
+ const expiryTime = new Date();
593
+ expiryTime.setMinutes(expiryTime.getMinutes() + this.iamConfiguration.forgotPasswordVerificationTokenExpiry);
594
+ return {
595
+ token: this.iamConfiguration.dummyOtp
596
+ ? this.iamConfiguration.dummyOtp
597
+ : (0, uuid_1.v4)(),
598
+ expiresAt: expiryTime,
599
+ };
600
+ }
583
601
  async initiateForgotPassword(initiateForgotPasswordDto) {
584
602
  const user = await this.resolveUser(initiateForgotPasswordDto.username, initiateForgotPasswordDto.email);
585
603
  if (!user) {
586
- throw new common_1.NotFoundException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
604
+ throw new common_1.NotFoundException(error_messages_1.ERROR_MESSAGES.INVALID_CREDENTIALS);
587
605
  }
588
606
  if (!user.active) {
589
- throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_INACTIVE);
607
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_CREDENTIALS);
590
608
  }
591
609
  if (user.lastLoginProvider !== 'local') {
592
- throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.NON_LOCAL_PROVIDER);
610
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.INVALID_CREDENTIALS);
593
611
  }
594
- const { token, expiresAt } = this.otp();
612
+ const { token, expiresAt } = this.generateForgotPasswordToken();
595
613
  user.verificationTokenOnForgotPassword = token;
596
614
  user.verificationTokenOnForgotPasswordExpiresAt = expiresAt;
597
615
  await this.userRepository.save(user);
@@ -620,7 +638,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
620
638
  solidAppWebsiteUrl: process.env.SOLID_APP_WEBSITE_URL,
621
639
  firstName: user.username,
622
640
  fullName: user.fullName,
623
- passwordResetLink: `${process.env.IAM_FRONTEND_APP_FORGOT_PASSWORD_PAGE_URL}?token=${user.verificationTokenOnForgotPassword}&username=${user.username}`,
641
+ passwordResetLink: `${process.env.IAM_FRONTEND_APP_FORGOT_PASSWORD_PAGE_URL}?token=${user.verificationTokenOnForgotPassword}`,
624
642
  companyLogoUrl: companyLogo
625
643
  }, this.commonConfiguration.shouldQueueEmails, null, null, 'user', user.id);
626
644
  }
@@ -635,44 +653,75 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
635
653
  }
636
654
  }
637
655
  async confirmForgotPassword(confirmForgotPasswordDto) {
638
- const user = await this.resolveUser(confirmForgotPasswordDto.username, confirmForgotPasswordDto.email);
639
- if (!user) {
640
- throw new common_1.NotFoundException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
641
- }
642
- if (user.lastLoginProvider !== 'local') {
643
- throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.NON_LOCAL_PROVIDER);
644
- }
645
- if (!user.active) {
646
- throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_INACTIVE);
647
- }
648
- if (user.verificationTokenOnForgotPassword !== confirmForgotPasswordDto.verificationToken) {
649
- throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TOKEN);
650
- }
651
- if (user.verificationTokenOnForgotPasswordExpiresAt < new Date()) {
652
- throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TOKEN);
656
+ return this.dataSource.transaction(async (m) => {
657
+ const user = await this.resolveUserByVerificationToken(confirmForgotPasswordDto.verificationToken);
658
+ if (!user)
659
+ throw new common_1.NotFoundException(error_messages_1.ERROR_MESSAGES.INVALID_CREDENTIALS);
660
+ if (user.lastLoginProvider !== 'local')
661
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.INVALID_CREDENTIALS);
662
+ if (!user.active)
663
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_CREDENTIALS);
664
+ const { affected } = await m
665
+ .createQueryBuilder()
666
+ .update(user_entity_1.User)
667
+ .set({
668
+ forgotPasswordConfirmedAt: () => 'NOW()',
669
+ verificationTokenOnForgotPassword: () => 'NULL',
670
+ verificationTokenOnForgotPasswordExpiresAt: () => 'NULL',
671
+ })
672
+ .where('id = :id', { id: user.id })
673
+ .andWhere('verificationTokenOnForgotPassword = :token', { token: confirmForgotPasswordDto.verificationToken })
674
+ .andWhere('verificationTokenOnForgotPasswordExpiresAt > NOW()')
675
+ .execute();
676
+ if (affected !== 1) {
677
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_CREDENTIALS);
678
+ }
679
+ const pwdHash = await this.hashingService.hash(confirmForgotPasswordDto.password);
680
+ const tempUser = { ...user, password: pwdHash };
681
+ if (await this.isPasswordDuplicate(tempUser)) {
682
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORD_REUSED);
683
+ }
684
+ await this.deleteOldPasswords(user);
685
+ await m.getRepository(user_entity_1.User).update({ id: user.id }, { password: pwdHash });
686
+ const history = m.getRepository(user_password_history_entity_1.UserPasswordHistory).create({
687
+ user: { id: user.id },
688
+ passwordHash: pwdHash,
689
+ });
690
+ await m.getRepository(user_password_history_entity_1.UserPasswordHistory).save(history);
691
+ this.notifyUserOnPasswordChanged(user);
692
+ return {
693
+ status: 'success',
694
+ message: success_messages_1.SUCCESS_MESSAGES.FORGOT_PASSWORD_CONFIRMED,
695
+ error: '',
696
+ errorCode: '',
697
+ data: {},
698
+ };
699
+ });
700
+ }
701
+ async notifyUserOnPasswordChanged(user) {
702
+ const companyLogo = await this.getCompanyLogo();
703
+ const forgotPasswordSendVerificationTokenOn = this.iamConfiguration.forgotPasswordSendVerificationTokenOn;
704
+ if (forgotPasswordSendVerificationTokenOn == constants_1.ForgotPasswordSendVerificationTokenOn.EMAIL) {
705
+ const mailService = this.mailServiceFactory.getMailService();
706
+ mailService.sendEmailUsingTemplate(user.email, 'password-changed', {
707
+ solidAppName: process.env.SOLID_APP_NAME,
708
+ solidAppWebsiteUrl: process.env.SOLID_APP_WEBSITE_URL,
709
+ email: user.email,
710
+ firstName: user.username,
711
+ fullName: user.fullName,
712
+ passwordResetLink: `${process.env.IAM_FRONTEND_APP_FORGOT_PASSWORD_PAGE_URL}?token=${user.verificationTokenOnForgotPassword}`,
713
+ companyLogoUrl: companyLogo
714
+ }, this.commonConfiguration.shouldQueueEmails, null, null, 'user', user.id);
653
715
  }
654
- user.forgotPasswordConfirmedAt = new Date();
655
- user.verificationTokenOnForgotPassword = null;
656
- user.verificationTokenOnForgotPasswordExpiresAt = null;
657
- const pwd = await this.hashingService.hash(confirmForgotPasswordDto.password);
658
- user.password = confirmForgotPasswordDto.password;
659
- if (await this.isPasswordDuplicate(user)) {
660
- throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORD_REUSED);
716
+ if (forgotPasswordSendVerificationTokenOn == constants_1.ForgotPasswordSendVerificationTokenOn.MOBILE && user.mobile) {
717
+ this.smsService.sendSMSUsingTemplate(user.mobile, 'forgot-password', {
718
+ solidAppName: process.env.SOLID_APP_NAME,
719
+ otp: user.verificationTokenOnForgotPassword,
720
+ verificationTokenOnForgotPassword: user.verificationTokenOnForgotPassword,
721
+ firstName: user.username,
722
+ companyLogoUrl: companyLogo
723
+ });
661
724
  }
662
- await this.deleteOldPasswords(user);
663
- user.password = pwd;
664
- const userPasswordHistory = new user_password_history_entity_1.UserPasswordHistory();
665
- userPasswordHistory.passwordHash = pwd;
666
- userPasswordHistory.user = user;
667
- await this.userRepository.save(user);
668
- await this.userPasswordHistoryRepository.save(userPasswordHistory);
669
- return {
670
- status: 'success',
671
- message: success_messages_1.SUCCESS_MESSAGES.FORGOT_PASSWORD_CONFIRMED,
672
- error: '',
673
- errorCode: '',
674
- data: {}
675
- };
676
725
  }
677
726
  async isPasswordDuplicate(user) {
678
727
  const userPwdHistoryEntityArray = await this.userPasswordHistoryRepository.findBy({ user: { id: user.id } });
@@ -862,6 +911,7 @@ exports.AuthenticationService = AuthenticationService = AuthenticationService_1
862
911
  __param(5, (0, common_1.Inject)(iam_config_1.jwtConfig.KEY)),
863
912
  __param(6, (0, common_1.Inject)(iam_config_1.iamConfig.KEY)),
864
913
  __param(14, (0, common_1.Inject)(common_config_1.default.KEY)),
914
+ __param(17, (0, typeorm_1.InjectDataSource)()),
865
915
  __metadata("design:paramtypes", [user_service_1.UserService,
866
916
  typeorm_2.Repository,
867
917
  typeorm_2.Repository,
@@ -873,7 +923,8 @@ exports.AuthenticationService = AuthenticationService = AuthenticationService_1
873
923
  event_emitter_1.EventEmitter2,
874
924
  setting_service_1.SettingService,
875
925
  role_metadata_service_1.RoleMetadataService, void 0, user_activity_history_service_1.UserActivityHistoryService,
876
- request_context_service_1.RequestContextService])
926
+ request_context_service_1.RequestContextService,
927
+ typeorm_2.DataSource])
877
928
  ], AuthenticationService);
878
929
  function parseUniqueConstraintError(detail) {
879
930
  const match = detail.match(/Key \(([^)]+)\)=\(([^)]+)\) already exists\./);