@agentforge-io/nest 2.0.22 → 2.1.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/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/services.providers.js +24 -4
- package/dist/providers/services.providers.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/database/entities/auth-identity.entity.d.ts +0 -1
- package/dist/database/entities/auth-identity.entity.js +0 -6
- package/dist/database/entities/auth-identity.entity.js.map +0 -1
- package/dist/database/entities/conversation.entity.d.ts +0 -1
- package/dist/database/entities/conversation.entity.js +0 -6
- package/dist/database/entities/conversation.entity.js.map +0 -1
- package/dist/database/entities/email-token.entity.d.ts +0 -1
- package/dist/database/entities/email-token.entity.js +0 -6
- package/dist/database/entities/email-token.entity.js.map +0 -1
- package/dist/database/entities/index.d.ts +0 -7
- package/dist/database/entities/index.js +0 -16
- package/dist/database/entities/index.js.map +0 -1
- package/dist/database/entities/message.entity.d.ts +0 -1
- package/dist/database/entities/message.entity.js +0 -6
- package/dist/database/entities/message.entity.js.map +0 -1
- package/dist/database/entities/refresh-token.entity.d.ts +0 -1
- package/dist/database/entities/refresh-token.entity.js +0 -6
- package/dist/database/entities/refresh-token.entity.js.map +0 -1
- package/dist/database/entities/subscription.entity.d.ts +0 -1
- package/dist/database/entities/subscription.entity.js +0 -6
- package/dist/database/entities/subscription.entity.js.map +0 -1
- package/dist/database/entities/usage-record.entity.d.ts +0 -1
- package/dist/database/entities/usage-record.entity.js +0 -6
- package/dist/database/entities/usage-record.entity.js.map +0 -1
- package/dist/database/entities/user.entity.d.ts +0 -1
- package/dist/database/entities/user.entity.js +0 -6
- package/dist/database/entities/user.entity.js.map +0 -1
- package/dist/decorators/require-plan.decorator.d.ts +0 -2
- package/dist/decorators/require-plan.decorator.js +0 -8
- package/dist/decorators/require-plan.decorator.js.map +0 -1
- package/dist/guards/usage-limit.guard.d.ts +0 -11
- package/dist/guards/usage-limit.guard.js +0 -57
- package/dist/guards/usage-limit.guard.js.map +0 -1
- package/dist/modules/admin/admin-plans.controller.d.ts +0 -11
- package/dist/modules/admin/admin-plans.controller.js +0 -97
- package/dist/modules/admin/admin-plans.controller.js.map +0 -1
- package/dist/modules/admin/admin-tenant-agents.controller.d.ts +0 -61
- package/dist/modules/admin/admin-tenant-agents.controller.js +0 -424
- package/dist/modules/admin/admin-tenant-agents.controller.js.map +0 -1
- package/dist/modules/admin/admin-tenant-billing.controller.d.ts +0 -51
- package/dist/modules/admin/admin-tenant-billing.controller.js +0 -119
- package/dist/modules/admin/admin-tenant-billing.controller.js.map +0 -1
- package/dist/modules/admin/admin-tenants.controller.d.ts +0 -43
- package/dist/modules/admin/admin-tenants.controller.js +0 -178
- package/dist/modules/admin/admin-tenants.controller.js.map +0 -1
- package/dist/modules/admin/admin-users.controller.d.ts +0 -41
- package/dist/modules/admin/admin-users.controller.js +0 -121
- package/dist/modules/admin/admin-users.controller.js.map +0 -1
- package/dist/modules/admin/admin.module.d.ts +0 -2
- package/dist/modules/admin/admin.module.js +0 -26
- package/dist/modules/admin/admin.module.js.map +0 -1
- package/dist/modules/admin/platform-admin.guard.d.ts +0 -7
- package/dist/modules/admin/platform-admin.guard.js +0 -52
- package/dist/modules/admin/platform-admin.guard.js.map +0 -1
- package/dist/modules/auth/auth.controller.d.ts +0 -63
- package/dist/modules/auth/auth.controller.js +0 -255
- package/dist/modules/auth/auth.controller.js.map +0 -1
- package/dist/modules/auth/auth.module.d.ts +0 -4
- package/dist/modules/auth/auth.module.js +0 -71
- package/dist/modules/auth/auth.module.js.map +0 -1
- package/dist/modules/auth/auth.service.d.ts +0 -2
- package/dist/modules/auth/auth.service.js +0 -7
- package/dist/modules/auth/auth.service.js.map +0 -1
- package/dist/modules/auth/decorators/current-user.decorator.d.ts +0 -8
- package/dist/modules/auth/decorators/current-user.decorator.js +0 -12
- package/dist/modules/auth/decorators/current-user.decorator.js.map +0 -1
- package/dist/modules/auth/decorators/public.decorator.d.ts +0 -2
- package/dist/modules/auth/decorators/public.decorator.js +0 -8
- package/dist/modules/auth/decorators/public.decorator.js.map +0 -1
- package/dist/modules/auth/dto/login.dto.d.ts +0 -4
- package/dist/modules/auth/dto/login.dto.js +0 -29
- package/dist/modules/auth/dto/login.dto.js.map +0 -1
- package/dist/modules/auth/dto/register.dto.d.ts +0 -5
- package/dist/modules/auth/dto/register.dto.js +0 -36
- package/dist/modules/auth/dto/register.dto.js.map +0 -1
- package/dist/modules/auth/guards/jwt-auth.guard.d.ts +0 -9
- package/dist/modules/auth/guards/jwt-auth.guard.js +0 -37
- package/dist/modules/auth/guards/jwt-auth.guard.js.map +0 -1
- package/dist/modules/auth/guards/local-auth.guard.d.ts +0 -4
- package/dist/modules/auth/guards/local-auth.guard.js +0 -18
- package/dist/modules/auth/guards/local-auth.guard.js.map +0 -1
- package/dist/modules/auth/guards/oauth-configured.guard.d.ts +0 -11
- package/dist/modules/auth/guards/oauth-configured.guard.js +0 -51
- package/dist/modules/auth/guards/oauth-configured.guard.js.map +0 -1
- package/dist/modules/auth/oauth.controller.d.ts +0 -20
- package/dist/modules/auth/oauth.controller.js +0 -208
- package/dist/modules/auth/oauth.controller.js.map +0 -1
- package/dist/modules/auth/refresh-token.service.d.ts +0 -2
- package/dist/modules/auth/refresh-token.service.js +0 -7
- package/dist/modules/auth/refresh-token.service.js.map +0 -1
- package/dist/modules/auth/strategies/github.strategy.d.ts +0 -12
- package/dist/modules/auth/strategies/github.strategy.js +0 -57
- package/dist/modules/auth/strategies/github.strategy.js.map +0 -1
- package/dist/modules/auth/strategies/google.strategy.d.ts +0 -19
- package/dist/modules/auth/strategies/google.strategy.js +0 -56
- package/dist/modules/auth/strategies/google.strategy.js.map +0 -1
- package/dist/modules/auth/strategies/jwt.strategy.d.ts +0 -18
- package/dist/modules/auth/strategies/jwt.strategy.js +0 -49
- package/dist/modules/auth/strategies/jwt.strategy.js.map +0 -1
- package/dist/modules/auth/strategies/local.strategy.d.ts +0 -11
- package/dist/modules/auth/strategies/local.strategy.js +0 -31
- package/dist/modules/auth/strategies/local.strategy.js.map +0 -1
- package/dist/modules/billing/adapters/billing-adapter.interface.d.ts +0 -1
- package/dist/modules/billing/adapters/billing-adapter.interface.js +0 -6
- package/dist/modules/billing/adapters/billing-adapter.interface.js.map +0 -1
- package/dist/modules/billing/adapters/stripe/stripe.adapter.d.ts +0 -19
- package/dist/modules/billing/adapters/stripe/stripe.adapter.js +0 -118
- package/dist/modules/billing/adapters/stripe/stripe.adapter.js.map +0 -1
- package/dist/modules/billing/billing.controller.d.ts +0 -54
- package/dist/modules/billing/billing.controller.js +0 -180
- package/dist/modules/billing/billing.controller.js.map +0 -1
- package/dist/modules/billing/billing.module.d.ts +0 -2
- package/dist/modules/billing/billing.module.js +0 -57
- package/dist/modules/billing/billing.module.js.map +0 -1
- package/dist/modules/billing/billing.service.d.ts +0 -2
- package/dist/modules/billing/billing.service.js +0 -7
- package/dist/modules/billing/billing.service.js.map +0 -1
- package/dist/modules/billing/usage.service.d.ts +0 -2
- package/dist/modules/billing/usage.service.js +0 -6
- package/dist/modules/billing/usage.service.js.map +0 -1
- package/dist/modules/email/adapters/email-adapter.interface.d.ts +0 -1
- package/dist/modules/email/adapters/email-adapter.interface.js +0 -6
- package/dist/modules/email/adapters/email-adapter.interface.js.map +0 -1
- package/dist/modules/email/adapters/noop.adapter.d.ts +0 -1
- package/dist/modules/email/adapters/noop.adapter.js +0 -6
- package/dist/modules/email/adapters/noop.adapter.js.map +0 -1
- package/dist/modules/email/adapters/resend.adapter.d.ts +0 -1
- package/dist/modules/email/adapters/resend.adapter.js +0 -6
- package/dist/modules/email/adapters/resend.adapter.js.map +0 -1
- package/dist/modules/email/email.module.d.ts +0 -2
- package/dist/modules/email/email.module.js +0 -17
- package/dist/modules/email/email.module.js.map +0 -1
- package/dist/modules/email/email.service.d.ts +0 -1
- package/dist/modules/email/email.service.js +0 -6
- package/dist/modules/email/email.service.js.map +0 -1
- package/dist/modules/email/templates/transactional.template.d.ts +0 -18
- package/dist/modules/email/templates/transactional.template.js +0 -43
- package/dist/modules/email/templates/transactional.template.js.map +0 -1
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.AdminTenantsController = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
-
const core_1 = require("@agentforge/core");
|
|
19
|
-
const current_user_decorator_1 = require("../auth/decorators/current-user.decorator");
|
|
20
|
-
const platform_admin_guard_1 = require("./platform-admin.guard");
|
|
21
|
-
let AdminTenantsController = class AdminTenantsController {
|
|
22
|
-
constructor(tenants, apiKeys) {
|
|
23
|
-
this.tenants = tenants;
|
|
24
|
-
this.apiKeys = apiKeys;
|
|
25
|
-
}
|
|
26
|
-
async createTenant(body, userId) {
|
|
27
|
-
this.ensureB2B();
|
|
28
|
-
if (!body?.name)
|
|
29
|
-
throw new common_1.BadRequestException('name is required');
|
|
30
|
-
return this.tenants.create({
|
|
31
|
-
name: body.name,
|
|
32
|
-
ownerUserId: userId,
|
|
33
|
-
planId: body.planId,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
async listMyTenants(user, q, status, limit, offset) {
|
|
37
|
-
this.ensureB2B();
|
|
38
|
-
const limitNum = limit ? Number(limit) : undefined;
|
|
39
|
-
const offsetNum = offset ? Number(offset) : undefined;
|
|
40
|
-
const isActive = status === 'active' ? true : status === 'inactive' ? false : undefined;
|
|
41
|
-
const opts = { q, isActive, limit: limitNum, offset: offsetNum };
|
|
42
|
-
const result = user.isPlatformAdmin
|
|
43
|
-
? await this.tenants.listAll(opts)
|
|
44
|
-
: await this.tenants.listForOwner(user.userId, opts);
|
|
45
|
-
return {
|
|
46
|
-
items: result.items,
|
|
47
|
-
total: result.total,
|
|
48
|
-
limit: limitNum ?? null,
|
|
49
|
-
offset: offsetNum ?? 0,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
async issueApiKey(tenantId, body, user) {
|
|
53
|
-
this.ensureB2BWithApiKeys();
|
|
54
|
-
const userId = user.userId;
|
|
55
|
-
if (!body?.name)
|
|
56
|
-
throw new common_1.BadRequestException('name is required');
|
|
57
|
-
await this.tenants.assertOwner(tenantId, userId, { allowAnyOwner: user.isPlatformAdmin });
|
|
58
|
-
const minted = await this.apiKeys.issue({
|
|
59
|
-
tenantId,
|
|
60
|
-
name: body.name,
|
|
61
|
-
scopes: body.scopes,
|
|
62
|
-
expiresAt: body.expiresAt ? new Date(body.expiresAt) : undefined,
|
|
63
|
-
});
|
|
64
|
-
return {
|
|
65
|
-
key: minted.key,
|
|
66
|
-
id: minted.entity.id,
|
|
67
|
-
name: minted.entity.name,
|
|
68
|
-
keyPrefix: minted.entity.keyPrefix,
|
|
69
|
-
scopes: minted.entity.scopes,
|
|
70
|
-
expiresAt: minted.entity.expiresAt,
|
|
71
|
-
createdAt: minted.entity.createdAt,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
async listApiKeys(tenantId, user) {
|
|
75
|
-
this.ensureB2BWithApiKeys();
|
|
76
|
-
const userId = user.userId;
|
|
77
|
-
await this.tenants.assertOwner(tenantId, userId, { allowAnyOwner: user.isPlatformAdmin });
|
|
78
|
-
const keys = await this.apiKeys.listForTenant(tenantId);
|
|
79
|
-
return keys.map((k) => ({
|
|
80
|
-
id: k.id,
|
|
81
|
-
name: k.name,
|
|
82
|
-
keyPrefix: k.keyPrefix,
|
|
83
|
-
scopes: k.scopes,
|
|
84
|
-
createdAt: k.createdAt,
|
|
85
|
-
lastUsedAt: k.lastUsedAt,
|
|
86
|
-
expiresAt: k.expiresAt,
|
|
87
|
-
revokedAt: k.revokedAt,
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
async revokeApiKey(tenantId, keyId, user) {
|
|
91
|
-
this.ensureB2BWithApiKeys();
|
|
92
|
-
const userId = user.userId;
|
|
93
|
-
await this.tenants.assertOwner(tenantId, userId, { allowAnyOwner: user.isPlatformAdmin });
|
|
94
|
-
await this.apiKeys.revoke(keyId);
|
|
95
|
-
}
|
|
96
|
-
ensureB2B() {
|
|
97
|
-
if (!this.tenants) {
|
|
98
|
-
throw new common_1.NotImplementedException({
|
|
99
|
-
error: 'b2b_not_configured',
|
|
100
|
-
message: 'B2B mode is not configured. Pass tenant/apiKey/externalUser repositories to createAgentForge.',
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
ensureB2BWithApiKeys() {
|
|
105
|
-
if (!this.tenants || !this.apiKeys) {
|
|
106
|
-
throw new common_1.NotImplementedException({
|
|
107
|
-
error: 'b2b_not_configured',
|
|
108
|
-
message: 'B2B mode is not configured. Pass tenant/apiKey/externalUser repositories to createAgentForge.',
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
exports.AdminTenantsController = AdminTenantsController;
|
|
114
|
-
__decorate([
|
|
115
|
-
(0, common_1.Post)(),
|
|
116
|
-
(0, swagger_1.ApiOperation)({ summary: 'Create a tenant owned by the current user' }),
|
|
117
|
-
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
118
|
-
__param(0, (0, common_1.Body)()),
|
|
119
|
-
__param(1, (0, current_user_decorator_1.CurrentUser)('userId')),
|
|
120
|
-
__metadata("design:type", Function),
|
|
121
|
-
__metadata("design:paramtypes", [Object, String]),
|
|
122
|
-
__metadata("design:returntype", Promise)
|
|
123
|
-
], AdminTenantsController.prototype, "createTenant", null);
|
|
124
|
-
__decorate([
|
|
125
|
-
(0, common_1.Get)(),
|
|
126
|
-
(0, swagger_1.ApiOperation)({
|
|
127
|
-
summary: 'List tenants. Platform admins see all; everyone else sees only the tenants they own.',
|
|
128
|
-
}),
|
|
129
|
-
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
|
130
|
-
__param(1, (0, common_1.Query)('q')),
|
|
131
|
-
__param(2, (0, common_1.Query)('status')),
|
|
132
|
-
__param(3, (0, common_1.Query)('limit')),
|
|
133
|
-
__param(4, (0, common_1.Query)('offset')),
|
|
134
|
-
__metadata("design:type", Function),
|
|
135
|
-
__metadata("design:paramtypes", [Object, String, String, String, String]),
|
|
136
|
-
__metadata("design:returntype", Promise)
|
|
137
|
-
], AdminTenantsController.prototype, "listMyTenants", null);
|
|
138
|
-
__decorate([
|
|
139
|
-
(0, common_1.Post)(':tenantId/api-keys'),
|
|
140
|
-
(0, swagger_1.ApiOperation)({ summary: 'Issue a new API key for a tenant (owner-only)' }),
|
|
141
|
-
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
142
|
-
__param(0, (0, common_1.Param)('tenantId')),
|
|
143
|
-
__param(1, (0, common_1.Body)()),
|
|
144
|
-
__param(2, (0, current_user_decorator_1.CurrentUser)()),
|
|
145
|
-
__metadata("design:type", Function),
|
|
146
|
-
__metadata("design:paramtypes", [String, Object, Object]),
|
|
147
|
-
__metadata("design:returntype", Promise)
|
|
148
|
-
], AdminTenantsController.prototype, "issueApiKey", null);
|
|
149
|
-
__decorate([
|
|
150
|
-
(0, common_1.Get)(':tenantId/api-keys'),
|
|
151
|
-
(0, swagger_1.ApiOperation)({ summary: 'List API keys for a tenant (owner-only)' }),
|
|
152
|
-
__param(0, (0, common_1.Param)('tenantId')),
|
|
153
|
-
__param(1, (0, current_user_decorator_1.CurrentUser)()),
|
|
154
|
-
__metadata("design:type", Function),
|
|
155
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
156
|
-
__metadata("design:returntype", Promise)
|
|
157
|
-
], AdminTenantsController.prototype, "listApiKeys", null);
|
|
158
|
-
__decorate([
|
|
159
|
-
(0, common_1.Delete)(':tenantId/api-keys/:keyId'),
|
|
160
|
-
(0, swagger_1.ApiOperation)({ summary: 'Revoke an API key (owner-only)' }),
|
|
161
|
-
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
162
|
-
__param(0, (0, common_1.Param)('tenantId')),
|
|
163
|
-
__param(1, (0, common_1.Param)('keyId')),
|
|
164
|
-
__param(2, (0, current_user_decorator_1.CurrentUser)()),
|
|
165
|
-
__metadata("design:type", Function),
|
|
166
|
-
__metadata("design:paramtypes", [String, String, Object]),
|
|
167
|
-
__metadata("design:returntype", Promise)
|
|
168
|
-
], AdminTenantsController.prototype, "revokeApiKey", null);
|
|
169
|
-
exports.AdminTenantsController = AdminTenantsController = __decorate([
|
|
170
|
-
(0, swagger_1.ApiTags)('Admin: Tenants'),
|
|
171
|
-
(0, common_1.Controller)('admin/tenants'),
|
|
172
|
-
(0, common_1.UseGuards)(platform_admin_guard_1.RequireUserSessionGuard),
|
|
173
|
-
__param(0, (0, common_1.Optional)()),
|
|
174
|
-
__param(1, (0, common_1.Optional)()),
|
|
175
|
-
__metadata("design:paramtypes", [core_1.TenantService,
|
|
176
|
-
core_1.ApiKeyService])
|
|
177
|
-
], AdminTenantsController);
|
|
178
|
-
//# sourceMappingURL=admin-tenants.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin-tenants.controller.js","sourceRoot":"","sources":["../../../src/modules/admin/admin-tenants.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAcwB;AACxB,6CAAwD;AACxD,2CAAgE;AAChE,sFAAuF;AACvF,iEAAiE;AAc1D,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,YAC+B,OAAuB,EACvB,OAAuB;QADvB,YAAO,GAAP,OAAO,CAAgB;QACvB,YAAO,GAAP,OAAO,CAAgB;IACnD,CAAC;IAOE,AAAN,KAAK,CAAC,YAAY,CACR,IAAwC,EACzB,MAAc;QAErC,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,EAAE,IAAI;YAAE,MAAM,IAAI,4BAAmB,CAAC,kBAAkB,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC,OAAQ,CAAC,MAAM,CAAC;YAC1B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;IAOK,AAAN,KAAK,CAAC,aAAa,CACF,IAAc,EACjB,CAAU,EACL,MAAe,EAChB,KAAc,EACb,MAAe;QAEhC,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACnD,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAGtD,MAAM,QAAQ,GACZ,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,U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: AuthService);
|
|
5
|
-
list(q?: string, role?: string, status?: string, emailVerified?: string, limit?: string, offset?: string): Promise<{
|
|
6
|
-
items: {
|
|
7
|
-
id: string;
|
|
8
|
-
email: string | undefined;
|
|
9
|
-
name: string | undefined;
|
|
10
|
-
role: import("@agentforge/core").UserRole;
|
|
11
|
-
isActive: boolean;
|
|
12
|
-
currentPlanId: string;
|
|
13
|
-
createdAt: Date;
|
|
14
|
-
lastLoginAt: Date | undefined;
|
|
15
|
-
emailVerifiedAt: Date | undefined;
|
|
16
|
-
}[];
|
|
17
|
-
total: number;
|
|
18
|
-
limit: number | null;
|
|
19
|
-
offset: number;
|
|
20
|
-
}>;
|
|
21
|
-
get(userId: string): Promise<{
|
|
22
|
-
id: string;
|
|
23
|
-
email: string | undefined;
|
|
24
|
-
name: string | undefined;
|
|
25
|
-
role: import("@agentforge/core").UserRole;
|
|
26
|
-
isActive: boolean;
|
|
27
|
-
currentPlanId: string;
|
|
28
|
-
creditsBalance: number;
|
|
29
|
-
providerCustomerId: string | undefined;
|
|
30
|
-
createdAt: Date;
|
|
31
|
-
lastLoginAt: Date | undefined;
|
|
32
|
-
emailVerifiedAt: Date | undefined;
|
|
33
|
-
}>;
|
|
34
|
-
setRole(userId: string, body: {
|
|
35
|
-
role?: 'user' | 'platform_admin';
|
|
36
|
-
}): Promise<{
|
|
37
|
-
id: string;
|
|
38
|
-
email: string | undefined;
|
|
39
|
-
role: import("@agentforge/core").UserRole;
|
|
40
|
-
}>;
|
|
41
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.AdminUsersController = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
-
const core_1 = require("@agentforge/core");
|
|
19
|
-
const platform_admin_guard_1 = require("./platform-admin.guard");
|
|
20
|
-
let AdminUsersController = class AdminUsersController {
|
|
21
|
-
constructor(auth) {
|
|
22
|
-
this.auth = auth;
|
|
23
|
-
}
|
|
24
|
-
async list(q, role, status, emailVerified, limit, offset) {
|
|
25
|
-
const roleFilter = role === 'platform_admin' || role === 'user' ? role : undefined;
|
|
26
|
-
const isActive = status === 'active' ? true : status === 'inactive' ? false : undefined;
|
|
27
|
-
const verified = emailVerified === 'true' ? true : emailVerified === 'false' ? false : undefined;
|
|
28
|
-
const limitNum = limit ? Number(limit) : undefined;
|
|
29
|
-
const offsetNum = offset ? Number(offset) : undefined;
|
|
30
|
-
const result = await this.auth.listUsers({
|
|
31
|
-
q,
|
|
32
|
-
role: roleFilter,
|
|
33
|
-
isActive,
|
|
34
|
-
emailVerified: verified,
|
|
35
|
-
limit: limitNum,
|
|
36
|
-
offset: offsetNum,
|
|
37
|
-
});
|
|
38
|
-
return {
|
|
39
|
-
items: result.items.map((u) => ({
|
|
40
|
-
id: u.id,
|
|
41
|
-
email: u.email,
|
|
42
|
-
name: u.name,
|
|
43
|
-
role: u.role,
|
|
44
|
-
isActive: u.isActive,
|
|
45
|
-
currentPlanId: u.currentPlanId,
|
|
46
|
-
createdAt: u.createdAt,
|
|
47
|
-
lastLoginAt: u.lastLoginAt,
|
|
48
|
-
emailVerifiedAt: u.emailVerifiedAt,
|
|
49
|
-
})),
|
|
50
|
-
total: result.total,
|
|
51
|
-
limit: limitNum ?? null,
|
|
52
|
-
offset: offsetNum ?? 0,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
async get(userId) {
|
|
56
|
-
const user = await this.auth.getFullUserById(userId);
|
|
57
|
-
if (!user)
|
|
58
|
-
throw new common_1.NotFoundException(`User "${userId}" not found`);
|
|
59
|
-
return {
|
|
60
|
-
id: user.id,
|
|
61
|
-
email: user.email,
|
|
62
|
-
name: user.name,
|
|
63
|
-
role: user.role,
|
|
64
|
-
isActive: user.isActive,
|
|
65
|
-
currentPlanId: user.currentPlanId,
|
|
66
|
-
creditsBalance: user.creditsBalance,
|
|
67
|
-
providerCustomerId: user.providerCustomerId,
|
|
68
|
-
createdAt: user.createdAt,
|
|
69
|
-
lastLoginAt: user.lastLoginAt,
|
|
70
|
-
emailVerifiedAt: user.emailVerifiedAt,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
async setRole(userId, body) {
|
|
74
|
-
const role = body?.role;
|
|
75
|
-
if (role !== 'user' && role !== 'platform_admin') {
|
|
76
|
-
throw new common_1.BadRequestException('role must be "user" or "platform_admin"');
|
|
77
|
-
}
|
|
78
|
-
const updated = await this.auth.setUserRole(userId, role);
|
|
79
|
-
return { id: updated.id, email: updated.email, role: updated.role };
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
exports.AdminUsersController = AdminUsersController;
|
|
83
|
-
__decorate([
|
|
84
|
-
(0, common_1.Get)(),
|
|
85
|
-
(0, swagger_1.ApiOperation)({ summary: 'List users (paginated, newest first)' }),
|
|
86
|
-
__param(0, (0, common_1.Query)('q')),
|
|
87
|
-
__param(1, (0, common_1.Query)('role')),
|
|
88
|
-
__param(2, (0, common_1.Query)('status')),
|
|
89
|
-
__param(3, (0, common_1.Query)('emailVerified')),
|
|
90
|
-
__param(4, (0, common_1.Query)('limit')),
|
|
91
|
-
__param(5, (0, common_1.Query)('offset')),
|
|
92
|
-
__metadata("design:type", Function),
|
|
93
|
-
__metadata("design:paramtypes", [String, String, String, String, String, String]),
|
|
94
|
-
__metadata("design:returntype", Promise)
|
|
95
|
-
], AdminUsersController.prototype, "list", null);
|
|
96
|
-
__decorate([
|
|
97
|
-
(0, common_1.Get)(':userId'),
|
|
98
|
-
(0, swagger_1.ApiOperation)({ summary: 'Get a single user by id' }),
|
|
99
|
-
__param(0, (0, common_1.Param)('userId')),
|
|
100
|
-
__metadata("design:type", Function),
|
|
101
|
-
__metadata("design:paramtypes", [String]),
|
|
102
|
-
__metadata("design:returntype", Promise)
|
|
103
|
-
], AdminUsersController.prototype, "get", null);
|
|
104
|
-
__decorate([
|
|
105
|
-
(0, common_1.Patch)(':userId/role'),
|
|
106
|
-
(0, swagger_1.ApiOperation)({
|
|
107
|
-
summary: 'Change a user role. Refuses to demote the last platform_admin (409).',
|
|
108
|
-
}),
|
|
109
|
-
__param(0, (0, common_1.Param)('userId')),
|
|
110
|
-
__param(1, (0, common_1.Body)()),
|
|
111
|
-
__metadata("design:type", Function),
|
|
112
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
113
|
-
__metadata("design:returntype", Promise)
|
|
114
|
-
], AdminUsersController.prototype, "setRole", null);
|
|
115
|
-
exports.AdminUsersController = AdminUsersController = __decorate([
|
|
116
|
-
(0, swagger_1.ApiTags)('Admin: Users'),
|
|
117
|
-
(0, common_1.Controller)('admin/users'),
|
|
118
|
-
(0, common_1.UseGuards)(platform_admin_guard_1.PlatformAdminGuard),
|
|
119
|
-
__metadata("design:paramtypes", [core_1.AuthService])
|
|
120
|
-
], AdminUsersController);
|
|
121
|
-
//# sourceMappingURL=admin-users.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":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GAAE,CAAA;;;;mDAQR;+BApFU,oBAAoB;IAHhC,IAAA,iBAAO,EAAC,cAAc,CAAC;IACvB,IAAA,mBAAU,EAAC,aAAa,CAAC;IACzB,IAAA,kBAAS,EAAC,yCAAkB,CAAC;qCAEO,kBAAW;GADnC,oBAAoB,CAqFhC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.AdminModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const admin_tenants_controller_1 = require("./admin-tenants.controller");
|
|
12
|
-
const admin_tenant_agents_controller_1 = require("./admin-tenant-agents.controller");
|
|
13
|
-
const admin_users_controller_1 = require("./admin-users.controller");
|
|
14
|
-
let AdminModule = class AdminModule {
|
|
15
|
-
};
|
|
16
|
-
exports.AdminModule = AdminModule;
|
|
17
|
-
exports.AdminModule = AdminModule = __decorate([
|
|
18
|
-
(0, common_1.Module)({
|
|
19
|
-
controllers: [
|
|
20
|
-
admin_tenants_controller_1.AdminTenantsController,
|
|
21
|
-
admin_tenant_agents_controller_1.AdminTenantAgentsController,
|
|
22
|
-
admin_users_controller_1.AdminUsersController,
|
|
23
|
-
],
|
|
24
|
-
})
|
|
25
|
-
], AdminModule);
|
|
26
|
-
//# sourceMappingURL=admin.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.module.js","sourceRoot":"","sources":["../../../src/modules/admin/admin.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,yEAAoE;AACpE,qFAA+E;AAC/E,qEAAgE;AAoBzD,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAPvB,IAAA,eAAM,EAAC;QACN,WAAW,EAAE;YACX,iDAAsB;YACtB,4DAA2B;YAC3B,6CAAoB;SACrB;KACF,CAAC;GACW,WAAW,CAAG"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
-
export declare class RequireUserSessionGuard implements CanActivate {
|
|
3
|
-
canActivate(context: ExecutionContext): boolean;
|
|
4
|
-
}
|
|
5
|
-
export declare class PlatformAdminGuard implements CanActivate {
|
|
6
|
-
canActivate(context: ExecutionContext): boolean;
|
|
7
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.PlatformAdminGuard = exports.RequireUserSessionGuard = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
function isApiKey(req) {
|
|
12
|
-
return req.user?.isApiKey === true;
|
|
13
|
-
}
|
|
14
|
-
let RequireUserSessionGuard = class RequireUserSessionGuard {
|
|
15
|
-
canActivate(context) {
|
|
16
|
-
const req = context.switchToHttp().getRequest();
|
|
17
|
-
if (isApiKey(req)) {
|
|
18
|
-
throw new common_1.ForbiddenException({
|
|
19
|
-
error: 'admin_required',
|
|
20
|
-
message: 'Use end-user auth (JWT) for admin endpoints.',
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
exports.RequireUserSessionGuard = RequireUserSessionGuard;
|
|
27
|
-
exports.RequireUserSessionGuard = RequireUserSessionGuard = __decorate([
|
|
28
|
-
(0, common_1.Injectable)()
|
|
29
|
-
], RequireUserSessionGuard);
|
|
30
|
-
let PlatformAdminGuard = class PlatformAdminGuard {
|
|
31
|
-
canActivate(context) {
|
|
32
|
-
const req = context.switchToHttp().getRequest();
|
|
33
|
-
if (isApiKey(req)) {
|
|
34
|
-
throw new common_1.ForbiddenException({
|
|
35
|
-
error: 'admin_required',
|
|
36
|
-
message: 'Use end-user auth (JWT) for admin endpoints.',
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
if (!req.user?.isPlatformAdmin) {
|
|
40
|
-
throw new common_1.ForbiddenException({
|
|
41
|
-
error: 'platform_admin_required',
|
|
42
|
-
message: 'This endpoint manages the AgentForge instance — your account does not have platform-admin privileges.',
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
exports.PlatformAdminGuard = PlatformAdminGuard;
|
|
49
|
-
exports.PlatformAdminGuard = PlatformAdminGuard = __decorate([
|
|
50
|
-
(0, common_1.Injectable)()
|
|
51
|
-
], PlatformAdminGuard);
|
|
52
|
-
//# sourceMappingURL=platform-admin.guard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platform-admin.guard.js","sourceRoot":"","sources":["../../../src/modules/admin/platform-admin.guard.ts"],"names":[],"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express';
|
|
2
|
-
import { AuthService } from './auth.service';
|
|
3
|
-
import { RegisterDto } from './dto/register.dto';
|
|
4
|
-
import { LoginDto } from './dto/login.dto';
|
|
5
|
-
import { AuthUser } from './decorators/current-user.decorator';
|
|
6
|
-
import type { AgentForgeConfig } from '../../types';
|
|
7
|
-
export declare class AuthController {
|
|
8
|
-
private readonly config;
|
|
9
|
-
private readonly auth;
|
|
10
|
-
constructor(config: AgentForgeConfig, auth: AuthService);
|
|
11
|
-
register(dto: RegisterDto, req: Request, res: Response): Promise<{
|
|
12
|
-
accessToken: string;
|
|
13
|
-
user: {
|
|
14
|
-
id: string;
|
|
15
|
-
email?: string;
|
|
16
|
-
name?: string;
|
|
17
|
-
};
|
|
18
|
-
}>;
|
|
19
|
-
login(dto: LoginDto, req: Request, res: Response): Promise<{
|
|
20
|
-
accessToken: string;
|
|
21
|
-
user: {
|
|
22
|
-
id: string;
|
|
23
|
-
email?: string;
|
|
24
|
-
name?: string;
|
|
25
|
-
};
|
|
26
|
-
}>;
|
|
27
|
-
refresh(req: Request, res: Response): Promise<{
|
|
28
|
-
accessToken: string;
|
|
29
|
-
user: {
|
|
30
|
-
id: string;
|
|
31
|
-
email?: string;
|
|
32
|
-
name?: string;
|
|
33
|
-
};
|
|
34
|
-
}>;
|
|
35
|
-
logout(req: Request, res: Response): Promise<void>;
|
|
36
|
-
logoutAll(userId: string, res: Response): Promise<void>;
|
|
37
|
-
me(user: AuthUser): AuthUser;
|
|
38
|
-
verifyEmail(body: {
|
|
39
|
-
token: string;
|
|
40
|
-
}): Promise<{
|
|
41
|
-
userId: string;
|
|
42
|
-
}>;
|
|
43
|
-
resendVerification(userId: string): Promise<void>;
|
|
44
|
-
requestPasswordReset(body: {
|
|
45
|
-
email: string;
|
|
46
|
-
}): Promise<{
|
|
47
|
-
ok: boolean;
|
|
48
|
-
}>;
|
|
49
|
-
resetPassword(body: {
|
|
50
|
-
token: string;
|
|
51
|
-
password: string;
|
|
52
|
-
}): Promise<{
|
|
53
|
-
ok: boolean;
|
|
54
|
-
}>;
|
|
55
|
-
private accessCookieName;
|
|
56
|
-
private refreshCookieName;
|
|
57
|
-
private cookieSecure;
|
|
58
|
-
private metaFrom;
|
|
59
|
-
private setSessionCookies;
|
|
60
|
-
private clearSessionCookies;
|
|
61
|
-
private publicResult;
|
|
62
|
-
private parseAccessTtlMs;
|
|
63
|
-
}
|