@kosha-ai/server 0.1.0 → 0.3.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/auth/api-key.guard.d.ts +7 -2
- package/dist/auth/api-key.guard.d.ts.map +1 -1
- package/dist/auth/api-key.guard.js +28 -8
- package/dist/auth/auth.factory.d.ts +15 -1
- package/dist/auth/auth.factory.d.ts.map +1 -1
- package/dist/auth/auth.factory.js +43 -2
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +24 -6
- package/dist/configurations/configurations.controller.d.ts +12 -136
- package/dist/configurations/configurations.controller.d.ts.map +1 -1
- package/dist/configurations/configurations.controller.js +65 -28
- package/dist/configurations/configurations.module.d.ts.map +1 -1
- package/dist/configurations/configurations.module.js +2 -0
- package/dist/configurations/configurations.service.d.ts +32 -200
- package/dist/configurations/configurations.service.d.ts.map +1 -1
- package/dist/configurations/configurations.service.js +98 -170
- package/dist/configurations/dto/create-configuration.dto.d.ts +7 -0
- package/dist/configurations/dto/create-configuration.dto.d.ts.map +1 -0
- package/dist/configurations/dto/create-configuration.dto.js +44 -0
- package/dist/configurations/dto/update-configuration.dto.d.ts +5 -0
- package/dist/configurations/dto/update-configuration.dto.d.ts.map +1 -0
- package/dist/configurations/dto/update-configuration.dto.js +23 -0
- package/dist/connect/connect.controller.d.ts +6 -8
- package/dist/connect/connect.controller.d.ts.map +1 -1
- package/dist/connect/connect.controller.js +46 -15
- package/dist/connect/connect.module.d.ts.map +1 -1
- package/dist/connect/connect.module.js +4 -3
- package/dist/connect/connect.repository.d.ts +78 -0
- package/dist/connect/connect.repository.d.ts.map +1 -0
- package/dist/connect/connect.repository.js +134 -0
- package/dist/connect/connect.service.d.ts +29 -21
- package/dist/connect/connect.service.d.ts.map +1 -1
- package/dist/connect/connect.service.js +157 -168
- package/dist/connect/dto/create-connect-session.dto.d.ts +8 -0
- package/dist/connect/dto/create-connect-session.dto.d.ts.map +1 -0
- package/dist/connect/dto/create-connect-session.dto.js +54 -0
- package/dist/connect/dto/create-test-session.dto.d.ts +11 -0
- package/dist/connect/dto/create-test-session.dto.d.ts.map +1 -0
- package/dist/connect/dto/create-test-session.dto.js +41 -0
- package/dist/connections/connections.controller.d.ts +10 -62
- package/dist/connections/connections.controller.d.ts.map +1 -1
- package/dist/connections/connections.controller.js +41 -17
- package/dist/connections/connections.module.d.ts.map +1 -1
- package/dist/connections/connections.module.js +4 -1
- package/dist/connections/connections.repository.d.ts +31 -0
- package/dist/connections/connections.repository.d.ts.map +1 -0
- package/dist/connections/connections.repository.js +44 -0
- package/dist/connections/connections.service.d.ts +58 -68
- package/dist/connections/connections.service.d.ts.map +1 -1
- package/dist/connections/connections.service.js +137 -55
- package/dist/connections/dto/list-connections.dto.d.ts +7 -0
- package/dist/connections/dto/list-connections.dto.d.ts.map +1 -0
- package/dist/connections/dto/list-connections.dto.js +47 -0
- package/dist/connections/environment-connections.controller.d.ts +27 -0
- package/dist/connections/environment-connections.controller.d.ts.map +1 -0
- package/dist/connections/environment-connections.controller.js +83 -0
- package/dist/connections/environment-connections.module.d.ts +11 -0
- package/dist/connections/environment-connections.module.d.ts.map +1 -0
- package/dist/connections/environment-connections.module.js +21 -0
- package/dist/credentials/credentials.module.d.ts.map +1 -1
- package/dist/credentials/credentials.module.js +2 -4
- package/dist/credentials/credentials.repository.d.ts +11 -0
- package/dist/credentials/credentials.repository.d.ts.map +1 -0
- package/dist/credentials/credentials.repository.js +28 -0
- package/dist/credentials/credentials.service.d.ts +25 -31
- package/dist/credentials/credentials.service.d.ts.map +1 -1
- package/dist/credentials/credentials.service.js +100 -62
- package/dist/crypto/credential-envelope.d.ts +56 -0
- package/dist/crypto/credential-envelope.d.ts.map +1 -0
- package/dist/crypto/credential-envelope.js +70 -0
- package/dist/crypto/crypto.service.d.ts +8 -0
- package/dist/crypto/crypto.service.d.ts.map +1 -1
- package/dist/crypto/crypto.service.js +12 -0
- package/dist/egress/dto/mint-grant.dto.d.ts +7 -0
- package/dist/egress/dto/mint-grant.dto.d.ts.map +1 -0
- package/dist/egress/dto/mint-grant.dto.js +44 -0
- package/dist/egress/egress.controller.d.ts +2 -8
- package/dist/egress/egress.controller.d.ts.map +1 -1
- package/dist/egress/egress.controller.js +27 -6
- package/dist/egress/egress.listener.d.ts.map +1 -1
- package/dist/egress/egress.listener.js +6 -6
- package/dist/egress/egress.module.d.ts.map +1 -1
- package/dist/egress/egress.module.js +10 -2
- package/dist/egress/egress.repository.d.ts +65 -0
- package/dist/egress/egress.repository.d.ts.map +1 -0
- package/dist/egress/egress.repository.js +103 -0
- package/dist/egress/grants.service.d.ts +23 -78
- package/dist/egress/grants.service.d.ts.map +1 -1
- package/dist/egress/grants.service.js +44 -104
- package/dist/environments/dto/create-environment.dto.d.ts +6 -0
- package/dist/environments/dto/create-environment.dto.d.ts.map +1 -0
- package/dist/environments/dto/create-environment.dto.js +34 -0
- package/dist/environments/dto/update-environment.dto.d.ts +5 -0
- package/dist/environments/dto/update-environment.dto.d.ts.map +1 -0
- package/dist/environments/dto/update-environment.dto.js +24 -0
- package/dist/environments/environments.controller.d.ts +53 -0
- package/dist/environments/environments.controller.d.ts.map +1 -0
- package/dist/environments/environments.controller.js +101 -0
- package/dist/environments/environments.module.d.ts +3 -0
- package/dist/environments/environments.module.d.ts.map +1 -0
- package/dist/environments/environments.module.js +15 -0
- package/dist/environments/environments.repository.d.ts +37 -0
- package/dist/environments/environments.repository.d.ts.map +1 -0
- package/dist/environments/environments.repository.js +82 -0
- package/dist/environments/environments.service.d.ts +43 -0
- package/dist/environments/environments.service.d.ts.map +1 -0
- package/dist/environments/environments.service.js +124 -0
- package/dist/generated/prisma/browser.d.ts +11 -39
- package/dist/generated/prisma/browser.d.ts.map +1 -1
- package/dist/generated/prisma/client.d.ts +11 -39
- package/dist/generated/prisma/client.d.ts.map +1 -1
- package/dist/generated/prisma/commonInputTypes.d.ts +50 -146
- package/dist/generated/prisma/commonInputTypes.d.ts.map +1 -1
- package/dist/generated/prisma/enums.d.ts +1 -21
- package/dist/generated/prisma/enums.d.ts.map +1 -1
- package/dist/generated/prisma/enums.js +1 -18
- package/dist/generated/prisma/internal/class.d.ts +16 -60
- package/dist/generated/prisma/internal/class.d.ts.map +1 -1
- package/dist/generated/prisma/internal/class.js +4 -4
- package/dist/generated/prisma/internal/prismaNamespace.d.ts +166 -583
- package/dist/generated/prisma/internal/prismaNamespace.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespace.js +25 -104
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +26 -111
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +25 -104
- package/dist/generated/prisma/models/EgressGrant.d.ts +131 -134
- package/dist/generated/prisma/models/EgressGrant.d.ts.map +1 -1
- package/dist/generated/prisma/models/Environment.d.ts +1386 -0
- package/dist/generated/prisma/models/Environment.d.ts.map +1 -0
- package/dist/generated/prisma/models/Invitation.d.ts +42 -1
- package/dist/generated/prisma/models/Invitation.d.ts.map +1 -1
- package/dist/generated/prisma/models/Organization.d.ts +122 -408
- package/dist/generated/prisma/models/Organization.d.ts.map +1 -1
- package/dist/generated/prisma/models/Session.d.ts +36 -1
- package/dist/generated/prisma/models/Session.d.ts.map +1 -1
- package/dist/generated/prisma/models/Team.d.ts +1498 -0
- package/dist/generated/prisma/models/Team.d.ts.map +1 -0
- package/dist/generated/prisma/models/TeamMember.d.ts +1281 -0
- package/dist/generated/prisma/models/TeamMember.d.ts.map +1 -0
- package/dist/generated/prisma/models/User.d.ts +278 -0
- package/dist/generated/prisma/models/User.d.ts.map +1 -1
- package/dist/generated/prisma/models.d.ts +3 -7
- package/dist/generated/prisma/models.d.ts.map +1 -1
- package/dist/index.d.ts +14 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/integrations/integrations.controller.d.ts +4 -1
- package/dist/integrations/integrations.controller.d.ts.map +1 -1
- package/dist/integrations/integrations.controller.js +1 -0
- package/dist/integrations/integrations.module.js +3 -3
- package/dist/integrations/provider-store.d.ts +104 -0
- package/dist/integrations/provider-store.d.ts.map +1 -0
- package/dist/integrations/provider-store.js +234 -0
- package/dist/kosha.module.d.ts.map +1 -1
- package/dist/kosha.module.js +9 -3
- package/dist/proxy/proxy.controller.d.ts +12 -3
- package/dist/proxy/proxy.controller.d.ts.map +1 -1
- package/dist/proxy/proxy.controller.js +31 -10
- package/dist/proxy/proxy.module.d.ts.map +1 -1
- package/dist/proxy/proxy.module.js +4 -2
- package/dist/proxy/proxy.repository.d.ts +21 -0
- package/dist/proxy/proxy.repository.d.ts.map +1 -0
- package/dist/proxy/proxy.repository.js +37 -0
- package/dist/proxy/proxy.service.d.ts +15 -5
- package/dist/proxy/proxy.service.d.ts.map +1 -1
- package/dist/proxy/proxy.service.js +63 -26
- package/package.json +7 -4
- package/prisma/migrations/{20260908000000_init → 20261008090000_init}/migration.sql +99 -16
- package/prisma/schema.prisma +56 -202
- package/dist/generated/prisma/models/Configuration.d.ts +0 -2018
- package/dist/generated/prisma/models/Configuration.d.ts.map +0 -1
- package/dist/generated/prisma/models/ConnectSession.d.ts +0 -1606
- package/dist/generated/prisma/models/ConnectSession.d.ts.map +0 -1
- package/dist/generated/prisma/models/Connection.d.ts +0 -1949
- package/dist/generated/prisma/models/Connection.d.ts.map +0 -1
- package/dist/generated/prisma/models/ConnectionCredential.d.ts +0 -1293
- package/dist/generated/prisma/models/ConnectionCredential.d.ts.map +0 -1
- package/dist/generated/prisma/models/ConnectionCredential.js +0 -1
- package/dist/generated/prisma/models/EndUser.d.ts +0 -1666
- package/dist/generated/prisma/models/EndUser.d.ts.map +0 -1
- package/dist/generated/prisma/models/EndUser.js +0 -1
- package/dist/generated/prisma/models/OAuthState.d.ts +0 -1404
- package/dist/generated/prisma/models/OAuthState.d.ts.map +0 -1
- package/dist/generated/prisma/models/OAuthState.js +0 -1
- package/dist/generated/prisma/models/Provider.d.ts +0 -1462
- package/dist/generated/prisma/models/Provider.d.ts.map +0 -1
- package/dist/generated/prisma/models/Provider.js +0 -1
- package/dist/integrations/provider-sync.service.d.ts +0 -24
- package/dist/integrations/provider-sync.service.d.ts.map +0 -1
- package/dist/integrations/provider-sync.service.js +0 -74
- package/prisma/migrations/20260908161813_add_connect_domain/migration.sql +0 -173
- package/prisma/migrations/20260916000000_add_configuration_slug/migration.sql +0 -15
- package/prisma/migrations/20260921000000_add_egress_grant/migration.sql +0 -31
- /package/dist/generated/prisma/models/{Configuration.js → Environment.js} +0 -0
- /package/dist/generated/prisma/models/{ConnectSession.js → Team.js} +0 -0
- /package/dist/generated/prisma/models/{Connection.js → TeamMember.js} +0 -0
|
@@ -1,53 +1,77 @@
|
|
|
1
1
|
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
-
import { Controller, Delete, Get, Param, Query, Req, UseGuards, } from '@nestjs/common';
|
|
2
|
+
import { BadRequestException, Controller, Delete, Get, Param, Query, Req, UseGuards, } from '@nestjs/common';
|
|
3
|
+
import { ApiOkResponse, ApiOperation, ApiSecurity, ApiTags, } from '@nestjs/swagger';
|
|
3
4
|
import { AllowAnonymous } from '@thallesp/nestjs-better-auth';
|
|
4
5
|
import { OrgAuthGuard } from '../auth/api-key.guard.js';
|
|
5
6
|
import { ConnectionsService } from './connections.service.js';
|
|
7
|
+
import { ListConnectionsDto } from './dto/list-connections.dto.js';
|
|
8
|
+
/**
|
|
9
|
+
* The environment comes from the API key, so a caller only ever sees the
|
|
10
|
+
* connections of the environment its key reaches.
|
|
11
|
+
*/
|
|
6
12
|
let ConnectionsController = class ConnectionsController {
|
|
7
13
|
connections;
|
|
8
14
|
constructor(connections) {
|
|
9
15
|
this.connections = connections;
|
|
10
16
|
}
|
|
11
|
-
list(request,
|
|
12
|
-
return this.connections.list(request.organizationId,
|
|
13
|
-
endUserExternalId,
|
|
14
|
-
});
|
|
17
|
+
list(request, filters) {
|
|
18
|
+
return this.connections.list(request.organizationId, environmentOf(request), filters);
|
|
15
19
|
}
|
|
16
|
-
get(request, id) {
|
|
17
|
-
return this.connections.get(request.organizationId, id);
|
|
20
|
+
get(request, provider, id) {
|
|
21
|
+
return this.connections.get(request.organizationId, environmentOf(request), provider, id);
|
|
18
22
|
}
|
|
19
|
-
revoke(request, id) {
|
|
20
|
-
return this.connections.revoke(request.organizationId, id);
|
|
23
|
+
revoke(request, provider, id) {
|
|
24
|
+
return this.connections.revoke(request.organizationId, environmentOf(request), provider, id);
|
|
21
25
|
}
|
|
22
26
|
};
|
|
23
27
|
__decorate([
|
|
24
28
|
Get(),
|
|
29
|
+
ApiOperation({
|
|
30
|
+
summary: 'List the connections in this environment',
|
|
31
|
+
description: 'Returns connections from every installed provider, newest first. Tokens and secrets are never included.',
|
|
32
|
+
}),
|
|
33
|
+
ApiOkResponse({ description: 'Connections. Never carries a credential.' }),
|
|
25
34
|
__param(0, Req()),
|
|
26
|
-
__param(1, Query(
|
|
35
|
+
__param(1, Query()),
|
|
27
36
|
__metadata("design:type", Function),
|
|
28
|
-
__metadata("design:paramtypes", [Object,
|
|
37
|
+
__metadata("design:paramtypes", [Object, ListConnectionsDto]),
|
|
29
38
|
__metadata("design:returntype", void 0)
|
|
30
39
|
], ConnectionsController.prototype, "list", null);
|
|
31
40
|
__decorate([
|
|
32
|
-
Get(':id'),
|
|
41
|
+
Get(':provider/:id'),
|
|
42
|
+
ApiOperation({ summary: 'Get one connection' }),
|
|
33
43
|
__param(0, Req()),
|
|
34
|
-
__param(1, Param('
|
|
44
|
+
__param(1, Param('provider')),
|
|
45
|
+
__param(2, Param('id')),
|
|
35
46
|
__metadata("design:type", Function),
|
|
36
|
-
__metadata("design:paramtypes", [Object, String]),
|
|
47
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
37
48
|
__metadata("design:returntype", void 0)
|
|
38
49
|
], ConnectionsController.prototype, "get", null);
|
|
39
50
|
__decorate([
|
|
40
|
-
Delete(':id'),
|
|
51
|
+
Delete(':provider/:id'),
|
|
52
|
+
ApiOperation({
|
|
53
|
+
summary: 'Revoke a connection',
|
|
54
|
+
description: 'Deletes the credential. The row is the credential, so keeping it would only leave ciphertext nobody can use.',
|
|
55
|
+
}),
|
|
41
56
|
__param(0, Req()),
|
|
42
|
-
__param(1, Param('
|
|
57
|
+
__param(1, Param('provider')),
|
|
58
|
+
__param(2, Param('id')),
|
|
43
59
|
__metadata("design:type", Function),
|
|
44
|
-
__metadata("design:paramtypes", [Object, String]),
|
|
60
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
45
61
|
__metadata("design:returntype", void 0)
|
|
46
62
|
], ConnectionsController.prototype, "revoke", null);
|
|
47
63
|
ConnectionsController = __decorate([
|
|
64
|
+
ApiTags('connections'),
|
|
65
|
+
ApiSecurity('x-api-key'),
|
|
48
66
|
Controller('connections'),
|
|
49
67
|
AllowAnonymous(),
|
|
50
68
|
UseGuards(OrgAuthGuard),
|
|
51
69
|
__metadata("design:paramtypes", [ConnectionsService])
|
|
52
70
|
], ConnectionsController);
|
|
53
71
|
export { ConnectionsController };
|
|
72
|
+
function environmentOf(request) {
|
|
73
|
+
if (!request.environmentId) {
|
|
74
|
+
throw new BadRequestException('This route needs an API key, which is what names the environment');
|
|
75
|
+
}
|
|
76
|
+
return request.environmentId;
|
|
77
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.module.d.ts","sourceRoot":"","sources":["../../src/connections/connections.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connections.module.d.ts","sourceRoot":"","sources":["../../src/connections/connections.module.ts"],"names":[],"mappings":"AAMA,qBAMa,iBAAiB;CAAG"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { Module } from '@nestjs/common';
|
|
3
|
+
import { EnvironmentsModule } from '../environments/environments.module.js';
|
|
3
4
|
import { ConnectionsController } from './connections.controller.js';
|
|
5
|
+
import { ConnectionsRepository } from './connections.repository.js';
|
|
4
6
|
import { ConnectionsService } from './connections.service.js';
|
|
5
7
|
let ConnectionsModule = class ConnectionsModule {
|
|
6
8
|
};
|
|
7
9
|
ConnectionsModule = __decorate([
|
|
8
10
|
Module({
|
|
11
|
+
imports: [EnvironmentsModule],
|
|
9
12
|
controllers: [ConnectionsController],
|
|
10
|
-
providers: [ConnectionsService],
|
|
13
|
+
providers: [ConnectionsService, ConnectionsRepository],
|
|
11
14
|
exports: [ConnectionsService],
|
|
12
15
|
})
|
|
13
16
|
], ConnectionsModule);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PrismaService } from '../prisma/prisma.service.js';
|
|
2
|
+
/**
|
|
3
|
+
* The fields of an `account` row that a connection listing needs. Tokens and
|
|
4
|
+
* passwords are never read.
|
|
5
|
+
*
|
|
6
|
+
* `accountId` is the person's id at the provider, `scope` is what they
|
|
7
|
+
* granted, and the two dates say when the tokens expire.
|
|
8
|
+
*/
|
|
9
|
+
export interface ConnectionAccount {
|
|
10
|
+
id: string;
|
|
11
|
+
accountId: string;
|
|
12
|
+
scope: string | null;
|
|
13
|
+
accessTokenExpiresAt: Date | null;
|
|
14
|
+
refreshTokenExpiresAt: Date | null;
|
|
15
|
+
user: {
|
|
16
|
+
email: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reads `account` and `user` rows for connections, and deletes `account` rows
|
|
21
|
+
* on revoke. Deleting an account also deletes its provider connection row, by
|
|
22
|
+
* cascade.
|
|
23
|
+
*/
|
|
24
|
+
export declare class ConnectionsRepository {
|
|
25
|
+
private readonly prisma;
|
|
26
|
+
constructor(prisma: PrismaService);
|
|
27
|
+
findAccounts(ids: string[]): Promise<ConnectionAccount[]>;
|
|
28
|
+
findUserIdByEmail(email: string): Promise<string | null>;
|
|
29
|
+
deleteAccount(id: string): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=connections.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.repository.d.ts","sourceRoot":"","sources":["../../src/connections/connections.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,oBAAoB,EAAE,IAAI,GAAG,IAAI,CAAC;IAClC,qBAAqB,EAAE,IAAI,GAAG,IAAI,CAAC;IACnC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACzB;AAED;;;;GAIG;AACH,qBACa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAgBnD,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAQxD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/C"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { PrismaService } from '../prisma/prisma.service.js';
|
|
4
|
+
/**
|
|
5
|
+
* Reads `account` and `user` rows for connections, and deletes `account` rows
|
|
6
|
+
* on revoke. Deleting an account also deletes its provider connection row, by
|
|
7
|
+
* cascade.
|
|
8
|
+
*/
|
|
9
|
+
let ConnectionsRepository = class ConnectionsRepository {
|
|
10
|
+
prisma;
|
|
11
|
+
constructor(prisma) {
|
|
12
|
+
this.prisma = prisma;
|
|
13
|
+
}
|
|
14
|
+
findAccounts(ids) {
|
|
15
|
+
if (ids.length === 0)
|
|
16
|
+
return Promise.resolve([]);
|
|
17
|
+
return this.prisma.account.findMany({
|
|
18
|
+
where: { id: { in: ids } },
|
|
19
|
+
select: {
|
|
20
|
+
id: true,
|
|
21
|
+
accountId: true,
|
|
22
|
+
scope: true,
|
|
23
|
+
accessTokenExpiresAt: true,
|
|
24
|
+
refreshTokenExpiresAt: true,
|
|
25
|
+
user: { select: { email: true } },
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async findUserIdByEmail(email) {
|
|
30
|
+
const user = await this.prisma.user.findUnique({
|
|
31
|
+
where: { email },
|
|
32
|
+
select: { id: true },
|
|
33
|
+
});
|
|
34
|
+
return user?.id ?? null;
|
|
35
|
+
}
|
|
36
|
+
async deleteAccount(id) {
|
|
37
|
+
await this.prisma.account.deleteMany({ where: { id } });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
ConnectionsRepository = __decorate([
|
|
41
|
+
Injectable(),
|
|
42
|
+
__metadata("design:paramtypes", [PrismaService])
|
|
43
|
+
], ConnectionsRepository);
|
|
44
|
+
export { ConnectionsRepository };
|
|
@@ -1,76 +1,66 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnvironmentsService } from '../environments/environments.service.js';
|
|
2
|
+
import { IntegrationRegistry } from '../integrations/integration.registry.js';
|
|
3
|
+
import { ProviderStore } from '../integrations/provider-store.js';
|
|
4
|
+
import { ConnectionsRepository } from './connections.repository.js';
|
|
5
|
+
export interface ListConnectionsFilters {
|
|
6
|
+
provider?: string;
|
|
7
|
+
configurationId?: string;
|
|
8
|
+
configurationSlug?: string;
|
|
9
|
+
externalUserId?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A connection as a client sees it. Never carries a credential.
|
|
13
|
+
*
|
|
14
|
+
* `id` is the `account` row, which the provider's connection row is keyed on.
|
|
15
|
+
* `accountId` is the person's id at the provider. `scopes` is what the person
|
|
16
|
+
* granted, and is empty when the provider reported nothing.
|
|
17
|
+
*/
|
|
18
|
+
export interface DescribedConnection {
|
|
19
|
+
id: string;
|
|
20
|
+
provider: string;
|
|
21
|
+
configurationId: string;
|
|
22
|
+
configurationSlug: string;
|
|
23
|
+
externalUserId: string;
|
|
24
|
+
accountId: string;
|
|
25
|
+
scopes: string[];
|
|
26
|
+
metadata: unknown;
|
|
27
|
+
accessTokenExpiresAt: Date | null;
|
|
28
|
+
refreshTokenExpiresAt: Date | null;
|
|
29
|
+
createdAt: Date;
|
|
30
|
+
updatedAt: Date;
|
|
31
|
+
}
|
|
2
32
|
export declare class ConnectionsService {
|
|
3
|
-
private readonly
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
provider: {
|
|
12
|
-
name: string;
|
|
13
|
-
key: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
endUser: {
|
|
17
|
-
name: string | null;
|
|
18
|
-
email: string | null;
|
|
19
|
-
externalId: string;
|
|
20
|
-
};
|
|
21
|
-
} & {
|
|
33
|
+
private readonly connections;
|
|
34
|
+
private readonly store;
|
|
35
|
+
private readonly registry;
|
|
36
|
+
private readonly environments;
|
|
37
|
+
constructor(connections: ConnectionsRepository, store: ProviderStore, registry: IntegrationRegistry, environments: EnvironmentsService);
|
|
38
|
+
list(organizationId: string, environmentId: string, filters?: ListConnectionsFilters): Promise<DescribedConnection[]>;
|
|
39
|
+
get(organizationId: string, environmentId: string, provider: string, id: string): Promise<DescribedConnection>;
|
|
40
|
+
revoke(organizationId: string, environmentId: string, provider: string, id: string): Promise<{
|
|
22
41
|
id: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
endUserId: string;
|
|
30
|
-
configurationId: string;
|
|
31
|
-
label: string | null;
|
|
32
|
-
externalAccountId: string | null;
|
|
33
|
-
lastSyncedAt: Date | null;
|
|
34
|
-
lastUsedAt: Date | null;
|
|
35
|
-
errorMessage: string | null;
|
|
36
|
-
})[]>;
|
|
37
|
-
get(organizationId: string, id: string): Promise<{
|
|
38
|
-
configuration: {
|
|
39
|
-
name: string;
|
|
40
|
-
id: string;
|
|
41
|
-
provider: {
|
|
42
|
-
name: string;
|
|
43
|
-
key: string;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
endUser: {
|
|
47
|
-
name: string | null;
|
|
48
|
-
email: string | null;
|
|
49
|
-
externalId: string;
|
|
50
|
-
};
|
|
51
|
-
} & {
|
|
42
|
+
provider: string;
|
|
43
|
+
revoked: true;
|
|
44
|
+
}>;
|
|
45
|
+
listForMember(organizationId: string, userId: string, environmentId: string, filters?: ListConnectionsFilters): Promise<DescribedConnection[]>;
|
|
46
|
+
getForMember(organizationId: string, userId: string, environmentId: string, provider: string, id: string): Promise<DescribedConnection>;
|
|
47
|
+
revokeForMember(organizationId: string, userId: string, environmentId: string, provider: string, id: string): Promise<{
|
|
52
48
|
id: string;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
status: import("../generated/prisma/enums.js").ConnectionStatus;
|
|
56
|
-
metadata: import("@prisma/client/runtime/client").JsonValue | null;
|
|
57
|
-
scopes: string[];
|
|
58
|
-
organizationId: string;
|
|
59
|
-
endUserId: string;
|
|
60
|
-
configurationId: string;
|
|
61
|
-
label: string | null;
|
|
62
|
-
externalAccountId: string | null;
|
|
63
|
-
lastSyncedAt: Date | null;
|
|
64
|
-
lastUsedAt: Date | null;
|
|
65
|
-
errorMessage: string | null;
|
|
49
|
+
provider: string;
|
|
50
|
+
revoked: true;
|
|
66
51
|
}>;
|
|
67
52
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
53
|
+
* Every connection in an environment, across every installed provider.
|
|
54
|
+
*
|
|
55
|
+
* Kosha owns no table that lists them, so this asks each provider in turn
|
|
56
|
+
* and merges newest first. A provider filter asks only that one.
|
|
70
57
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
58
|
+
private listIn;
|
|
59
|
+
private getIn;
|
|
60
|
+
/**
|
|
61
|
+
* Deletes the credential. The row is the credential, so there is no history
|
|
62
|
+
* to preserve by keeping it — only ciphertext nobody can use.
|
|
63
|
+
*/
|
|
64
|
+
private revokeIn;
|
|
75
65
|
}
|
|
76
66
|
//# sourceMappingURL=connections.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.service.d.ts","sourceRoot":"","sources":["../../src/connections/connections.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connections.service.d.ts","sourceRoot":"","sources":["../../src/connections/connections.service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EACL,aAAa,EAGd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,qBAAqB,EAEtB,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,oBAAoB,EAAE,IAAI,GAAG,IAAI,CAAC;IAClC,qBAAqB,EAAE,IAAI,GAAG,IAAI,CAAC;IACnC,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,qBACa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAHZ,WAAW,EAAE,qBAAqB,EAClC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,mBAAmB,EAC7B,YAAY,EAAE,mBAAmB;IAgB9C,IAAI,CACR,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAQ3B,GAAG,CACP,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,mBAAmB,CAAC;IAQzB,MAAM,CACV,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM;;;;;IASN,aAAa,CACjB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAS3B,YAAY,CAChB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,mBAAmB,CAAC;IASzB,eAAe,CACnB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM;;;;;IAUZ;;;;;OAKG;YACW,MAAM;YAwEN,KAAK;IAmCnB;;;OAGG;YACW,QAAQ;CASvB"}
|
|
@@ -1,71 +1,153 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
3
|
-
import {
|
|
3
|
+
import { derivedEmail, externalUserIdOf, } from '../connect/connect.repository.js';
|
|
4
|
+
import { EnvironmentsService } from '../environments/environments.service.js';
|
|
5
|
+
import { IntegrationRegistry } from '../integrations/integration.registry.js';
|
|
6
|
+
import { ProviderStore, } from '../integrations/provider-store.js';
|
|
7
|
+
import { ConnectionsRepository, } from './connections.repository.js';
|
|
4
8
|
let ConnectionsService = class ConnectionsService {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
connections;
|
|
10
|
+
store;
|
|
11
|
+
registry;
|
|
12
|
+
environments;
|
|
13
|
+
constructor(connections, store, registry, environments) {
|
|
14
|
+
this.connections = connections;
|
|
15
|
+
this.store = store;
|
|
16
|
+
this.registry = registry;
|
|
17
|
+
this.environments = environments;
|
|
8
18
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
/*
|
|
20
|
+
* Two audiences, two authorization rules, one set of reads.
|
|
21
|
+
*
|
|
22
|
+
* A consuming app's backend sends an API key, and a key names exactly one
|
|
23
|
+
* environment — it is not a person and has no teams, so there is nothing to
|
|
24
|
+
* check beyond the organization. A signed-in operator names the environment
|
|
25
|
+
* in the route instead, and their teams decide whether they may reach it.
|
|
26
|
+
*
|
|
27
|
+
* Separate methods rather than one with an optional userId, because which
|
|
28
|
+
* check runs is the whole security of it and must not depend on whether an
|
|
29
|
+
* argument happened to be passed.
|
|
30
|
+
*/
|
|
31
|
+
async list(organizationId, environmentId, filters = {}) {
|
|
32
|
+
const environment = await this.environments.get(organizationId, environmentId);
|
|
33
|
+
return this.listIn(environment, filters);
|
|
34
|
+
}
|
|
35
|
+
async get(organizationId, environmentId, provider, id) {
|
|
36
|
+
const environment = await this.environments.get(organizationId, environmentId);
|
|
37
|
+
return this.getIn(environment, provider, id);
|
|
38
|
+
}
|
|
39
|
+
async revoke(organizationId, environmentId, provider, id) {
|
|
40
|
+
const environment = await this.environments.get(organizationId, environmentId);
|
|
41
|
+
return this.revokeIn(environment, provider, id);
|
|
42
|
+
}
|
|
43
|
+
async listForMember(organizationId, userId, environmentId, filters = {}) {
|
|
44
|
+
const environment = await this.environments.getForMember(organizationId, userId, environmentId);
|
|
45
|
+
return this.listIn(environment, filters);
|
|
29
46
|
}
|
|
30
|
-
async
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
async getForMember(organizationId, userId, environmentId, provider, id) {
|
|
48
|
+
const environment = await this.environments.getForMember(organizationId, userId, environmentId);
|
|
49
|
+
return this.getIn(environment, provider, id);
|
|
50
|
+
}
|
|
51
|
+
async revokeForMember(organizationId, userId, environmentId, provider, id) {
|
|
52
|
+
const environment = await this.environments.getForMember(organizationId, userId, environmentId);
|
|
53
|
+
return this.revokeIn(environment, provider, id);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Every connection in an environment, across every installed provider.
|
|
57
|
+
*
|
|
58
|
+
* Kosha owns no table that lists them, so this asks each provider in turn
|
|
59
|
+
* and merges newest first. A provider filter asks only that one.
|
|
60
|
+
*/
|
|
61
|
+
async listIn(environment, filters) {
|
|
62
|
+
let userId;
|
|
63
|
+
if (filters.externalUserId) {
|
|
64
|
+
const found = await this.connections.findUserIdByEmail(derivedEmail(environment.slug, filters.externalUserId));
|
|
65
|
+
if (!found)
|
|
66
|
+
return [];
|
|
67
|
+
userId = found;
|
|
68
|
+
}
|
|
69
|
+
const integrations = filters.provider
|
|
70
|
+
? [this.registry.get(filters.provider)]
|
|
71
|
+
: this.registry.list();
|
|
72
|
+
const perProvider = await Promise.all(integrations.map(async (integration) => {
|
|
73
|
+
const configurations = await this.store.listConfigurations(integration, environment.id);
|
|
74
|
+
// A slug that names nothing is an empty listing, not a 404: the caller
|
|
75
|
+
// asked which connections exist for it, and the answer is none.
|
|
76
|
+
let configurationId = filters.configurationId;
|
|
77
|
+
if (!configurationId && filters.configurationSlug) {
|
|
78
|
+
configurationId = configurations.find((configuration) => configuration.slug === filters.configurationSlug)?.id;
|
|
79
|
+
if (!configurationId)
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
const rows = await this.store.listConnections(integration, environment.id, { configurationId, userId });
|
|
83
|
+
return rows.map((connection) => ({
|
|
84
|
+
integration,
|
|
85
|
+
connection,
|
|
86
|
+
configuration: configurations.find((candidate) => candidate.id === connection.configurationId),
|
|
87
|
+
}));
|
|
88
|
+
}));
|
|
89
|
+
const found = perProvider.flat();
|
|
90
|
+
const accounts = await this.connections.findAccounts(found.map(({ connection }) => connection.accountId));
|
|
91
|
+
return found
|
|
92
|
+
.flatMap(({ integration, connection, configuration }) => {
|
|
93
|
+
const account = accounts.find((row) => row.id === connection.accountId);
|
|
94
|
+
return account && configuration
|
|
95
|
+
? [
|
|
96
|
+
describe(environment, integration, connection, configuration, account),
|
|
97
|
+
]
|
|
98
|
+
: [];
|
|
99
|
+
})
|
|
100
|
+
.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
101
|
+
}
|
|
102
|
+
async getIn(environment, provider, id) {
|
|
103
|
+
const integration = this.registry.get(provider);
|
|
104
|
+
const connection = await this.store.findConnectionByAccount(integration, environment.id, id);
|
|
105
|
+
if (!connection)
|
|
106
|
+
throw new NotFoundException('Connection not found');
|
|
107
|
+
const [configuration, [account]] = await Promise.all([
|
|
108
|
+
this.store.findConfigurationById(integration, environment.id, connection.configurationId),
|
|
109
|
+
this.connections.findAccounts([id]),
|
|
110
|
+
]);
|
|
111
|
+
if (!configuration || !account) {
|
|
45
112
|
throw new NotFoundException('Connection not found');
|
|
46
113
|
}
|
|
47
|
-
return connection;
|
|
114
|
+
return describe(environment, integration, connection, configuration, account);
|
|
48
115
|
}
|
|
49
116
|
/**
|
|
50
|
-
* Deletes the
|
|
51
|
-
*
|
|
117
|
+
* Deletes the credential. The row is the credential, so there is no history
|
|
118
|
+
* to preserve by keeping it — only ciphertext nobody can use.
|
|
52
119
|
*/
|
|
53
|
-
async
|
|
54
|
-
await this.
|
|
55
|
-
await this.
|
|
56
|
-
|
|
57
|
-
where: { connectionId: id },
|
|
58
|
-
}),
|
|
59
|
-
this.prisma.connection.update({
|
|
60
|
-
where: { id },
|
|
61
|
-
data: { status: 'REVOKED', errorMessage: null },
|
|
62
|
-
}),
|
|
63
|
-
]);
|
|
64
|
-
return { id, status: 'REVOKED' };
|
|
120
|
+
async revokeIn(environment, provider, id) {
|
|
121
|
+
await this.getIn(environment, provider, id);
|
|
122
|
+
await this.connections.deleteAccount(id);
|
|
123
|
+
return { id, provider, revoked: true };
|
|
65
124
|
}
|
|
66
125
|
};
|
|
67
126
|
ConnectionsService = __decorate([
|
|
68
127
|
Injectable(),
|
|
69
|
-
__metadata("design:paramtypes", [
|
|
128
|
+
__metadata("design:paramtypes", [ConnectionsRepository,
|
|
129
|
+
ProviderStore,
|
|
130
|
+
IntegrationRegistry,
|
|
131
|
+
EnvironmentsService])
|
|
70
132
|
], ConnectionsService);
|
|
71
133
|
export { ConnectionsService };
|
|
134
|
+
function describe(environment, integration, connection, configuration, account) {
|
|
135
|
+
return {
|
|
136
|
+
id: connection.accountId,
|
|
137
|
+
provider: integration.key,
|
|
138
|
+
configurationId: configuration.id,
|
|
139
|
+
configurationSlug: configuration.slug,
|
|
140
|
+
externalUserId: externalUserIdOf(environment.slug, account.user.email),
|
|
141
|
+
accountId: account.accountId,
|
|
142
|
+
scopes: scopesOf(account.scope),
|
|
143
|
+
metadata: connection.metadata,
|
|
144
|
+
accessTokenExpiresAt: account.accessTokenExpiresAt,
|
|
145
|
+
refreshTokenExpiresAt: account.refreshTokenExpiresAt,
|
|
146
|
+
createdAt: connection.createdAt,
|
|
147
|
+
updatedAt: connection.updatedAt,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Providers separate granted scopes with commas or spaces. */
|
|
151
|
+
function scopesOf(scope) {
|
|
152
|
+
return scope ? scope.split(/[\s,]+/).filter(Boolean) : [];
|
|
153
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-connections.dto.d.ts","sourceRoot":"","sources":["../../../src/connections/dto/list-connections.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,kBAAkB;IAS7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAOlB,eAAe,CAAC,EAAE,MAAM,CAAC;IAUzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAU3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
3
|
+
import { IsOptional, IsString, MaxLength } from 'class-validator';
|
|
4
|
+
export class ListConnectionsDto {
|
|
5
|
+
provider;
|
|
6
|
+
configurationId;
|
|
7
|
+
configurationSlug;
|
|
8
|
+
externalUserId;
|
|
9
|
+
}
|
|
10
|
+
__decorate([
|
|
11
|
+
ApiPropertyOptional({
|
|
12
|
+
example: 'github',
|
|
13
|
+
description: 'Only connections to the given provider. Reads that one provider rather than every installed one.',
|
|
14
|
+
}),
|
|
15
|
+
IsOptional(),
|
|
16
|
+
IsString(),
|
|
17
|
+
MaxLength(255),
|
|
18
|
+
__metadata("design:type", String)
|
|
19
|
+
], ListConnectionsDto.prototype, "provider", void 0);
|
|
20
|
+
__decorate([
|
|
21
|
+
ApiPropertyOptional({
|
|
22
|
+
description: 'Only connections to this configuration.',
|
|
23
|
+
}),
|
|
24
|
+
IsOptional(),
|
|
25
|
+
IsString(),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], ListConnectionsDto.prototype, "configurationId", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
ApiPropertyOptional({
|
|
30
|
+
example: 'github',
|
|
31
|
+
description: 'The same thing by slug, which is what a consuming app already has — it names the slug when it connects and again on every proxy call. Ignored when configurationId is given.',
|
|
32
|
+
}),
|
|
33
|
+
IsOptional(),
|
|
34
|
+
IsString(),
|
|
35
|
+
MaxLength(255),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], ListConnectionsDto.prototype, "configurationSlug", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
ApiPropertyOptional({
|
|
40
|
+
example: 'user_9',
|
|
41
|
+
description: 'Only connections belonging to this person, by the id the consuming app sent. Without it a caller reads every connection in the environment to find one.',
|
|
42
|
+
}),
|
|
43
|
+
IsOptional(),
|
|
44
|
+
IsString(),
|
|
45
|
+
MaxLength(255),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], ListConnectionsDto.prototype, "externalUserId", void 0);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type UserSession } from '@thallesp/nestjs-better-auth';
|
|
2
|
+
import { ConnectionsService } from './connections.service.js';
|
|
3
|
+
import { ListConnectionsDto } from './dto/list-connections.dto.js';
|
|
4
|
+
/**
|
|
5
|
+
* The admin's view of connections, nested under the environment they belong
|
|
6
|
+
* to — the same shape as `ConfigurationsController`.
|
|
7
|
+
*
|
|
8
|
+
* Separate from `ConnectionsController` because the two have different
|
|
9
|
+
* audiences and different authorization rules. That one serves a consuming
|
|
10
|
+
* app's backend over `x-api-key`, where the key names the environment. This
|
|
11
|
+
* serves a signed-in operator, whose teams decide which environments they may
|
|
12
|
+
* reach. Keeping them apart means the rule is chosen by the route rather than
|
|
13
|
+
* by a branch inside a handler, so a later route cannot quietly pick up the
|
|
14
|
+
* wrong one.
|
|
15
|
+
*/
|
|
16
|
+
export declare class EnvironmentConnectionsController {
|
|
17
|
+
private readonly connections;
|
|
18
|
+
constructor(connections: ConnectionsService);
|
|
19
|
+
list(session: UserSession, environmentId: string, filters: ListConnectionsDto): Promise<import("./connections.service.js").DescribedConnection[]>;
|
|
20
|
+
get(session: UserSession, environmentId: string, provider: string, id: string): Promise<import("./connections.service.js").DescribedConnection>;
|
|
21
|
+
revoke(session: UserSession, environmentId: string, provider: string, id: string): Promise<{
|
|
22
|
+
id: string;
|
|
23
|
+
provider: string;
|
|
24
|
+
revoked: true;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=environment-connections.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-connections.controller.d.ts","sourceRoot":"","sources":["../../src/connections/environment-connections.controller.ts"],"names":[],"mappings":"AAOA,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;;;;;;;;;GAWG;AACH,qBAEa,gCAAgC;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,kBAAkB;IAS5D,IAAI,CACS,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EACpC,OAAO,EAAE,kBAAkB;IAetC,GAAG,CACU,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EAC1B,QAAQ,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM;IAkBzB,MAAM,CACO,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EAC1B,QAAQ,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM;;;;;CAU1B"}
|