@solidxai/core 0.1.8-beta.1 → 0.1.8-beta.11
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/README.md +197 -0
- package/dist/controllers/authentication.controller.d.ts +32 -2
- package/dist/controllers/authentication.controller.d.ts.map +1 -1
- package/dist/controllers/authentication.controller.js +80 -3
- package/dist/controllers/authentication.controller.js.map +1 -1
- package/dist/dtos/create-api-key.dto.d.ts +5 -0
- package/dist/dtos/create-api-key.dto.d.ts.map +1 -0
- package/dist/dtos/create-api-key.dto.js +34 -0
- package/dist/dtos/create-api-key.dto.js.map +1 -0
- package/dist/dtos/post-chatter-message.dto.d.ts +1 -0
- package/dist/dtos/post-chatter-message.dto.d.ts.map +1 -1
- package/dist/dtos/post-chatter-message.dto.js +6 -1
- package/dist/dtos/post-chatter-message.dto.js.map +1 -1
- package/dist/dtos/register-private.dto.d.ts +3 -5
- package/dist/dtos/register-private.dto.d.ts.map +1 -1
- package/dist/dtos/register-private.dto.js +6 -18
- package/dist/dtos/register-private.dto.js.map +1 -1
- package/dist/dtos/sso-exchange.dto.d.ts +4 -0
- package/dist/dtos/sso-exchange.dto.d.ts.map +1 -0
- package/dist/dtos/sso-exchange.dto.js +26 -0
- package/dist/dtos/sso-exchange.dto.js.map +1 -0
- package/dist/dtos/update-api-key.dto.d.ts +4 -0
- package/dist/dtos/update-api-key.dto.d.ts.map +1 -0
- package/dist/dtos/update-api-key.dto.js +28 -0
- package/dist/dtos/update-api-key.dto.js.map +1 -0
- package/dist/entities/agent-event.entity.d.ts +3 -12
- package/dist/entities/agent-event.entity.d.ts.map +1 -1
- package/dist/entities/agent-event.entity.js +21 -46
- package/dist/entities/agent-event.entity.js.map +1 -1
- package/dist/entities/agent-session.entity.d.ts +2 -11
- package/dist/entities/agent-session.entity.d.ts.map +1 -1
- package/dist/entities/agent-session.entity.js +15 -40
- package/dist/entities/agent-session.entity.js.map +1 -1
- package/dist/entities/field-metadata.entity.js +1 -1
- package/dist/entities/field-metadata.entity.js.map +1 -1
- package/dist/entities/legacy-common.entity.d.ts +9 -9
- package/dist/entities/legacy-common.entity.d.ts.map +1 -1
- package/dist/entities/legacy-common.entity.js +7 -7
- package/dist/entities/legacy-common.entity.js.map +1 -1
- package/dist/entities/setting.entity.d.ts +1 -0
- package/dist/entities/setting.entity.d.ts.map +1 -1
- package/dist/entities/setting.entity.js +5 -1
- package/dist/entities/setting.entity.js.map +1 -1
- package/dist/entities/sms-template.entity.d.ts.map +1 -1
- package/dist/entities/sms-template.entity.js +2 -1
- package/dist/entities/sms-template.entity.js.map +1 -1
- package/dist/entities/user-api-key.entity.d.ts +12 -0
- package/dist/entities/user-api-key.entity.d.ts.map +1 -0
- package/dist/entities/user-api-key.entity.js +62 -0
- package/dist/entities/user-api-key.entity.js.map +1 -0
- package/dist/entities/user.entity.d.ts +3 -0
- package/dist/entities/user.entity.d.ts.map +1 -1
- package/dist/entities/user.entity.js +12 -1
- package/dist/entities/user.entity.js.map +1 -1
- package/dist/enums/auth-type.enum.d.ts +2 -1
- package/dist/enums/auth-type.enum.d.ts.map +1 -1
- package/dist/enums/auth-type.enum.js +2 -1
- package/dist/enums/auth-type.enum.js.map +1 -1
- package/dist/guards/api-key.guard.d.ts +11 -0
- package/dist/guards/api-key.guard.d.ts.map +1 -0
- package/dist/guards/api-key.guard.js +43 -0
- package/dist/guards/api-key.guard.js.map +1 -0
- package/dist/guards/authentication.guard.d.ts +4 -2
- package/dist/guards/authentication.guard.d.ts.map +1 -1
- package/dist/guards/authentication.guard.js +7 -3
- package/dist/guards/authentication.guard.js.map +1 -1
- package/dist/helpers/bootstrap.helper.d.ts.map +1 -1
- package/dist/helpers/bootstrap.helper.js +12 -1
- package/dist/helpers/bootstrap.helper.js.map +1 -1
- package/dist/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.d.ts.map +1 -1
- package/dist/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.js +15 -6
- package/dist/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.js.map +1 -1
- package/dist/helpers/typeorm-db-helper.d.ts.map +1 -1
- package/dist/helpers/typeorm-db-helper.js +9 -0
- package/dist/helpers/typeorm-db-helper.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +12 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/jobs/database/chatter-queue-publisher-database.service.d.ts +1 -1
- package/dist/jobs/database/chatter-queue-publisher-database.service.d.ts.map +1 -1
- package/dist/jobs/database/chatter-queue-publisher-database.service.js.map +1 -1
- package/dist/jobs/database/chatter-queue-subscriber-database.service.d.ts +1 -1
- package/dist/jobs/database/chatter-queue-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/chatter-queue-subscriber-database.service.js.map +1 -1
- package/dist/jobs/rabbitmq/chatter-queue-publisher.service.d.ts +1 -12
- package/dist/jobs/rabbitmq/chatter-queue-publisher.service.d.ts.map +1 -1
- package/dist/jobs/rabbitmq/chatter-queue-publisher.service.js.map +1 -1
- package/dist/jobs/rabbitmq/chatter-queue-subscriber.service.d.ts +1 -1
- package/dist/jobs/rabbitmq/chatter-queue-subscriber.service.d.ts.map +1 -1
- package/dist/jobs/rabbitmq/chatter-queue-subscriber.service.js.map +1 -1
- package/dist/jobs/redis/chatter-queue-subscriber-redis.service.d.ts +1 -1
- package/dist/jobs/redis/chatter-queue-subscriber-redis.service.d.ts.map +1 -1
- package/dist/jobs/redis/chatter-queue-subscriber-redis.service.js.map +1 -1
- package/dist/repository/user-api-key.repository.d.ts +12 -0
- package/dist/repository/user-api-key.repository.d.ts.map +1 -0
- package/dist/repository/user-api-key.repository.js +34 -0
- package/dist/repository/user-api-key.repository.js.map +1 -0
- package/dist/seeders/module-test-data.service.d.ts +5 -0
- package/dist/seeders/module-test-data.service.d.ts.map +1 -1
- package/dist/seeders/module-test-data.service.js +131 -4
- package/dist/seeders/module-test-data.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +287 -197
- package/dist/services/api-key.service.d.ts +20 -0
- package/dist/services/api-key.service.d.ts.map +1 -0
- package/dist/services/api-key.service.js +98 -0
- package/dist/services/api-key.service.js.map +1 -0
- package/dist/services/authentication.service.d.ts +19 -1
- package/dist/services/authentication.service.d.ts.map +1 -1
- package/dist/services/authentication.service.js +31 -5
- package/dist/services/authentication.service.js.map +1 -1
- package/dist/services/chatter-message.service.d.ts.map +1 -1
- package/dist/services/chatter-message.service.js +6 -0
- package/dist/services/chatter-message.service.js.map +1 -1
- package/dist/services/encryption.service.d.ts +8 -0
- package/dist/services/encryption.service.d.ts.map +1 -0
- package/dist/services/encryption.service.js +75 -0
- package/dist/services/encryption.service.js.map +1 -0
- package/dist/services/export-transaction.service.d.ts.map +1 -1
- package/dist/services/export-transaction.service.js +0 -23
- package/dist/services/export-transaction.service.js.map +1 -1
- package/dist/services/field-metadata.service.d.ts +1 -3
- package/dist/services/field-metadata.service.d.ts.map +1 -1
- package/dist/services/field-metadata.service.js +6 -13
- package/dist/services/field-metadata.service.js.map +1 -1
- package/dist/services/file/disk-file.service.d.ts +1 -0
- package/dist/services/file/disk-file.service.d.ts.map +1 -1
- package/dist/services/file/disk-file.service.js +11 -3
- package/dist/services/file/disk-file.service.js.map +1 -1
- package/dist/services/media.service.d.ts +0 -1
- package/dist/services/media.service.d.ts.map +1 -1
- package/dist/services/media.service.js +10 -11
- package/dist/services/media.service.js.map +1 -1
- package/dist/services/setting.service.d.ts +1 -0
- package/dist/services/setting.service.d.ts.map +1 -1
- package/dist/services/setting.service.js +35 -7
- package/dist/services/setting.service.js.map +1 -1
- package/dist/services/settings/default-settings-provider.service.d.ts +12 -0
- package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
- package/dist/services/settings/default-settings-provider.service.js +7 -3
- package/dist/services/settings/default-settings-provider.service.js.map +1 -1
- package/dist/services/sso-code-storage.service.d.ts +15 -0
- package/dist/services/sso-code-storage.service.d.ts.map +1 -0
- package/dist/services/sso-code-storage.service.js +47 -0
- package/dist/services/sso-code-storage.service.js.map +1 -0
- package/dist/services/user.service.d.ts.map +1 -1
- package/dist/services/user.service.js +3 -2
- package/dist/services/user.service.js.map +1 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +10 -0
- package/dist/solid-core.module.js.map +1 -1
- package/dist/subscribers/audit.subscriber.d.ts +1 -1
- package/dist/subscribers/audit.subscriber.d.ts.map +1 -1
- package/dist/subscribers/audit.subscriber.js.map +1 -1
- package/package.json +1 -1
- package/src/controllers/authentication.controller.ts +59 -3
- package/src/dtos/create-api-key.dto.ts +14 -0
- package/src/dtos/post-chatter-message.dto.ts +4 -0
- package/src/dtos/register-private.dto.ts +5 -14
- package/src/dtos/sso-exchange.dto.ts +7 -0
- package/src/dtos/update-api-key.dto.ts +9 -0
- package/src/entities/agent-event.entity.ts +21 -55
- package/src/entities/agent-session.entity.ts +15 -47
- package/src/entities/field-metadata.entity.ts +1 -1
- package/src/entities/legacy-common.entity.ts +15 -15
- package/src/entities/setting.entity.ts +3 -0
- package/src/entities/sms-template.entity.ts +3 -2
- package/src/entities/user-api-key.entity.ts +37 -0
- package/src/entities/user.entity.ts +8 -0
- package/src/enums/auth-type.enum.ts +1 -0
- package/src/guards/api-key.guard.ts +32 -0
- package/src/guards/authentication.guard.ts +6 -3
- package/src/helpers/bootstrap.helper.ts +16 -1
- package/src/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.ts +17 -6
- package/src/helpers/typeorm-db-helper.ts +11 -0
- package/src/index.ts +2 -0
- package/src/interfaces.ts +16 -0
- package/src/jobs/database/chatter-queue-publisher-database.service.ts +1 -1
- package/src/jobs/database/chatter-queue-subscriber-database.service.ts +1 -1
- package/src/jobs/rabbitmq/chatter-queue-publisher.service.ts +1 -15
- package/src/jobs/rabbitmq/chatter-queue-subscriber.service.ts +1 -1
- package/src/jobs/redis/chatter-queue-subscriber-redis.service.ts +1 -1
- package/src/repository/user-api-key.repository.ts +17 -0
- package/src/seeders/module-test-data.service.ts +165 -6
- package/src/seeders/seed-data/solid-core-metadata.json +287 -197
- package/src/services/api-key.service.ts +111 -0
- package/src/services/authentication.service.ts +35 -3
- package/src/services/chatter-message.service.ts +7 -0
- package/src/services/encryption.service.ts +43 -0
- package/src/services/export-transaction.service.ts +0 -26
- package/src/services/field-metadata.service.ts +5 -12
- package/src/services/file/disk-file.service.ts +15 -7
- package/src/services/media.service.ts +12 -51
- package/src/services/setting.service.ts +38 -9
- package/src/services/settings/default-settings-provider.service.ts +7 -3
- package/src/services/sso-code-storage.service.ts +36 -0
- package/src/services/user.service.ts +3 -2
- package/src/solid-core.module.ts +10 -0
- package/src/subscribers/audit.subscriber.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.subscriber.js","sourceRoot":"","sources":["../../src/subscribers/audit.subscriber.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA2D;AAC3D,4DAAuD;AACvD,8DAA2D;AAG3D,iFAA6E;AAC7E,4FAAiF;AAG1E,IAAM,eAAe,uBAArB,MAAM,eAAe;IAGxB,YACqB,gBAAqD,EACrD,aAA4B,EAC5B,qBAA4C;QAF5C,qBAAgB,GAAhB,gBAAgB,CAAqC;QACrD,kBAAa,GAAb,aAAa,CAAe;QAC5B,0BAAqB,GAArB,qBAAqB,CAAuB;QALhD,WAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;QAcnD,WAAM,GAAG,IAAI,OAAO,EAA4B,CAAC;IARrD,CAAC;IAEL,gBAAgB,CAAC,UAAsB;QACnC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAKO,OAAO,CAAC,KAA2B,EAAE,OAA0B;QACnE,MAAM,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O,EAAE,EAAE,uBAAuB,CAAC,CAAC,CAC5F,CAAC;QAEF,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,qCAAqC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAC9E,MAAM,CAAC,MAAM,CAChB,CAAC;YACN,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,wBAAwB,CAAC,KAA2B;QAEhD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAA;AAjGY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,EAAC,EAAC,KAAK,EAAE,cAAK,CAAC,SAAS,EAAC,CAAC;qCAKM,4CAAgB;QACnB,8BAAa;QACL,+CAAqB;GANxD,eAAe,CAiG3B","sourcesContent":["import { Injectable, Logger, Scope } from '@nestjs/common';\nimport { lowerFirst } from 'src/helpers/string.helper';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { DataSource, EntityMetadata, EntitySubscriberInterface, InsertEvent, RemoveEvent, UpdateEvent } from 'typeorm';\nimport { AuditQueuePayload } from 'src/
|
|
1
|
+
{"version":3,"file":"audit.subscriber.js","sourceRoot":"","sources":["../../src/subscribers/audit.subscriber.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA2D;AAC3D,4DAAuD;AACvD,8DAA2D;AAG3D,iFAA6E;AAC7E,4FAAiF;AAG1E,IAAM,eAAe,uBAArB,MAAM,eAAe;IAGxB,YACqB,gBAAqD,EACrD,aAA4B,EAC5B,qBAA4C;QAF5C,qBAAgB,GAAhB,gBAAgB,CAAqC;QACrD,kBAAa,GAAb,aAAa,CAAe;QAC5B,0BA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AAK,CAAC,sBAAsB,CAAC,KAA2B;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACvD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAItC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CACpC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE,uBAAuB,CAAC,CAAC,CAC5F,CAAC;QAEF,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,qCAAqC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAC9E,MAAM,CAAC,MAAM,CAChB,CAAC;YACN,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,wBAAwB,CAAC,KAA2B;QAEhD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAA;AAjGY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,EAAC,EAAC,KAAK,EAAE,cAAK,CAAC,SAAS,EAAC,CAAC;qCAKM,4CAAgB;QACnB,8BAAa;QACL,+CAAqB;GANxD,eAAe,CAiG3B","sourcesContent":["import { Injectable, Logger, Scope } from '@nestjs/common';\nimport { lowerFirst } from 'src/helpers/string.helper';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { DataSource, EntityMetadata, EntitySubscriberInterface, InsertEvent, RemoveEvent, UpdateEvent } from 'typeorm';\nimport { AuditQueuePayload } from 'src/interfaces';\nimport { RequestContextService } from 'src/services/request-context.service';\nimport { PublisherFactory } from 'src/services/queues/publisher-factory.service';\n\n@Injectable({scope: Scope.TRANSIENT})\nexport class AuditSubscriber implements EntitySubscriberInterface {\n private readonly logger = new Logger(AuditSubscriber.name);\n private dataSource: DataSource;\n constructor(\n private readonly publisherFactory: PublisherFactory<AuditQueuePayload>,\n private readonly solidRegistry: SolidRegistry,\n private readonly requestContextService: RequestContextService,\n ) { }\n\n bindToDataSource(dataSource: DataSource) {\n this.dataSource = dataSource;\n this.dataSource.subscribers.push(this);\n }\n\n // Per-transaction buffer (auto-GC when queryRunner is gone)\n private perTxn = new WeakMap<any, AuditQueuePayload[]>();\n\n private enqueue(event: { queryRunner: any }, payload: AuditQueuePayload) {\n const qr = event.queryRunner;\n const arr = this.perTxn.get(qr) ?? [];\n arr.push(payload);\n this.perTxn.set(qr, arr);\n }\n\n private shouldTrackAudit(metadata: EntityMetadata): boolean {\n return this.solidRegistry.isAuditableModel(lowerFirst(metadata.name));\n }\n\n private activeUserId(): number | null {\n return this.requestContextService.getActiveUser()?.sub ?? null;\n }\n\n async afterInsert(event: InsertEvent<any>) {\n if (!this.shouldTrackAudit(event.metadata)) return;\n this.enqueue(event, {\n eventType: 'insert',\n modelName: event.metadata.name,\n entityId: event.entity?.id ?? null,\n occurredAt: new Date().toISOString(),\n after: event.entity ?? null,\n userId: this.activeUserId(),\n });\n }\n\n async afterUpdate(event: UpdateEvent<any>) {\n if (!this.shouldTrackAudit(event.metadata)) return;\n this.enqueue(event, {\n eventType: 'update',\n modelName: event.metadata.name,\n entityId: event.entity?.id ?? null,\n occurredAt: new Date().toISOString(),\n after: event.entity ?? null,\n // databaseEntity is only populated when the entity was fetched first (save() path).\n // QueryBuilder update() leaves this undefined; postAuditMessageOnUpdate guards for it.\n before: event.databaseEntity ?? null,\n updatedColumnNames: (event.updatedColumns ?? []).map(c => c.propertyName),\n userId: this.activeUserId(),\n });\n }\n\n async afterRemove(event: RemoveEvent<any>) {\n if (!this.shouldTrackAudit(event.metadata)) return;\n this.enqueue(event, {\n eventType: 'delete',\n modelName: event.metadata.name,\n entityId: event.databaseEntity?.id ?? null,\n occurredAt: new Date().toISOString(),\n before: event.databaseEntity,\n userId: this.activeUserId(),\n });\n }\n\n // --------- transaction lifecycle ----------\n async afterTransactionCommit(event: { queryRunner: any }) {\n const batch = this.perTxn.get(event.queryRunner) ?? [];\n this.perTxn.delete(event.queryRunner);\n\n // Now outside the DB transaction — safe to publish to the queue.\n // allSettled: publish in parallel; a single failure does not block the rest.\n const results = await Promise.allSettled(\n batch.map(payload => this.publisherFactory.publish({ payload }, 'ChatterQueuePublisher'))\n );\n\n results.forEach((result, i) => {\n if (result.status === 'rejected') {\n this.logger.error(\n `Failed to publish audit event for ${batch[i].modelName}#${batch[i].entityId}`,\n result.reason,\n );\n }\n });\n }\n\n afterTransactionRollback(event: { queryRunner: any }) {\n // Drop buffered payloads; the write never happened.\n this.perTxn.delete(event.queryRunner);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidxai/core",
|
|
3
|
-
"version": "0.1.8-beta.
|
|
3
|
+
"version": "0.1.8-beta.11",
|
|
4
4
|
"description": "This module is a NestJS module containing all the required core providers required by a Solid application",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import { Body, Controller, Get, HttpCode, HttpStatus, Logger, Post, Res } from '@nestjs/common';
|
|
1
|
+
import { Body, Controller, Get, HttpCode, HttpStatus, Logger, Param, ParseIntPipe, Patch, Post, Res, Headers } from '@nestjs/common';
|
|
2
2
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
|
3
3
|
import { Response } from 'express';
|
|
4
4
|
import { ActiveUser } from "../decorators/active-user.decorator";
|
|
5
5
|
import { Public } from '../decorators/public.decorator';
|
|
6
6
|
import { ChangePasswordDto } from "../dtos/change-password.dto";
|
|
7
7
|
import { ConfirmForgotPasswordDto } from '../dtos/confirm-forgot-password.dto';
|
|
8
|
+
import { CreateApiKeyDto } from '../dtos/create-api-key.dto';
|
|
9
|
+
import { UpdateApiKeyDto } from '../dtos/update-api-key.dto';
|
|
8
10
|
import { InitiateForgotPasswordDto } from '../dtos/initiate-forgot-password.dto';
|
|
9
11
|
import { RefreshTokenDto } from '../dtos/refresh-token.dto';
|
|
12
|
+
import { SsoExchangeDto } from '../dtos/sso-exchange.dto';
|
|
10
13
|
import { SignInDto } from '../dtos/sign-in.dto';
|
|
14
|
+
import { RegisterPrivateDto } from '../dtos/register-private.dto';
|
|
11
15
|
import { SignUpDto } from '../dtos/sign-up.dto';
|
|
12
16
|
import { ActiveUserData } from "../interfaces/active-user-data.interface";
|
|
17
|
+
import { ApiKeyService } from '../services/api-key.service';
|
|
13
18
|
import { AuthenticationService } from '../services/authentication.service';
|
|
14
19
|
|
|
15
20
|
|
|
@@ -21,7 +26,10 @@ import { AuthenticationService } from '../services/authentication.service';
|
|
|
21
26
|
export class AuthenticationController {
|
|
22
27
|
private readonly logger = new Logger(AuthenticationController.name);
|
|
23
28
|
|
|
24
|
-
constructor(
|
|
29
|
+
constructor(
|
|
30
|
+
private readonly authService: AuthenticationService,
|
|
31
|
+
private readonly apiKeyService: ApiKeyService,
|
|
32
|
+
) { }
|
|
25
33
|
|
|
26
34
|
@Public()
|
|
27
35
|
// @SkipThrottle({ login: false, short: true, burst: true, sustained: true }) //Enable the login throttle only
|
|
@@ -32,7 +40,7 @@ export class AuthenticationController {
|
|
|
32
40
|
|
|
33
41
|
@ApiBearerAuth("jwt")
|
|
34
42
|
@Post('register-private')
|
|
35
|
-
signUpPrivate(@Body() signUpDto:
|
|
43
|
+
signUpPrivate(@Body() signUpDto: RegisterPrivateDto, @ActiveUser() activeUser: ActiveUserData) {
|
|
36
44
|
return this.authService.signUp(signUpDto, activeUser);
|
|
37
45
|
}
|
|
38
46
|
|
|
@@ -102,4 +110,52 @@ export class AuthenticationController {
|
|
|
102
110
|
async logout(@Body('refreshToken') refreshToken: string) {
|
|
103
111
|
return this.authService.logout(refreshToken);
|
|
104
112
|
}
|
|
113
|
+
|
|
114
|
+
@ApiBearerAuth("jwt")
|
|
115
|
+
@Post('api-keys')
|
|
116
|
+
@HttpCode(HttpStatus.CREATED)
|
|
117
|
+
generateApiKey(
|
|
118
|
+
@Body() dto: CreateApiKeyDto,
|
|
119
|
+
@ActiveUser() activeUser: ActiveUserData,
|
|
120
|
+
) {
|
|
121
|
+
return this.apiKeyService.generate(activeUser.sub, dto);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@ApiBearerAuth("jwt")
|
|
125
|
+
@Post('api-keys/users/:userId')
|
|
126
|
+
@HttpCode(HttpStatus.CREATED)
|
|
127
|
+
generateApiKeyForUser(
|
|
128
|
+
@Param('userId', ParseIntPipe) userId: number,
|
|
129
|
+
@Body() dto: CreateApiKeyDto,
|
|
130
|
+
) {
|
|
131
|
+
return this.apiKeyService.generate(userId, dto);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@ApiBearerAuth("jwt")
|
|
135
|
+
@Patch('api-keys/:id')
|
|
136
|
+
@HttpCode(HttpStatus.OK)
|
|
137
|
+
updateApiKey(
|
|
138
|
+
@Param('id', ParseIntPipe) id: number,
|
|
139
|
+
@Body() dto: UpdateApiKeyDto,
|
|
140
|
+
@ActiveUser() activeUser: ActiveUserData,
|
|
141
|
+
) {
|
|
142
|
+
return this.apiKeyService.updateKey(id, activeUser.sub, dto);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@Post('sso/code')
|
|
146
|
+
@HttpCode(HttpStatus.OK)
|
|
147
|
+
generateSsoCode(
|
|
148
|
+
@ActiveUser() activeUser: ActiveUserData,
|
|
149
|
+
@Headers('authorization') authorization: string,
|
|
150
|
+
) {
|
|
151
|
+
const rawAccessToken = authorization?.replace(/^Bearer\s+/i, '');
|
|
152
|
+
return this.authService.generateSsoCode(activeUser, rawAccessToken);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@Public()
|
|
156
|
+
@Post('sso/exchange')
|
|
157
|
+
@HttpCode(HttpStatus.OK)
|
|
158
|
+
exchangeSsoCode(@Body() ssoExchangeDto: SsoExchangeDto) {
|
|
159
|
+
return this.authService.exchangeSsoCode(ssoExchangeDto.code);
|
|
160
|
+
}
|
|
105
161
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { IsDateString, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
export class CreateApiKeyDto {
|
|
5
|
+
@ApiProperty({ example: 'Production Server' })
|
|
6
|
+
@IsString()
|
|
7
|
+
@IsNotEmpty()
|
|
8
|
+
name: string;
|
|
9
|
+
|
|
10
|
+
@ApiPropertyOptional({ example: '2027-01-01T00:00:00.000Z' })
|
|
11
|
+
@IsDateString()
|
|
12
|
+
@IsOptional()
|
|
13
|
+
expiresAt?: string;
|
|
14
|
+
}
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export class RegisterPrivateDto {
|
|
4
|
-
@IsNotEmpty()
|
|
5
|
-
username: string;
|
|
6
|
-
|
|
7
|
-
@IsEmail()
|
|
8
|
-
@IsNotEmpty()
|
|
9
|
-
email: string;
|
|
10
|
-
|
|
11
|
-
@IsOptional()
|
|
12
|
-
mobile?: string;
|
|
1
|
+
import { IsBoolean, IsOptional } from 'class-validator';
|
|
2
|
+
import { SignUpDto } from './sign-up.dto';
|
|
13
3
|
|
|
4
|
+
export class RegisterPrivateDto extends SignUpDto {
|
|
5
|
+
@IsBoolean()
|
|
14
6
|
@IsOptional()
|
|
15
|
-
|
|
16
|
-
password?: string;
|
|
7
|
+
isAllowedToGenerateApiKeys?: boolean;
|
|
17
8
|
}
|
|
@@ -1,88 +1,54 @@
|
|
|
1
|
-
import { Column, Entity, Index
|
|
2
|
-
import {
|
|
1
|
+
import { Column, Entity, Index } from 'typeorm';
|
|
2
|
+
import { CommonEntity } from 'src/entities/common.entity';
|
|
3
|
+
import { getColumnType } from 'src/helpers/typeorm-db-helper';
|
|
3
4
|
|
|
4
|
-
@
|
|
5
|
-
|
|
6
|
-
export class AgentEvent {
|
|
7
|
-
@Expose()
|
|
8
|
-
@PrimaryGeneratedColumn({ type: 'integer' })
|
|
9
|
-
id: number;
|
|
10
|
-
|
|
11
|
-
@Expose()
|
|
5
|
+
@Entity({ name: 'ss_agent_events' })
|
|
6
|
+
export class AgentEvent extends CommonEntity {
|
|
12
7
|
@Index()
|
|
13
|
-
@Column({
|
|
8
|
+
@Column({ })
|
|
14
9
|
sessionId: string;
|
|
15
10
|
|
|
16
|
-
@
|
|
17
|
-
@Column({ type: 'integer', name: 'turn_number' })
|
|
11
|
+
@Column({ })
|
|
18
12
|
turnNumber: number;
|
|
19
13
|
|
|
20
|
-
@
|
|
21
|
-
@Column({ type: 'integer', nullable: true, name: 'step_number' })
|
|
14
|
+
@Column({ nullable: true })
|
|
22
15
|
stepNumber: number;
|
|
23
16
|
|
|
24
|
-
@Expose()
|
|
25
17
|
@Index()
|
|
26
|
-
@Column({
|
|
18
|
+
@Column({ })
|
|
27
19
|
eventType: string;
|
|
28
20
|
|
|
29
|
-
@
|
|
30
|
-
|
|
31
|
-
eventData: string;
|
|
21
|
+
@Column({ type: "simple-json", nullable: true, ...getColumnType('simpleJsonLargeText') })
|
|
22
|
+
eventData: any;
|
|
32
23
|
|
|
33
|
-
@
|
|
34
|
-
@Column({ type: 'text', nullable: true, name: 'content' })
|
|
24
|
+
@Column({ nullable: true, ...getColumnType('longText') })
|
|
35
25
|
content: string;
|
|
36
26
|
|
|
37
|
-
@Expose()
|
|
38
27
|
@Index()
|
|
39
|
-
@Column({
|
|
28
|
+
@Column({ nullable: true })
|
|
40
29
|
toolName: string;
|
|
41
30
|
|
|
42
|
-
@
|
|
43
|
-
@Column({ type: 'text', nullable: true, name: 'tool_arguments' })
|
|
31
|
+
@Column({ type: "simple-json", nullable: true, ...getColumnType('simpleJsonLargeText') })
|
|
44
32
|
toolArguments: string;
|
|
45
33
|
|
|
46
|
-
@
|
|
47
|
-
@Column({ type: 'text', nullable: true, name: 'tool_output' })
|
|
34
|
+
@Column({ nullable: true, ...getColumnType('longText') })
|
|
48
35
|
toolOutput: string;
|
|
49
36
|
|
|
50
|
-
@
|
|
51
|
-
@Column({ type: 'integer', nullable: true, name: 'tool_returncode' })
|
|
37
|
+
@Column({ nullable: true })
|
|
52
38
|
toolReturncode: number;
|
|
53
39
|
|
|
54
|
-
@
|
|
55
|
-
@Column({ type: 'double precision', nullable: true, name: 'duration_ms' })
|
|
40
|
+
@Column({ nullable: true, ...getColumnType('decimal') })
|
|
56
41
|
durationMs: number;
|
|
57
42
|
|
|
58
|
-
@
|
|
59
|
-
@Column({ type: 'double precision', nullable: true, name: 'cost' })
|
|
43
|
+
@Column({ nullable: true, ...getColumnType('decimal') })
|
|
60
44
|
cost: number;
|
|
61
45
|
|
|
62
|
-
@
|
|
63
|
-
@Column({ type: 'integer', nullable: true, name: 'input_tokens' })
|
|
46
|
+
@Column({ nullable: true })
|
|
64
47
|
inputTokens: number;
|
|
65
48
|
|
|
66
|
-
@
|
|
67
|
-
@Column({ type: 'integer', nullable: true, name: 'output_tokens' })
|
|
49
|
+
@Column({ nullable: true })
|
|
68
50
|
outputTokens: number;
|
|
69
51
|
|
|
70
|
-
@
|
|
71
|
-
@Column({ type: 'varchar', length: 255, nullable: true, name: 'model_used' })
|
|
52
|
+
@Column({ nullable: true })
|
|
72
53
|
modelUsed: string;
|
|
73
|
-
|
|
74
|
-
@Expose()
|
|
75
|
-
@Column({ type: 'timestamp without time zone', name: 'created_at' })
|
|
76
|
-
createdAt: Date;
|
|
77
|
-
|
|
78
|
-
// The following properties satisfy CRUDService<T extends CommonEntity> structural typing
|
|
79
|
-
// They are not mapped to DB columns (synchronize: false ensures no schema changes)
|
|
80
|
-
updatedAt: Date;
|
|
81
|
-
deletedAt: Date;
|
|
82
|
-
deletedTracker: string;
|
|
83
|
-
publishedAt: Date;
|
|
84
|
-
localeName: string;
|
|
85
|
-
defaultEntityLocaleId: number;
|
|
86
|
-
createdBy: number;
|
|
87
|
-
updatedBy: number;
|
|
88
54
|
}
|
|
@@ -1,71 +1,39 @@
|
|
|
1
|
-
import { Column, Entity, Index
|
|
2
|
-
import {
|
|
1
|
+
import { Column, Entity, Index } from 'typeorm';
|
|
2
|
+
import { CommonEntity } from 'src/entities/common.entity';
|
|
3
|
+
import { getColumnType } from 'src/helpers/typeorm-db-helper';
|
|
3
4
|
|
|
4
|
-
@
|
|
5
|
-
|
|
6
|
-
export class AgentSession {
|
|
7
|
-
@Expose()
|
|
8
|
-
@PrimaryGeneratedColumn({ type: 'integer' })
|
|
9
|
-
id: number;
|
|
10
|
-
|
|
11
|
-
@Expose()
|
|
5
|
+
@Entity({ name: 'ss_agent_sessions' })
|
|
6
|
+
export class AgentSession extends CommonEntity {
|
|
12
7
|
@Index({ unique: true })
|
|
13
|
-
@Column({
|
|
8
|
+
@Column({ })
|
|
14
9
|
sessionId: string;
|
|
15
10
|
|
|
16
|
-
@Expose()
|
|
17
11
|
@Index()
|
|
18
|
-
@Column({
|
|
12
|
+
@Column({ nullable: true })
|
|
19
13
|
userId: number;
|
|
20
14
|
|
|
21
|
-
@
|
|
22
|
-
@Column({ type: 'text', nullable: true, name: 'project_root' })
|
|
15
|
+
@Column({ nullable: true, ...getColumnType('longText') })
|
|
23
16
|
projectRoot: string;
|
|
24
17
|
|
|
25
|
-
@
|
|
26
|
-
@Column({ type: 'varchar', length: 255, name: 'model_name' })
|
|
18
|
+
@Column({ })
|
|
27
19
|
modelName: string;
|
|
28
20
|
|
|
29
|
-
@Expose()
|
|
30
21
|
@Index()
|
|
31
|
-
@Column({
|
|
22
|
+
@Column({ })
|
|
32
23
|
status: string;
|
|
33
24
|
|
|
34
|
-
@
|
|
35
|
-
@Column({ type: 'double precision', name: 'total_cost', default: 0 })
|
|
25
|
+
@Column({ default: 0, ...getColumnType('decimal') })
|
|
36
26
|
totalCost: number;
|
|
37
27
|
|
|
38
|
-
@
|
|
39
|
-
@Column({ type: 'integer', name: 'total_steps', default: 0 })
|
|
28
|
+
@Column({ default: 0 })
|
|
40
29
|
totalSteps: number;
|
|
41
30
|
|
|
42
|
-
@
|
|
43
|
-
@Column({ type: 'integer', name: 'total_input_tokens', default: 0 })
|
|
31
|
+
@Column({ default: 0 })
|
|
44
32
|
totalInputTokens: number;
|
|
45
33
|
|
|
46
|
-
@
|
|
47
|
-
@Column({ type: 'integer', name: 'total_output_tokens', default: 0 })
|
|
34
|
+
@Column({ default: 0 })
|
|
48
35
|
totalOutputTokens: number;
|
|
49
36
|
|
|
50
|
-
@
|
|
51
|
-
@Column({ type: 'text', nullable: true, name: 'summary' })
|
|
37
|
+
@Column({ nullable: true, ...getColumnType('longText') })
|
|
52
38
|
summary: string;
|
|
53
|
-
|
|
54
|
-
@Expose()
|
|
55
|
-
@Column({ type: 'timestamp without time zone', name: 'created_at' })
|
|
56
|
-
createdAt: Date;
|
|
57
|
-
|
|
58
|
-
@Expose()
|
|
59
|
-
@Column({ type: 'timestamp without time zone', name: 'updated_at' })
|
|
60
|
-
updatedAt: Date;
|
|
61
|
-
|
|
62
|
-
// The following properties satisfy CRUDService<T extends CommonEntity> structural typing
|
|
63
|
-
// They are not mapped to DB columns (synchronize: false ensures no schema changes)
|
|
64
|
-
deletedAt: Date;
|
|
65
|
-
deletedTracker: string;
|
|
66
|
-
publishedAt: Date;
|
|
67
|
-
localeName: string;
|
|
68
|
-
defaultEntityLocaleId: number;
|
|
69
|
-
createdBy: number;
|
|
70
|
-
updatedBy: number;
|
|
71
39
|
}
|
|
@@ -119,7 +119,7 @@ export class FieldMetadata extends CommonEntity {
|
|
|
119
119
|
@Column({ name: 'selection_static_values', nullable: true, type: 'simple-array' })
|
|
120
120
|
selectionStaticValues: string[];
|
|
121
121
|
|
|
122
|
-
@Column({ name: 'selection_value_type', nullable: true })
|
|
122
|
+
@Column({ name: 'selection_value_type', nullable: true, default: 'string' })
|
|
123
123
|
selectionValueType: string = 'string';
|
|
124
124
|
|
|
125
125
|
// @Column({ name: "computed", default: false })
|
|
@@ -11,30 +11,30 @@ export abstract class LegacyCommonEntity {
|
|
|
11
11
|
// @Generated("increment")
|
|
12
12
|
// id: number
|
|
13
13
|
|
|
14
|
-
@CreateDateColumn({ name: `${LEGACY_TABLE_FIELDS_PREFIX}_created_at`, transformer: LocalDateTimeTransformer })
|
|
15
|
-
createdAt: Date;
|
|
14
|
+
@CreateDateColumn({ name: `${LEGACY_TABLE_FIELDS_PREFIX}_created_at`, transformer: LocalDateTimeTransformer, nullable: true })
|
|
15
|
+
createdAt: Date | null;
|
|
16
16
|
|
|
17
|
-
@UpdateDateColumn({ name: `${LEGACY_TABLE_FIELDS_PREFIX}_updated_at`, transformer: LocalDateTimeTransformer })
|
|
18
|
-
updatedAt: Date;
|
|
17
|
+
@UpdateDateColumn({ name: `${LEGACY_TABLE_FIELDS_PREFIX}_updated_at`, transformer: LocalDateTimeTransformer, nullable: true })
|
|
18
|
+
updatedAt: Date | null;
|
|
19
19
|
|
|
20
|
-
@DeleteDateColumn({ name: `${LEGACY_TABLE_FIELDS_PREFIX}_deleted_at`, transformer: LocalDateTimeTransformer })
|
|
20
|
+
@DeleteDateColumn({ name: `${LEGACY_TABLE_FIELDS_PREFIX}_deleted_at`, transformer: LocalDateTimeTransformer, nullable: true })
|
|
21
21
|
@Index()
|
|
22
|
-
deletedAt: Date;
|
|
22
|
+
deletedAt: Date | null;
|
|
23
23
|
|
|
24
|
-
@Column({ name: `${LEGACY_TABLE_FIELDS_PREFIX}_deleted_tracker`, default: "not-deleted" })
|
|
25
|
-
deletedTracker: string;
|
|
24
|
+
@Column({ name: `${LEGACY_TABLE_FIELDS_PREFIX}_deleted_tracker`, default: "not-deleted", nullable: true })
|
|
25
|
+
deletedTracker: string | null;
|
|
26
26
|
|
|
27
27
|
@Expose()
|
|
28
28
|
@Column({ name: `${LEGACY_TABLE_FIELDS_PREFIX}_published_at`, default: null, nullable: true, transformer: LocalDateTimeTransformer })
|
|
29
|
-
publishedAt: Date;
|
|
29
|
+
publishedAt: Date | null;
|
|
30
30
|
|
|
31
31
|
@Expose()
|
|
32
|
-
@Column({ type: "varchar", name: `${LEGACY_TABLE_FIELDS_PREFIX}_locale_name`, default: null })
|
|
33
|
-
localeName: string;
|
|
32
|
+
@Column({ type: "varchar", name: `${LEGACY_TABLE_FIELDS_PREFIX}_locale_name`, default: null, nullable: true })
|
|
33
|
+
localeName: string | null;
|
|
34
34
|
|
|
35
35
|
@Expose()
|
|
36
|
-
@Column({ type: "int", name: `${LEGACY_TABLE_FIELDS_PREFIX}_default_entity_locale_id`, default: null })
|
|
37
|
-
defaultEntityLocaleId: number;
|
|
36
|
+
@Column({ type: "int", name: `${LEGACY_TABLE_FIELDS_PREFIX}_default_entity_locale_id`, default: null, nullable: true })
|
|
37
|
+
defaultEntityLocaleId: number | null;
|
|
38
38
|
|
|
39
39
|
// @Expose()
|
|
40
40
|
// @Type( () => require('./user.entity').User?.default ?? require('./user.entity').User )
|
|
@@ -50,9 +50,9 @@ export abstract class LegacyCommonEntity {
|
|
|
50
50
|
|
|
51
51
|
@Expose()
|
|
52
52
|
@Column({ name: `${LEGACY_TABLE_FIELDS_PREFIX}_created_by_id`, nullable: true })
|
|
53
|
-
createdBy: number;
|
|
53
|
+
createdBy: number | null;
|
|
54
54
|
|
|
55
55
|
@Expose()
|
|
56
56
|
@Column({ name: `${LEGACY_TABLE_FIELDS_PREFIX}_updated_by_id`, nullable: true })
|
|
57
|
-
updatedBy: number;
|
|
57
|
+
updatedBy: number | null;
|
|
58
58
|
}
|
|
@@ -19,6 +19,9 @@ export class Setting extends CommonEntity {
|
|
|
19
19
|
@Column({ name: "level", type: "varchar", nullable: true })
|
|
20
20
|
level: string;
|
|
21
21
|
|
|
22
|
+
@Column({ name: "encrypted", type: "boolean", default: false })
|
|
23
|
+
encrypted: boolean;
|
|
24
|
+
|
|
22
25
|
@Index()
|
|
23
26
|
@ManyToOne(() => User, { nullable: true })
|
|
24
27
|
@JoinColumn()
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { CommonEntity } from 'src/entities/common.entity';
|
|
2
2
|
import { Column, Entity, Index } from 'typeorm';
|
|
3
|
+
import { getColumnType } from 'src/helpers/typeorm-db-helper';
|
|
3
4
|
|
|
4
5
|
@Entity("ss_sms_template")
|
|
5
6
|
export class SmsTemplate extends CommonEntity {
|
|
6
7
|
@Index({ unique: true })
|
|
7
|
-
@Column({ name: "name", type: "varchar"})
|
|
8
|
+
@Column({ name: "name", type: "varchar" })
|
|
8
9
|
name: string;
|
|
9
10
|
@Column({ name: "display_name", type: "varchar" })
|
|
10
11
|
displayName: string;
|
|
11
|
-
@Column({ name: "body",
|
|
12
|
+
@Column({ name: "body", ...getColumnType('longText'), nullable: true })
|
|
12
13
|
body: string;
|
|
13
14
|
@Column({ type: "varchar", nullable: true })
|
|
14
15
|
smsProviderTemplateId: string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Exclude, Expose } from "class-transformer";
|
|
2
|
+
import { CommonEntity } from "src/entities/common.entity";
|
|
3
|
+
import { Column, Entity, Index, ManyToOne } from "typeorm";
|
|
4
|
+
import { User } from "./user.entity";
|
|
5
|
+
|
|
6
|
+
@Entity("ss_user_api_key")
|
|
7
|
+
@Exclude()
|
|
8
|
+
export class UserApiKey extends CommonEntity {
|
|
9
|
+
|
|
10
|
+
@Expose()
|
|
11
|
+
@Column()
|
|
12
|
+
name: string;
|
|
13
|
+
|
|
14
|
+
// SHA-256 hash of the raw key — never exposed, same treatment as User.password
|
|
15
|
+
@Index({ unique: true })
|
|
16
|
+
@Column()
|
|
17
|
+
hashedKey: string;
|
|
18
|
+
|
|
19
|
+
@Expose()
|
|
20
|
+
@Column()
|
|
21
|
+
maskedKey: string;
|
|
22
|
+
|
|
23
|
+
@Expose()
|
|
24
|
+
@Column({ default: true })
|
|
25
|
+
isActive: boolean;
|
|
26
|
+
|
|
27
|
+
@Expose()
|
|
28
|
+
@Column({ nullable: true })
|
|
29
|
+
expiresAt: Date;
|
|
30
|
+
|
|
31
|
+
@Expose()
|
|
32
|
+
@Column({ nullable: true })
|
|
33
|
+
lastUsedAt: Date;
|
|
34
|
+
|
|
35
|
+
@ManyToOne(() => User, user => user.apiKeys)
|
|
36
|
+
user: User;
|
|
37
|
+
}
|
|
@@ -2,6 +2,7 @@ import { CommonEntity } from "src/entities/common.entity"
|
|
|
2
2
|
import { Entity, Column, Index, JoinTable, ManyToMany, OneToMany, TableInheritance } from "typeorm";
|
|
3
3
|
import { RoleMetadata } from 'src/entities/role-metadata.entity';
|
|
4
4
|
import { UserViewMetadata } from 'src/entities/user-view-metadata.entity'
|
|
5
|
+
import { UserApiKey } from 'src/entities/user-api-key.entity'
|
|
5
6
|
import { Exclude, Expose } from "class-transformer";
|
|
6
7
|
|
|
7
8
|
@Entity("ss_user")
|
|
@@ -151,4 +152,11 @@ export class User extends CommonEntity {
|
|
|
151
152
|
@Expose()
|
|
152
153
|
_media: any;
|
|
153
154
|
|
|
155
|
+
@Column({ default: false })
|
|
156
|
+
@Expose()
|
|
157
|
+
isAllowedToGenerateApiKeys: boolean = false;
|
|
158
|
+
|
|
159
|
+
@OneToMany(() => UserApiKey, key => key.user)
|
|
160
|
+
apiKeys: UserApiKey[];
|
|
161
|
+
|
|
154
162
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext, Injectable, UnauthorizedException } from '@nestjs/common';
|
|
2
|
+
import { Request } from 'express';
|
|
3
|
+
import { REQUEST_USER_KEY } from 'src/constants';
|
|
4
|
+
import { ApiKeyService } from 'src/services/api-key.service';
|
|
5
|
+
import { ClsService } from 'nestjs-cls';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class ApiKeyGuard implements CanActivate {
|
|
9
|
+
constructor(
|
|
10
|
+
private readonly apiKeyService: ApiKeyService,
|
|
11
|
+
private readonly cls: ClsService,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
15
|
+
const request = context.switchToHttp().getRequest<Request>();
|
|
16
|
+
const rawKey = this.extractKeyFromHeader(request);
|
|
17
|
+
|
|
18
|
+
if (!rawKey) {
|
|
19
|
+
throw new UnauthorizedException();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const activeUser = await this.apiKeyService.validate(rawKey);
|
|
23
|
+
request[REQUEST_USER_KEY] = activeUser;
|
|
24
|
+
this.cls.set(REQUEST_USER_KEY, activeUser);
|
|
25
|
+
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private extractKeyFromHeader(request: Request): string | undefined {
|
|
30
|
+
return request.headers['solidx-api-key'] as string | undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -8,23 +8,26 @@ import { Reflector } from '@nestjs/core';
|
|
|
8
8
|
import { AUTH_TYPE_KEY } from '../decorators/auth.decorator';
|
|
9
9
|
import { AuthType } from '../enums/auth-type.enum';
|
|
10
10
|
import { AccessTokenGuard } from './access-token.guard';
|
|
11
|
+
import { ApiKeyGuard } from './api-key.guard';
|
|
11
12
|
import { IS_PUBLIC_KEY } from '../decorators/public.decorator';
|
|
12
13
|
import { PermissionMetadataService } from '../services/permission-metadata.service';
|
|
13
14
|
import { ClsService } from 'nestjs-cls';
|
|
14
15
|
|
|
15
16
|
@Injectable()
|
|
16
17
|
export class AuthenticationGuard implements CanActivate {
|
|
17
|
-
private static readonly
|
|
18
|
+
private static readonly defaultAuthTypes = [AuthType.Bearer, AuthType.ApiKey];
|
|
18
19
|
private readonly authTypeGuardMap: Record<
|
|
19
20
|
AuthType,
|
|
20
21
|
CanActivate | CanActivate[]> = {
|
|
21
22
|
[AuthType.Bearer]: this.accessTokenGuard,
|
|
23
|
+
[AuthType.ApiKey]: this.apiKeyGuard,
|
|
22
24
|
[AuthType.None]: { canActivate: () => true },
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
constructor(
|
|
26
28
|
private readonly reflector: Reflector,
|
|
27
29
|
private readonly accessTokenGuard: AccessTokenGuard,
|
|
30
|
+
private readonly apiKeyGuard: ApiKeyGuard,
|
|
28
31
|
private readonly permissionService: PermissionMetadataService,
|
|
29
32
|
private readonly cls: ClsService,
|
|
30
33
|
) { }
|
|
@@ -49,7 +52,7 @@ export class AuthenticationGuard implements CanActivate {
|
|
|
49
52
|
return true;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
// TODO: Check if this permission viz. contextPermission is listed in the Public role.
|
|
55
|
+
// TODO: Check if this permission viz. contextPermission is listed in the Public role.
|
|
53
56
|
const contextPermission = `${context.getClass().name}.${context.getHandler().name}`;
|
|
54
57
|
|
|
55
58
|
const permissionExistsInRole = await this.permissionService.permissionExistsInRole('Public', contextPermission)
|
|
@@ -61,7 +64,7 @@ export class AuthenticationGuard implements CanActivate {
|
|
|
61
64
|
const authTypes = this.reflector.getAllAndOverride<AuthType[]>(
|
|
62
65
|
AUTH_TYPE_KEY,
|
|
63
66
|
[context.getHandler(), context.getClass()],
|
|
64
|
-
) ??
|
|
67
|
+
) ?? AuthenticationGuard.defaultAuthTypes;
|
|
65
68
|
const guards = authTypes.map((type) => this.authTypeGuardMap[type]).flat();
|
|
66
69
|
let error = new UnauthorizedException();
|
|
67
70
|
|