@solidxai/core 0.1.18-beta.0 → 0.1.19-beta.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.
- package/CHANGELOG.md +1353 -0
- package/CLAUDE.md +26 -0
- package/dist/commands/seed.command.d.ts +2 -0
- package/dist/commands/seed.command.d.ts.map +1 -1
- package/dist/commands/seed.command.js +10 -2
- package/dist/commands/seed.command.js.map +1 -1
- package/dist/constants/error-messages.d.ts +2 -0
- package/dist/constants/error-messages.d.ts.map +1 -1
- package/dist/constants/error-messages.js +2 -0
- package/dist/constants/error-messages.js.map +1 -1
- package/dist/decorators/login-extension-provider.decorator.d.ts +3 -0
- package/dist/decorators/login-extension-provider.decorator.d.ts.map +1 -0
- package/dist/decorators/login-extension-provider.decorator.js +8 -0
- package/dist/decorators/login-extension-provider.decorator.js.map +1 -0
- package/dist/helpers/bootstrap.helper.d.ts +1 -0
- package/dist/helpers/bootstrap.helper.d.ts.map +1 -1
- package/dist/helpers/bootstrap.helper.js +7 -6
- package/dist/helpers/bootstrap.helper.js.map +1 -1
- package/dist/helpers/solid-core-error-codes-provider.service.d.ts.map +1 -1
- package/dist/helpers/solid-core-error-codes-provider.service.js +18 -0
- package/dist/helpers/solid-core-error-codes-provider.service.js.map +1 -1
- package/dist/helpers/solid-registry.d.ts +5 -1
- package/dist/helpers/solid-registry.d.ts.map +1 -1
- package/dist/helpers/solid-registry.js +16 -0
- package/dist/helpers/solid-registry.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +24 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js +6 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +1 -0
- package/dist/services/authentication.service.d.ts +11 -1
- package/dist/services/authentication.service.d.ts.map +1 -1
- package/dist/services/authentication.service.js +70 -4
- package/dist/services/authentication.service.js.map +1 -1
- package/dist/services/dashboard-providers/mq-dashboard-recent-failures-provider.service.d.ts +21 -1
- package/dist/services/dashboard-providers/mq-dashboard-recent-failures-provider.service.d.ts.map +1 -1
- package/dist/services/dashboard-providers/mq-dashboard-recent-failures-provider.service.js +10 -10
- package/dist/services/dashboard-providers/mq-dashboard-recent-failures-provider.service.js.map +1 -1
- package/dist/services/solid-introspect.service.d.ts +1 -0
- package/dist/services/solid-introspect.service.d.ts.map +1 -1
- package/dist/services/solid-introspect.service.js +11 -0
- package/dist/services/solid-introspect.service.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/seed.command.ts +7 -2
- package/src/constants/error-messages.ts +2 -0
- package/src/decorators/login-extension-provider.decorator.ts +6 -0
- package/src/helpers/bootstrap.helper.ts +31 -8
- package/src/helpers/solid-core-error-codes-provider.service.ts +21 -0
- package/src/helpers/solid-registry.ts +19 -1
- package/src/index.ts +1 -0
- package/src/interfaces.ts +93 -0
- package/src/seeders/seed-data/solid-core-metadata.json +1 -0
- package/src/services/authentication.service.ts +135 -3
- package/src/services/dashboard-providers/mq-dashboard-recent-failures-provider.service.ts +31 -13
- package/src/services/solid-introspect.service.ts +13 -0
package/dist/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;AA8DA,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,wCAAwB,CAAA;IACxB,6DAA6C,CAAA;IAC7C,6DAA6C,CAAA;IAC7C,8CAA8B,CAAA;AAChC,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AA8LD,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,gDAAmC,CAAA;IACnC,8EAAiE,CAAA;IACjE,gFAAmE,CAAA;AACrE,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB;AAED,MAAa,YAAY;IACvB,YACS,IAAS,EACT,OAAU;QADV,SAAI,GAAJ,IAAI,CAAK;QACT,YAAO,GAAP,OAAO,CAAG;IACf,CAAC;CACN;AALD,oCAKC;AA4FD,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,mCAAqB,CAAA;IACrB,6BAAe,CAAA;AACjB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB","sourcesContent":["import { Repository } from 'typeorm';\nimport { User } from 'src/entities/user.entity';\nimport { CreateUserDto } from 'src/dtos/create-user.dto';\nimport { CreateEmailTemplateDto } from 'src/dtos/create-email-template.dto';\nimport { CreateSmsTemplateDto } from 'src/dtos/create-sms-template.dto';\nimport { SignUpDto } from 'src/dtos/sign-up.dto';\nimport { Readable } from 'stream';\nimport { CreateMediaStorageProviderMetadataDto } from './dtos/create-media-storage-provider-metadata.dto';\nimport { DatasourceType } from './dtos/create-model-metadata.dto';\nimport { CreateModuleMetadataDto } from './dtos/create-module-metadata.dto';\nimport { CreateRoleMetadataDto } from './dtos/create-role-metadata.dto';\nimport { CreateSecurityRuleDto } from './dtos/create-security-rule.dto';\nimport { FieldMetadata } from './entities/field-metadata.entity';\nimport { Media } from './entities/media.entity';\nimport { ComputedFieldMetadata } from './helpers/solid-registry';\nimport { ActiveUserData } from './interfaces/active-user-data.interface';\nimport { SecurityRuleConfig } from './dtos/security-rule-config.dto';\nimport { SecurityRule } from './entities/security-rule.entity';\nimport { ModelMetadata } from './entities/model-metadata.entity';\nimport { ViewMetadata } from './entities/view-metadata.entity';\n\nexport interface FieldCrudManager {\n // fieldMetadata: FieldMetadata;\n // entityManager?: EntityManager;\n // createDto: any;\n // files : Array<Express.Multer.File>;\n validate(\n dto: any,\n files: Array<Express.Multer.File>,\n ): ValidationError[] | Promise<ValidationError[]>;\n transformForCreate(dto: any, ctxt?: any): any | Promise<any>;\n}\n\nexport interface ValidationError {\n field: string;\n error: string;\n}\n\n// export interface MediaStorage\nexport interface MediaStorageProvider<T> {\n store(files: Express.Multer.File[], entity: T, mediaFieldMetadata: FieldMetadata): Promise<Media[]>;\n delete(entity: T, mediaFieldMetadata: FieldMetadata): Promise<void>;\n deleteByMediaRecord(media: Media): Promise<void>;\n retrieve(entity: T, mediaFieldMetadata: FieldMetadata): Promise<Media[]>;\n storeStreams(streamPairs: [Readable, string][], entity: T, mediaFieldMetadata: FieldMetadata): Promise<Media[]>;\n // delete(file: string): Promise<void>;\n}\n\nexport interface ModuleMetadataConfiguration {\n moduleMetadata?: CreateModuleMetadataDto,\n roles?: CreateRoleMetadataDto[],\n users?: SignUpDto[],\n actions?: any[],\n menus?: any[],\n views?: any[],\n emailTemplates?: CreateEmailTemplateDto[],\n smsTemplates?: CreateSmsTemplateDto[],\n mediaStorageProviders?: CreateMediaStorageProviderMetadataDto[]\n securityRules?: CreateSecurityRuleDto[],\n dashboards?: any[],\n}\n\nexport enum SettingLevel {\n SystemEnv = 'system-env',\n SystemAdminReadonly = 'system-admin-readonly',\n SystemAdminEditable = 'system-admin-editable',\n InternalUser = \"internal-user\"\n}\n\nexport type SettingControlType =\n | 'shortText'\n | 'longText'\n | 'numeric'\n | 'boolean'\n | 'date'\n | 'datetime'\n | 'mediaSingle'\n | 'selectionStatic'\n | 'custom';\n\nexport interface SettingOption {\n label: string;\n value: string | number | boolean;\n}\n\nexport interface SettingDefinition<T = any> {\n moduleName: string;\n key: string;\n value: T;\n level: SettingLevel;\n encrypted?: boolean;\n label?: string;\n description?: string;\n helpText?: string;\n placeholder?: string;\n group?: string;\n sortOrder?: number;\n controlType?: SettingControlType;\n options?: SettingOption[];\n settingsWidget?: string; // for custom controlType, specify the frontend widget to use\n}\n\nexport interface AdminSettingDefinition<T = any> extends SettingDefinition<T> {\n editable: boolean;\n}\n\nexport interface AdminSettingsResponse<T = any> {\n data: AdminSettingDefinition<T>[];\n}\n\n// solid-core/settings/settings-provider.interface.ts\nexport interface ISettingsProvider {\n getSettings(): SettingDefinition[];\n}\n\nexport interface CodeGenerationOptions {\n moduleId?: number;\n moduleUserKey?: string;\n modelId?: number;\n modelUserKey?: string;\n fieldIdsForRemoval?: number[];\n fieldNamesForRemoval?: string[];\n dryRun?: boolean;\n}\n\n\nexport interface McpResponse {\n success: boolean;\n request: string;\n response: string;\n model?: string;\n tools_invoked?: string[];\n tool_calls?: any[];\n duration_ms?: number;\n errors?: string[];\n error_trace?: string[];\n content_type?: string;\n}\n\nexport interface ISelectionProviderContext {\n limit: number;\n offset: number;\n formValues: Record<string, any>;\n //Attribute to control the validation on creating the record\n validateOnSave?: boolean;\n // query: string;\n}\n\nexport interface ISelectionProviderValues {\n label: string;\n value: string;\n}\n\nexport interface ISelectionProvider<T extends ISelectionProviderContext> {\n help(): string;\n\n name(): string;\n\n value(optionValue: string, ctxt: T): Promise<ISelectionProviderValues | any>;\n\n values(query: any, ctxt: T): Promise<readonly ISelectionProviderValues[]>;\n}\n\nexport interface IWorkflowFieldDataProviderContext<TProviderContext = Record<string, any>> {\n entityId?: string;\n modelName: string;\n moduleName: string;\n workflowFieldName: string;\n workflowField: FieldMetadata;\n solidModel?: ModelMetadata;\n solidView?: ViewMetadata;\n solidFieldsMetadata: Record<string, FieldMetadata>;\n query?: Record<string, any>;\n providerContext: TProviderContext;\n activeUser?: ActiveUserData;\n}\n\nexport interface IWorkflowFieldDataProviderValues {\n label: string;\n value: string | number;\n}\n\nexport interface IWorkflowFieldDataProvider<\n TContext extends IWorkflowFieldDataProviderContext = IWorkflowFieldDataProviderContext,\n> {\n help(): string;\n name(): string;\n values(ctxt: TContext): Promise<readonly IWorkflowFieldDataProviderValues[]>;\n}\n\nexport interface IDashboardWidgetDataProviderContext<TVariables = Record<string, any>, TProviderContext = Record<string, any>> {\n moduleName: string;\n dashboardName: string;\n widgetName: string;\n variables: TVariables;\n providerContext: TProviderContext;\n activeUser?: ActiveUserData;\n}\n\nexport interface IDashboardWidgetDataResponseEnvelope<TData = any, TUiHints = Record<string, any>> {\n meta: {\n providerName: string;\n generatedAt: string;\n widgetName: string;\n durationMs: number;\n [key: string]: any;\n };\n data: TData;\n uiHints?: TUiHints;\n}\n\nexport interface IDashboardWidgetDataProvider<\n TContext extends IDashboardWidgetDataProviderContext = IDashboardWidgetDataProviderContext,\n TResponse = any,\n> {\n help(): string;\n name(): string;\n getData(\n widgetDefinition: Record<string, any>,\n ctxt: TContext,\n ): Promise<IDashboardWidgetDataResponseEnvelope<TResponse> | any>;\n}\n\n\n/**\n * @deprecated Use `IEntityComputedFieldProvider` instead.\n */\nexport interface IComputedFieldProvider<T> {\n help(): string;\n\n name(): string;\n\n valueType(): string;\n\n computeValue(dto: any, ctxt: T): Promise<string | number>; // FIXME : Improve the types to make it more specific using generics\n}\n\nexport interface IEntityComputedFieldProvider {\n help(): string;\n\n name(): string;\n}\n\nexport interface IEntityPreComputeFieldProvider<TTriggerEntity, TContext, TValue = void> extends IEntityComputedFieldProvider {\n preComputeValue(triggerEntity: TTriggerEntity, computedFieldMetadata: ComputedFieldMetadata<TContext>): Promise<TValue>;\n}\n\nexport interface IEntityPostComputeFieldProvider<TTriggerEntity, TContext> extends IEntityComputedFieldProvider {\n postComputeAndSaveValue(triggerEntity: TTriggerEntity, computedFieldMetadata: ComputedFieldMetadata<TContext>): Promise<void>;\n}\n\nexport interface ISolidDatabaseModule {\n name(): string;\n\n type(): DatasourceType;\n}\n\nexport enum EventType {\n USER_REGISTERED = 'user.registered',\n MODULE_METADATA_SEEDER_STARTED = 'module-metadata-seeder.started',\n MODULE_METADATA_SEEDER_FINISHED = 'module-metadata-seeder.finished',\n}\n\nexport class EventDetails<T> {\n constructor(\n public type: any,\n public payload: T,\n ) { }\n}\n\nexport interface ModuleMetadataSeederOptions {\n modulesToSeed: string[] | null;\n pruneMetadata: boolean;\n seedGlobalMetadata: boolean;\n skipHooks: boolean;\n}\n\nexport interface ModuleMetadataSeederEventPayload {\n seedRunId: string;\n options: ModuleMetadataSeederOptions;\n startedAt: string;\n finishedAt?: string;\n durationMs?: number;\n success?: boolean;\n seededModuleNames?: string[];\n currentStep?: string;\n errorMessage?: string;\n}\n\nexport interface IExtensionUserCreationProvider<T extends User = User, TDto extends CreateUserDto = CreateUserDto> {\n readonly repo: Repository<T>;\n buildExtensionEntity(dto: TDto): Promise<T>;\n roles(dto: TDto): string[];\n}\n\nexport interface IMail<TResponse = unknown> {\n sendEmail(\n to: string,\n subject: string,\n body: string,\n shouldQueueEmails: boolean,\n wrapperAttachments?: MailAttachmentWrapper[],\n attachments?: MailAttachment[],\n parentEntity?: any,\n parentEntityId?: any,\n cc?: string[],\n bcc?: string[],\n from?: string,\n ): Promise<TResponse>;\n\n sendEmailUsingTemplate(\n to: string,\n templateName: string,\n templateParams: any,\n shouldQueueEmails: boolean,\n wrapperAttachments?: MailAttachmentWrapper[],\n attachments?: MailAttachment[],\n parentEntity?: any,\n parentEntityId?: any,\n cc?: string[],\n bcc?: string[],\n from?: string,\n ): Promise<TResponse>;\n}\n\nexport interface ISMS {\n sendSMS(to: string, body: string, shouldQueueSms: boolean): Promise<any>;\n\n sendSMSUsingTemplate(\n to: string,\n templateName: string,\n templateParams: any,\n shouldQueueSms: boolean,\n ): Promise<any>;\n}\n\nexport interface IWhatsAppTransport {\n sendWhatsAppMessage(\n to: string,\n templateId: string,\n parameters: any,\n parentEntity?: any,\n parentEntityId?: any\n ): Promise<any>;\n}\n\nexport interface MailAttachmentWrapper {\n relativePath?: string;\n attachment?: MailAttachment;\n}\n\nexport interface MailAttachment {\n filename: string;\n templatePath?: string; // deprecated\n templateParams?: any; // deprecated\n content?: string | Buffer;\n contentType?: string;\n path?: string; //Filesystem absolute path or URL. \n}\n\nexport enum BrokerType {\n RabbitMQ = 'rabbitmq',\n Database = 'database',\n Redis = 'redis',\n}\n\nexport interface QueuesModuleOptions {\n name: string;\n type: BrokerType;\n queueName: string;\n prefetch?: number;\n persistToDatabase?: boolean;\n}\n\nexport type MediaWithFullUrl = Media & {\n _full_url: string;\n};\n\n\nexport type ErrorCode = string;\n\nexport type ErrorMeta = {\n message: string;\n httpStatus?: number;\n};\n\nexport type ErrorRule = {\n /** Canonical error code. Keep them kebab-case for consistency. */\n code: ErrorCode;\n /** Higher runs earlier. Defaults to 0 if not provided. */\n priority?: number;\n /** Return true if this rule matches the combined error text. */\n match: (combinedErrorText: string) => boolean;\n /** Display + HTTP mapping for this code. */\n meta: ErrorMeta;\n};\n\nexport interface IErrorCodeProvider {\n /** Used for registry identity & logs */\n name(): string;\n\n /**\n * Return all rules this provider contributes.\n * These will be merged with other providers’ rules, then sorted by priority.\n */\n rules(): ReadonlyArray<ErrorRule>;\n\n /**\n * Optional fallback meta for codes this provider owns (when called by getMessage/getHttpStatus).\n * If omitted, the ErrorMapperService will rely on the rule.meta of the first matching rule.\n */\n resolve?(code: ErrorCode): ErrorMeta | undefined;\n}\n\n// MCP Tool Related\n\nexport type PlanStep = CreateNewFileStep | RegisterNestProviderStep | AddMethodToExistingClassStep | RegisterSolidXExtensionComponentStep | AddListViewButtonStep | AddFormViewButtonStep | AddImportStep;\nexport interface AddImportStep {\n type: \"addImport\";\n path: string; // e.g. apps/api/src/address-master/services/address-master.service.ts\n importStatement: string; // e.g. import { Something } from 'somewhere';\n overwrite?: boolean; // default=false\n rationale?: string; // optional, ignored by executor\n}\n\nexport interface CreateNewFileStep {\n type: \"createNewFile\";\n path: string; // repo-relative e.g. solid-api/api/src/computed-providers/foo.provider.ts\n content: string; // full file content\n overwrite?: boolean; // default=false\n rationale?: string; // optional, ignored by executor\n}\n\nexport interface RegisterNestProviderStep {\n type: \"registerNestProvider\";\n modulePath: string; // e.g. apps/api/src/address-master/address-master.module.ts\n providerClassName: string; // e.g. StateTotalCitiesComputedFieldProvider\n importFrom: string; // e.g. \"@/computed-providers/state-total-cities.provider\"\n registerIn: Array<\"providers\" | \"exports\">; // which arrays to add to\n uniqueGuard?: boolean; // default=true\n rationale?: string; // optional, ignored by executor\n}\n\nexport interface AddMethodToExistingClassStep {\n type: \"addMethodToExistingClass\";\n path: string; // e.g. apps/api/src/address-master/services/address-master.service.ts\n className: string // e.g. CountryService\n methodName: string // e.g. addCountry\n content: string // Full Method Code\n importStatements?: string[]; // e.g. [ \"import { X } from 'y';\" ]\n rationale?: string; // optional, ignored by executor\n}\n\nexport interface RegisterSolidXExtensionComponentStep {\n type: \"registerSolidXExtensionComponent\";\n path: string; // e.g. apps/api/src/address-master/services/address-master.service.ts\n content?: string; // Code\n importExtensionComponent?: string;\n}\n\nexport interface AddListViewButtonStep {\n type: \"addListViewButton\";\n moduleName?: string;\n modelName?: string;\n buttonType?: string;\n content?: string; // Code\n}\n\nexport interface AddFormViewButtonStep {\n type: \"addFormViewButton\";\n moduleName?: string;\n modelName?: string;\n buttonType?: string;\n content?: string; // Code\n}\n\nexport interface McpComputedProviderResponse {\n plan: PlanStep[];\n // provider?: any; // (intentionally ignored per your note)\n}\n\nexport interface ISecurityRuleConfigProvider {\n securityRuleConfig(activeUser: ActiveUserData, securityRule: SecurityRule): Promise<SecurityRuleConfig>;\n}\n\n\nexport interface AwsS3Config {\n S3_AWS_ACCESS_KEY: string;\n S3_AWS_SECRET_KEY: string;\n S3_AWS_REGION_NAME: string;\n}\n\n// Prevents inference so callers must provide explicit type arguments; reusable for other APIs.\nexport type NoInfer<T> = [T][T extends any ? 0 : never];\n\nexport type AuditEventType = 'insert' | 'update' | 'delete';\n\nexport interface AuditQueuePayload {\n eventType: AuditEventType;\n modelName: string;\n entityId: string | number | null;\n occurredAt: string;\n after?: any;\n before?: any;\n updatedColumnNames?: string[];\n userId?: number | null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;AA8DA,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,wCAAwB,CAAA;IACxB,6DAA6C,CAAA;IAC7C,6DAA6C,CAAA;IAC7C,8CAA8B,CAAA;AAChC,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AA8LD,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,gDAAmC,CAAA;IACnC,8EAAiE,CAAA;IACjE,gFAAmE,CAAA;AACrE,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB;AAED,MAAa,YAAY;IACvB,YACS,IAAS,EACT,OAAU;QADV,SAAI,GAAJ,IAAI,CAAK;QACT,YAAO,GAAP,OAAO,CAAG;IACf,CAAC;CACN;AALD,oCAKC;AAgCD,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,8CAAqB,CAAA;IACrB,oCAAW,CAAA;AACb,CAAC,EAHW,qBAAqB,qCAArB,qBAAqB,QAGhC;AAsJD,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,mCAAqB,CAAA;IACrB,6BAAe,CAAA;AACjB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB","sourcesContent":["import { Repository } from 'typeorm';\nimport { User } from 'src/entities/user.entity';\nimport { CreateUserDto } from 'src/dtos/create-user.dto';\nimport { CreateEmailTemplateDto } from 'src/dtos/create-email-template.dto';\nimport { CreateSmsTemplateDto } from 'src/dtos/create-sms-template.dto';\nimport { SignUpDto } from 'src/dtos/sign-up.dto';\nimport { Readable } from 'stream';\nimport { CreateMediaStorageProviderMetadataDto } from './dtos/create-media-storage-provider-metadata.dto';\nimport { DatasourceType } from './dtos/create-model-metadata.dto';\nimport { CreateModuleMetadataDto } from './dtos/create-module-metadata.dto';\nimport { CreateRoleMetadataDto } from './dtos/create-role-metadata.dto';\nimport { CreateSecurityRuleDto } from './dtos/create-security-rule.dto';\nimport { FieldMetadata } from './entities/field-metadata.entity';\nimport { Media } from './entities/media.entity';\nimport { ComputedFieldMetadata } from './helpers/solid-registry';\nimport { ActiveUserData } from './interfaces/active-user-data.interface';\nimport { SecurityRuleConfig } from './dtos/security-rule-config.dto';\nimport { SecurityRule } from './entities/security-rule.entity';\nimport { ModelMetadata } from './entities/model-metadata.entity';\nimport { ViewMetadata } from './entities/view-metadata.entity';\n\nexport interface FieldCrudManager {\n // fieldMetadata: FieldMetadata;\n // entityManager?: EntityManager;\n // createDto: any;\n // files : Array<Express.Multer.File>;\n validate(\n dto: any,\n files: Array<Express.Multer.File>,\n ): ValidationError[] | Promise<ValidationError[]>;\n transformForCreate(dto: any, ctxt?: any): any | Promise<any>;\n}\n\nexport interface ValidationError {\n field: string;\n error: string;\n}\n\n// export interface MediaStorage\nexport interface MediaStorageProvider<T> {\n store(files: Express.Multer.File[], entity: T, mediaFieldMetadata: FieldMetadata): Promise<Media[]>;\n delete(entity: T, mediaFieldMetadata: FieldMetadata): Promise<void>;\n deleteByMediaRecord(media: Media): Promise<void>;\n retrieve(entity: T, mediaFieldMetadata: FieldMetadata): Promise<Media[]>;\n storeStreams(streamPairs: [Readable, string][], entity: T, mediaFieldMetadata: FieldMetadata): Promise<Media[]>;\n // delete(file: string): Promise<void>;\n}\n\nexport interface ModuleMetadataConfiguration {\n moduleMetadata?: CreateModuleMetadataDto,\n roles?: CreateRoleMetadataDto[],\n users?: SignUpDto[],\n actions?: any[],\n menus?: any[],\n views?: any[],\n emailTemplates?: CreateEmailTemplateDto[],\n smsTemplates?: CreateSmsTemplateDto[],\n mediaStorageProviders?: CreateMediaStorageProviderMetadataDto[]\n securityRules?: CreateSecurityRuleDto[],\n dashboards?: any[],\n}\n\nexport enum SettingLevel {\n SystemEnv = 'system-env',\n SystemAdminReadonly = 'system-admin-readonly',\n SystemAdminEditable = 'system-admin-editable',\n InternalUser = \"internal-user\"\n}\n\nexport type SettingControlType =\n | 'shortText'\n | 'longText'\n | 'numeric'\n | 'boolean'\n | 'date'\n | 'datetime'\n | 'mediaSingle'\n | 'selectionStatic'\n | 'custom';\n\nexport interface SettingOption {\n label: string;\n value: string | number | boolean;\n}\n\nexport interface SettingDefinition<T = any> {\n moduleName: string;\n key: string;\n value: T;\n level: SettingLevel;\n encrypted?: boolean;\n label?: string;\n description?: string;\n helpText?: string;\n placeholder?: string;\n group?: string;\n sortOrder?: number;\n controlType?: SettingControlType;\n options?: SettingOption[];\n settingsWidget?: string; // for custom controlType, specify the frontend widget to use\n}\n\nexport interface AdminSettingDefinition<T = any> extends SettingDefinition<T> {\n editable: boolean;\n}\n\nexport interface AdminSettingsResponse<T = any> {\n data: AdminSettingDefinition<T>[];\n}\n\n// solid-core/settings/settings-provider.interface.ts\nexport interface ISettingsProvider {\n getSettings(): SettingDefinition[];\n}\n\nexport interface CodeGenerationOptions {\n moduleId?: number;\n moduleUserKey?: string;\n modelId?: number;\n modelUserKey?: string;\n fieldIdsForRemoval?: number[];\n fieldNamesForRemoval?: string[];\n dryRun?: boolean;\n}\n\n\nexport interface McpResponse {\n success: boolean;\n request: string;\n response: string;\n model?: string;\n tools_invoked?: string[];\n tool_calls?: any[];\n duration_ms?: number;\n errors?: string[];\n error_trace?: string[];\n content_type?: string;\n}\n\nexport interface ISelectionProviderContext {\n limit: number;\n offset: number;\n formValues: Record<string, any>;\n //Attribute to control the validation on creating the record\n validateOnSave?: boolean;\n // query: string;\n}\n\nexport interface ISelectionProviderValues {\n label: string;\n value: string;\n}\n\nexport interface ISelectionProvider<T extends ISelectionProviderContext> {\n help(): string;\n\n name(): string;\n\n value(optionValue: string, ctxt: T): Promise<ISelectionProviderValues | any>;\n\n values(query: any, ctxt: T): Promise<readonly ISelectionProviderValues[]>;\n}\n\nexport interface IWorkflowFieldDataProviderContext<TProviderContext = Record<string, any>> {\n entityId?: string;\n modelName: string;\n moduleName: string;\n workflowFieldName: string;\n workflowField: FieldMetadata;\n solidModel?: ModelMetadata;\n solidView?: ViewMetadata;\n solidFieldsMetadata: Record<string, FieldMetadata>;\n query?: Record<string, any>;\n providerContext: TProviderContext;\n activeUser?: ActiveUserData;\n}\n\nexport interface IWorkflowFieldDataProviderValues {\n label: string;\n value: string | number;\n}\n\nexport interface IWorkflowFieldDataProvider<\n TContext extends IWorkflowFieldDataProviderContext = IWorkflowFieldDataProviderContext,\n> {\n help(): string;\n name(): string;\n values(ctxt: TContext): Promise<readonly IWorkflowFieldDataProviderValues[]>;\n}\n\nexport interface IDashboardWidgetDataProviderContext<TVariables = Record<string, any>, TProviderContext = Record<string, any>> {\n moduleName: string;\n dashboardName: string;\n widgetName: string;\n variables: TVariables;\n providerContext: TProviderContext;\n activeUser?: ActiveUserData;\n}\n\nexport interface IDashboardWidgetDataResponseEnvelope<TData = any, TUiHints = Record<string, any>> {\n meta: {\n providerName: string;\n generatedAt: string;\n widgetName: string;\n durationMs: number;\n [key: string]: any;\n };\n data: TData;\n uiHints?: TUiHints;\n}\n\nexport interface IDashboardWidgetDataProvider<\n TContext extends IDashboardWidgetDataProviderContext = IDashboardWidgetDataProviderContext,\n TResponse = any,\n> {\n help(): string;\n name(): string;\n getData(\n widgetDefinition: Record<string, any>,\n ctxt: TContext,\n ): Promise<IDashboardWidgetDataResponseEnvelope<TResponse> | any>;\n}\n\n\n/**\n * @deprecated Use `IEntityComputedFieldProvider` instead.\n */\nexport interface IComputedFieldProvider<T> {\n help(): string;\n\n name(): string;\n\n valueType(): string;\n\n computeValue(dto: any, ctxt: T): Promise<string | number>; // FIXME : Improve the types to make it more specific using generics\n}\n\nexport interface IEntityComputedFieldProvider {\n help(): string;\n\n name(): string;\n}\n\nexport interface IEntityPreComputeFieldProvider<TTriggerEntity, TContext, TValue = void> extends IEntityComputedFieldProvider {\n preComputeValue(triggerEntity: TTriggerEntity, computedFieldMetadata: ComputedFieldMetadata<TContext>): Promise<TValue>;\n}\n\nexport interface IEntityPostComputeFieldProvider<TTriggerEntity, TContext> extends IEntityComputedFieldProvider {\n postComputeAndSaveValue(triggerEntity: TTriggerEntity, computedFieldMetadata: ComputedFieldMetadata<TContext>): Promise<void>;\n}\n\nexport interface ISolidDatabaseModule {\n name(): string;\n\n type(): DatasourceType;\n}\n\nexport enum EventType {\n USER_REGISTERED = 'user.registered',\n MODULE_METADATA_SEEDER_STARTED = 'module-metadata-seeder.started',\n MODULE_METADATA_SEEDER_FINISHED = 'module-metadata-seeder.finished',\n}\n\nexport class EventDetails<T> {\n constructor(\n public type: any,\n public payload: T,\n ) { }\n}\n\nexport interface ModuleMetadataSeederOptions {\n modulesToSeed: string[] | null;\n pruneMetadata: boolean;\n seedGlobalMetadata: boolean;\n skipHooks: boolean;\n}\n\nexport interface ModuleMetadataSeederEventPayload {\n seedRunId: string;\n options: ModuleMetadataSeederOptions;\n startedAt: string;\n finishedAt?: string;\n durationMs?: number;\n success?: boolean;\n seededModuleNames?: string[];\n currentStep?: string;\n errorMessage?: string;\n}\n\nexport interface IExtensionUserCreationProvider<T extends User = User, TDto extends CreateUserDto = CreateUserDto> {\n readonly repo: Repository<T>;\n buildExtensionEntity(dto: TDto): Promise<T>;\n roles(dto: TDto): string[];\n}\n\n// ---------------------------------------------------------------------------\n// Login extension providers\n// ---------------------------------------------------------------------------\n\n/** The authentication entry point that produced this attempt. */\nexport enum LoginExtensionChannel {\n PASSWORD = \"password\",\n OTP = \"otp\",\n}\n\nexport type LoginExtensionFailurePolicy = \"fail-open\" | \"fail-closed\";\n\nexport interface ILoginExtensionContext {\n /** Which entry point is asking. */\n channel: LoginExtensionChannel;\n /** Correlates the log lines emitted for one attempt. */\n attemptId: string;\n /** When the attempt reached the extension chain. */\n startedAt: Date;\n}\n\nexport interface ILoginExtensionResult {\n /**\n * `false` denies the login. Any other value - including a malformed result -\n * allows it, so a provider bug cannot silently lock everyone out. A provider\n * that cannot reach its backing system must throw, not return `{ allow: true }`;\n * throwing is what the failure policy acts on.\n */\n allow: boolean;\n /**\n * Operator-facing reason. Written to the server log, never returned to the\n * client: a third party's denial reason leaks account state.\n */\n reason?: string;\n /**\n * Canonical client-facing code. Contribute it from an `IErrorCodeProvider`\n * so the global exception filter does not rewrite it.\n */\n errorCode?: ErrorCode;\n /** Client-facing message. Still subject to `ErrorMapperService` rewriting. */\n message?: string;\n}\n\n/**\n * Extends login with checks the primary authentication mechanism cannot make -\n * typically the live state of the same identity in a third-party system.\n *\n * Core calls `verifyLogin` only after the primary credential has been proven\n * and before any token is minted, so a provider can only turn a successful\n * login into a failure, never the reverse.\n *\n * Runs on the password and OTP login paths only. OAuth, MPIN, token refresh\n * and SSO code exchange do not invoke the chain.\n */\nexport interface ILoginExtensionProvider<\n TUser extends User = User,\n TContext extends ILoginExtensionContext = ILoginExtensionContext,\n> {\n /** Registry identity and log label. */\n name(): string;\n\n help(): string;\n\n /** Higher runs first. Defaults to 0. Mirrors `ErrorRule.priority`. */\n priority?: number;\n\n /**\n * Deadline for `verifyLogin`. Defaults to\n * `DEFAULT_LOGIN_EXTENSION_TIMEOUT_MS` (5000). Exceeding it is treated as a\n * failure, not a denial.\n */\n timeoutMs?: number;\n\n /**\n * What happens when `verifyLogin` throws or times out. Defaults to\n * `fail-closed`: a check that cannot reach its backing system denies the\n * login rather than silently waving it through. Providers that must never\n * be able to lock the product out should set `fail-open` explicitly.\n */\n failurePolicy?: LoginExtensionFailurePolicy;\n\n /**\n * Return `{ allow: false }` to deny. Throwing signals a malfunction and is\n * governed by the failure policy.\n *\n * This is the only entry point, so a provider that does not apply to a given\n * user returns `{ allow: true }` early rather than being filtered out\n * beforehand. That keeps every outbound call this provider makes under the\n * one deadline above.\n */\n verifyLogin(user: TUser, ctxt: TContext): Promise<ILoginExtensionResult>;\n}\n\nexport interface IMail<TResponse = unknown> {\n sendEmail(\n to: string,\n subject: string,\n body: string,\n shouldQueueEmails: boolean,\n wrapperAttachments?: MailAttachmentWrapper[],\n attachments?: MailAttachment[],\n parentEntity?: any,\n parentEntityId?: any,\n cc?: string[],\n bcc?: string[],\n from?: string,\n ): Promise<TResponse>;\n\n sendEmailUsingTemplate(\n to: string,\n templateName: string,\n templateParams: any,\n shouldQueueEmails: boolean,\n wrapperAttachments?: MailAttachmentWrapper[],\n attachments?: MailAttachment[],\n parentEntity?: any,\n parentEntityId?: any,\n cc?: string[],\n bcc?: string[],\n from?: string,\n ): Promise<TResponse>;\n}\n\nexport interface ISMS {\n sendSMS(to: string, body: string, shouldQueueSms: boolean): Promise<any>;\n\n sendSMSUsingTemplate(\n to: string,\n templateName: string,\n templateParams: any,\n shouldQueueSms: boolean,\n ): Promise<any>;\n}\n\nexport interface IWhatsAppTransport {\n sendWhatsAppMessage(\n to: string,\n templateId: string,\n parameters: any,\n parentEntity?: any,\n parentEntityId?: any\n ): Promise<any>;\n}\n\nexport interface MailAttachmentWrapper {\n relativePath?: string;\n attachment?: MailAttachment;\n}\n\nexport interface MailAttachment {\n filename: string;\n templatePath?: string; // deprecated\n templateParams?: any; // deprecated\n content?: string | Buffer;\n contentType?: string;\n path?: string; //Filesystem absolute path or URL. \n}\n\nexport enum BrokerType {\n RabbitMQ = 'rabbitmq',\n Database = 'database',\n Redis = 'redis',\n}\n\nexport interface QueuesModuleOptions {\n name: string;\n type: BrokerType;\n queueName: string;\n prefetch?: number;\n persistToDatabase?: boolean;\n}\n\nexport type MediaWithFullUrl = Media & {\n _full_url: string;\n};\n\n\nexport type ErrorCode = string;\n\nexport type ErrorMeta = {\n message: string;\n httpStatus?: number;\n};\n\nexport type ErrorRule = {\n /** Canonical error code. Keep them kebab-case for consistency. */\n code: ErrorCode;\n /** Higher runs earlier. Defaults to 0 if not provided. */\n priority?: number;\n /** Return true if this rule matches the combined error text. */\n match: (combinedErrorText: string) => boolean;\n /** Display + HTTP mapping for this code. */\n meta: ErrorMeta;\n};\n\nexport interface IErrorCodeProvider {\n /** Used for registry identity & logs */\n name(): string;\n\n /**\n * Return all rules this provider contributes.\n * These will be merged with other providers’ rules, then sorted by priority.\n */\n rules(): ReadonlyArray<ErrorRule>;\n\n /**\n * Optional fallback meta for codes this provider owns (when called by getMessage/getHttpStatus).\n * If omitted, the ErrorMapperService will rely on the rule.meta of the first matching rule.\n */\n resolve?(code: ErrorCode): ErrorMeta | undefined;\n}\n\n// MCP Tool Related\n\nexport type PlanStep = CreateNewFileStep | RegisterNestProviderStep | AddMethodToExistingClassStep | RegisterSolidXExtensionComponentStep | AddListViewButtonStep | AddFormViewButtonStep | AddImportStep;\nexport interface AddImportStep {\n type: \"addImport\";\n path: string; // e.g. apps/api/src/address-master/services/address-master.service.ts\n importStatement: string; // e.g. import { Something } from 'somewhere';\n overwrite?: boolean; // default=false\n rationale?: string; // optional, ignored by executor\n}\n\nexport interface CreateNewFileStep {\n type: \"createNewFile\";\n path: string; // repo-relative e.g. solid-api/api/src/computed-providers/foo.provider.ts\n content: string; // full file content\n overwrite?: boolean; // default=false\n rationale?: string; // optional, ignored by executor\n}\n\nexport interface RegisterNestProviderStep {\n type: \"registerNestProvider\";\n modulePath: string; // e.g. apps/api/src/address-master/address-master.module.ts\n providerClassName: string; // e.g. StateTotalCitiesComputedFieldProvider\n importFrom: string; // e.g. \"@/computed-providers/state-total-cities.provider\"\n registerIn: Array<\"providers\" | \"exports\">; // which arrays to add to\n uniqueGuard?: boolean; // default=true\n rationale?: string; // optional, ignored by executor\n}\n\nexport interface AddMethodToExistingClassStep {\n type: \"addMethodToExistingClass\";\n path: string; // e.g. apps/api/src/address-master/services/address-master.service.ts\n className: string // e.g. CountryService\n methodName: string // e.g. addCountry\n content: string // Full Method Code\n importStatements?: string[]; // e.g. [ \"import { X } from 'y';\" ]\n rationale?: string; // optional, ignored by executor\n}\n\nexport interface RegisterSolidXExtensionComponentStep {\n type: \"registerSolidXExtensionComponent\";\n path: string; // e.g. apps/api/src/address-master/services/address-master.service.ts\n content?: string; // Code\n importExtensionComponent?: string;\n}\n\nexport interface AddListViewButtonStep {\n type: \"addListViewButton\";\n moduleName?: string;\n modelName?: string;\n buttonType?: string;\n content?: string; // Code\n}\n\nexport interface AddFormViewButtonStep {\n type: \"addFormViewButton\";\n moduleName?: string;\n modelName?: string;\n buttonType?: string;\n content?: string; // Code\n}\n\nexport interface McpComputedProviderResponse {\n plan: PlanStep[];\n // provider?: any; // (intentionally ignored per your note)\n}\n\nexport interface ISecurityRuleConfigProvider {\n securityRuleConfig(activeUser: ActiveUserData, securityRule: SecurityRule): Promise<SecurityRuleConfig>;\n}\n\n\nexport interface AwsS3Config {\n S3_AWS_ACCESS_KEY: string;\n S3_AWS_SECRET_KEY: string;\n S3_AWS_REGION_NAME: string;\n}\n\n// Prevents inference so callers must provide explicit type arguments; reusable for other APIs.\nexport type NoInfer<T> = [T][T extends any ? 0 : never];\n\nexport type AuditEventType = 'insert' | 'update' | 'delete';\n\nexport interface AuditQueuePayload {\n eventType: AuditEventType;\n modelName: string;\n entityId: string | number | null;\n occurredAt: string;\n after?: any;\n before?: any;\n updatedColumnNames?: string[];\n userId?: number | null;\n}\n"]}
|
|
@@ -8000,6 +8000,7 @@
|
|
|
8000
8000
|
"ViewMetadataController.findOne",
|
|
8001
8001
|
"ActionMetadataController.findMany",
|
|
8002
8002
|
"ActionMetadataController.findOne",
|
|
8003
|
+
"UserViewMetadataController.create",
|
|
8003
8004
|
"UserViewMetadataController.upsert",
|
|
8004
8005
|
"UserViewMetadataController.findMany",
|
|
8005
8006
|
"UserViewMetadataController.findOne",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HttpService } from "@nestjs/axios";
|
|
2
|
+
import { ServiceUnavailableException, UnauthorizedException } from "@nestjs/common";
|
|
2
3
|
import { EventEmitter2 } from "@nestjs/event-emitter";
|
|
3
4
|
import { JwtService } from "@nestjs/jwt";
|
|
4
5
|
import { MailFactory } from "../factories/mail.factory";
|
|
@@ -15,7 +16,9 @@ import { SignInDto } from "../dtos/sign-in.dto";
|
|
|
15
16
|
import { SignUpDto } from "../dtos/sign-up.dto";
|
|
16
17
|
import { SignupIntent } from "../enums/signup-intent.enum";
|
|
17
18
|
import { User } from "../entities/user.entity";
|
|
19
|
+
import { ILoginExtensionContext } from "../interfaces";
|
|
18
20
|
import { ActiveUserData } from "../interfaces/active-user-data.interface";
|
|
21
|
+
import { SolidRegistry } from "../helpers/solid-registry";
|
|
19
22
|
import { ActiveSessionStorageService } from "./active-session-storage.service";
|
|
20
23
|
import { AccessTokenDenylistService } from "./access-token-denylist.service";
|
|
21
24
|
import { HashingService } from "./hashing.service";
|
|
@@ -28,6 +31,10 @@ import { MetadataValidationService } from "./metadata-validation.service";
|
|
|
28
31
|
import { UserService } from "./user.service";
|
|
29
32
|
import { SmsFactory } from "../factories/sms.factory";
|
|
30
33
|
import { WhatsAppFactory } from "../factories/whatsapp.factory";
|
|
34
|
+
export declare class LoginExtensionDeniedException extends UnauthorizedException {
|
|
35
|
+
}
|
|
36
|
+
export declare class LoginExtensionUnavailableException extends ServiceUnavailableException {
|
|
37
|
+
}
|
|
31
38
|
export declare class AuthenticationService {
|
|
32
39
|
private readonly userService;
|
|
33
40
|
private readonly userRepository;
|
|
@@ -46,14 +53,17 @@ export declare class AuthenticationService {
|
|
|
46
53
|
private readonly userActivityHistoryService;
|
|
47
54
|
private readonly ssoCodeStorage;
|
|
48
55
|
private readonly metadataValidationService;
|
|
56
|
+
private readonly solidRegistry;
|
|
49
57
|
private readonly dataSource;
|
|
50
58
|
private readonly logger;
|
|
51
|
-
constructor(userService: UserService, userRepository: UserRepository, hashingService: HashingService, jwtService: JwtService, activeSessionStorage: ActiveSessionStorageService, accessTokenDenylist: AccessTokenDenylistService, refreshTokenIdsStorage: RefreshTokenIdsStorageService, httpService: HttpService, mailServiceFactory: MailFactory, smsFactory: SmsFactory, whatsAppFactory: WhatsAppFactory, eventEmitter: EventEmitter2, settingService: SettingService, roleMetadataService: RoleMetadataService, userActivityHistoryService: UserActivityHistoryService, ssoCodeStorage: SsoCodeStorageService, metadataValidationService: MetadataValidationService, dataSource: DataSource);
|
|
59
|
+
constructor(userService: UserService, userRepository: UserRepository, hashingService: HashingService, jwtService: JwtService, activeSessionStorage: ActiveSessionStorageService, accessTokenDenylist: AccessTokenDenylistService, refreshTokenIdsStorage: RefreshTokenIdsStorageService, httpService: HttpService, mailServiceFactory: MailFactory, smsFactory: SmsFactory, whatsAppFactory: WhatsAppFactory, eventEmitter: EventEmitter2, settingService: SettingService, roleMetadataService: RoleMetadataService, userActivityHistoryService: UserActivityHistoryService, ssoCodeStorage: SsoCodeStorageService, metadataValidationService: MetadataValidationService, solidRegistry: SolidRegistry, dataSource: DataSource);
|
|
52
60
|
private getCompanyLogo;
|
|
53
61
|
resolveUser(username: string, email: string): Promise<User>;
|
|
54
62
|
private resolveUserForPasswordSignIn;
|
|
55
63
|
updatePasswordDetails(user: User, newPassword: string): Promise<User>;
|
|
56
64
|
resolveUserByVerificationToken(token: string): Promise<User>;
|
|
65
|
+
runLoginExtensions(user: User, ctxt: Omit<ILoginExtensionContext, "attemptId" | "startedAt">): Promise<void>;
|
|
66
|
+
private withLoginExtensionTimeout;
|
|
57
67
|
private validateUserForPasswordLogin;
|
|
58
68
|
private rehashPasswordIfRequired;
|
|
59
69
|
signUp(signUpDto: SignUpDto & Record<string, any>, activeUser?: ActiveUserData, intent?: SignupIntent): Promise<User>;
|
|
@@ -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;
|
|
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;AAE5C,OAAO,EAQL,2BAA2B,EAC3B,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAoB,UAAU,EAAE,MAAM,SAAS,CAAC;AAOhF,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,6BAA6B,CAA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exports, "__esModule", { value: true });
|
|
16
|
-
exports.AuthenticationService = void 0;
|
|
16
|
+
exports.AuthenticationService = exports.LoginExtensionUnavailableException = exports.LoginExtensionDeniedException = void 0;
|
|
17
17
|
const axios_1 = require("@nestjs/axios");
|
|
18
18
|
const common_1 = require("@nestjs/common");
|
|
19
19
|
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
@@ -31,6 +31,7 @@ const constants_1 = require("../constants");
|
|
|
31
31
|
const signup_intent_enum_1 = require("../enums/signup-intent.enum");
|
|
32
32
|
const user_entity_1 = require("../entities/user.entity");
|
|
33
33
|
const interfaces_1 = require("../interfaces");
|
|
34
|
+
const solid_registry_1 = require("../helpers/solid-registry");
|
|
34
35
|
const active_session_storage_service_1 = require("./active-session-storage.service");
|
|
35
36
|
const access_token_denylist_service_1 = require("./access-token-denylist.service");
|
|
36
37
|
const hashing_service_1 = require("./hashing.service");
|
|
@@ -69,8 +70,15 @@ const SIGNUP_POLICY = {
|
|
|
69
70
|
rolesSource: RolesSource.Caller,
|
|
70
71
|
},
|
|
71
72
|
};
|
|
73
|
+
const DEFAULT_LOGIN_EXTENSION_TIMEOUT_MS = 5000;
|
|
74
|
+
class LoginExtensionDeniedException extends common_1.UnauthorizedException {
|
|
75
|
+
}
|
|
76
|
+
exports.LoginExtensionDeniedException = LoginExtensionDeniedException;
|
|
77
|
+
class LoginExtensionUnavailableException extends common_1.ServiceUnavailableException {
|
|
78
|
+
}
|
|
79
|
+
exports.LoginExtensionUnavailableException = LoginExtensionUnavailableException;
|
|
72
80
|
let AuthenticationService = AuthenticationService_1 = class AuthenticationService {
|
|
73
|
-
constructor(userService, userRepository, hashingService, jwtService, activeSessionStorage, accessTokenDenylist, refreshTokenIdsStorage, httpService, mailServiceFactory, smsFactory, whatsAppFactory, eventEmitter, settingService, roleMetadataService, userActivityHistoryService, ssoCodeStorage, metadataValidationService, dataSource) {
|
|
81
|
+
constructor(userService, userRepository, hashingService, jwtService, activeSessionStorage, accessTokenDenylist, refreshTokenIdsStorage, httpService, mailServiceFactory, smsFactory, whatsAppFactory, eventEmitter, settingService, roleMetadataService, userActivityHistoryService, ssoCodeStorage, metadataValidationService, solidRegistry, dataSource) {
|
|
74
82
|
this.userService = userService;
|
|
75
83
|
this.userRepository = userRepository;
|
|
76
84
|
this.hashingService = hashingService;
|
|
@@ -88,6 +96,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
88
96
|
this.userActivityHistoryService = userActivityHistoryService;
|
|
89
97
|
this.ssoCodeStorage = ssoCodeStorage;
|
|
90
98
|
this.metadataValidationService = metadataValidationService;
|
|
99
|
+
this.solidRegistry = solidRegistry;
|
|
91
100
|
this.dataSource = dataSource;
|
|
92
101
|
this.logger = new common_1.Logger(AuthenticationService_1.name);
|
|
93
102
|
}
|
|
@@ -139,6 +148,53 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
139
148
|
relations: { roles: true },
|
|
140
149
|
});
|
|
141
150
|
}
|
|
151
|
+
async runLoginExtensions(user, ctxt) {
|
|
152
|
+
const wrappers = this.solidRegistry.getLoginExtensionProviders();
|
|
153
|
+
if (wrappers.length === 0)
|
|
154
|
+
return;
|
|
155
|
+
const context = {
|
|
156
|
+
attemptId: (0, crypto_1.randomUUID)(),
|
|
157
|
+
startedAt: new Date(),
|
|
158
|
+
...ctxt,
|
|
159
|
+
};
|
|
160
|
+
const providers = wrappers
|
|
161
|
+
.map((w) => w.instance)
|
|
162
|
+
.filter(Boolean)
|
|
163
|
+
.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
164
|
+
for (const provider of providers) {
|
|
165
|
+
const providerName = provider.name?.() ?? provider.constructor?.name ?? "unknown";
|
|
166
|
+
try {
|
|
167
|
+
const result = await this.withLoginExtensionTimeout(provider.verifyLogin(user, context), provider.timeoutMs ?? DEFAULT_LOGIN_EXTENSION_TIMEOUT_MS, providerName);
|
|
168
|
+
if (result?.allow === false) {
|
|
169
|
+
this.logger.warn(`Login denied by ${providerName} for user ${user.id} ` +
|
|
170
|
+
`[attempt=${context.attemptId} channel=${context.channel}]: ` +
|
|
171
|
+
`${result.reason ?? "no reason given"}`);
|
|
172
|
+
throw new LoginExtensionDeniedException(result.message ?? error_messages_1.ERROR_MESSAGES.LOGIN_DENIED_BY_EXTENSION);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch (e) {
|
|
176
|
+
if (e instanceof LoginExtensionDeniedException)
|
|
177
|
+
throw e;
|
|
178
|
+
const policy = provider.failurePolicy ?? "fail-closed";
|
|
179
|
+
this.logger.error(`Login extension ${providerName} failed ` +
|
|
180
|
+
`[attempt=${context.attemptId} policy=${policy}]: ${e?.message}`, e?.stack);
|
|
181
|
+
if (policy === "fail-open")
|
|
182
|
+
continue;
|
|
183
|
+
throw new LoginExtensionUnavailableException(error_messages_1.ERROR_MESSAGES.LOGIN_EXTENSION_UNAVAILABLE);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
withLoginExtensionTimeout(work, ms, providerName) {
|
|
188
|
+
if (!(ms > 0))
|
|
189
|
+
return work;
|
|
190
|
+
let timer;
|
|
191
|
+
return Promise.race([
|
|
192
|
+
work.finally(() => clearTimeout(timer)),
|
|
193
|
+
new Promise((_, reject) => {
|
|
194
|
+
timer = setTimeout(() => reject(new Error(`Login extension ${providerName} timed out after ${ms}ms`)), ms);
|
|
195
|
+
}),
|
|
196
|
+
]);
|
|
197
|
+
}
|
|
142
198
|
async validateUserForPasswordLogin(user, password) {
|
|
143
199
|
if (!user.active) {
|
|
144
200
|
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_ACTIVE);
|
|
@@ -705,6 +761,9 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
705
761
|
await this.validateUserForPasswordLogin(user, signInDto.password);
|
|
706
762
|
await this.rehashPasswordIfRequired(user, signInDto.password);
|
|
707
763
|
await this.resetFailedAttempts(user);
|
|
764
|
+
await this.runLoginExtensions(user, {
|
|
765
|
+
channel: interfaces_1.LoginExtensionChannel.PASSWORD,
|
|
766
|
+
});
|
|
708
767
|
const tokens = await this.generateTokens(user);
|
|
709
768
|
await this.userActivityHistoryService.logEvent("login", user);
|
|
710
769
|
return {
|
|
@@ -908,6 +967,9 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
908
967
|
if (otp !== dummyOtp) {
|
|
909
968
|
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
|
|
910
969
|
}
|
|
970
|
+
await this.runLoginExtensions(user, {
|
|
971
|
+
channel: interfaces_1.LoginExtensionChannel.OTP,
|
|
972
|
+
});
|
|
911
973
|
return this.buildLoginTokenResponse(user);
|
|
912
974
|
}
|
|
913
975
|
try {
|
|
@@ -918,8 +980,11 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
918
980
|
throw e;
|
|
919
981
|
}
|
|
920
982
|
await this.clearLoginOtp(user, type);
|
|
921
|
-
await this.userActivityHistoryService.logEvent("login", user);
|
|
922
983
|
await this.resetFailedAttempts(user);
|
|
984
|
+
await this.runLoginExtensions(user, {
|
|
985
|
+
channel: interfaces_1.LoginExtensionChannel.OTP,
|
|
986
|
+
});
|
|
987
|
+
await this.userActivityHistoryService.logEvent("login", user);
|
|
923
988
|
return this.buildLoginTokenResponse(user);
|
|
924
989
|
}
|
|
925
990
|
validateLoginOtp(user, otp, type) {
|
|
@@ -1654,7 +1719,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
1654
1719
|
exports.AuthenticationService = AuthenticationService;
|
|
1655
1720
|
exports.AuthenticationService = AuthenticationService = AuthenticationService_1 = __decorate([
|
|
1656
1721
|
(0, common_1.Injectable)(),
|
|
1657
|
-
__param(
|
|
1722
|
+
__param(18, (0, typeorm_1.InjectDataSource)()),
|
|
1658
1723
|
__metadata("design:paramtypes", [user_service_1.UserService,
|
|
1659
1724
|
user_repository_1.UserRepository,
|
|
1660
1725
|
hashing_service_1.HashingService,
|
|
@@ -1672,6 +1737,7 @@ exports.AuthenticationService = AuthenticationService = AuthenticationService_1
|
|
|
1672
1737
|
user_activity_history_service_1.UserActivityHistoryService,
|
|
1673
1738
|
sso_code_storage_service_1.SsoCodeStorageService,
|
|
1674
1739
|
metadata_validation_service_1.MetadataValidationService,
|
|
1740
|
+
solid_registry_1.SolidRegistry,
|
|
1675
1741
|
typeorm_2.DataSource])
|
|
1676
1742
|
], AuthenticationService);
|
|
1677
1743
|
function parseUniqueConstraintError(detail) {
|