@kosha-ai/server 0.2.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/auth.factory.d.ts.map +1 -1
- package/dist/auth/auth.factory.js +0 -5
- package/dist/configurations/configurations.controller.d.ts +6 -5
- package/dist/configurations/configurations.controller.d.ts.map +1 -1
- package/dist/configurations/configurations.controller.js +22 -18
- package/dist/configurations/configurations.module.d.ts.map +1 -1
- package/dist/configurations/configurations.module.js +1 -2
- package/dist/configurations/configurations.service.d.ts +24 -36
- package/dist/configurations/configurations.service.d.ts.map +1 -1
- package/dist/configurations/configurations.service.js +71 -151
- package/dist/configurations/dto/create-configuration.dto.d.ts +1 -2
- package/dist/configurations/dto/create-configuration.dto.d.ts.map +1 -1
- package/dist/configurations/dto/create-configuration.dto.js +2 -12
- package/dist/configurations/dto/update-configuration.dto.d.ts +0 -2
- package/dist/configurations/dto/update-configuration.dto.d.ts.map +1 -1
- package/dist/configurations/dto/update-configuration.dto.js +1 -17
- package/dist/connect/connect.controller.d.ts +1 -1
- package/dist/connect/connect.controller.d.ts.map +1 -1
- package/dist/connect/connect.controller.js +7 -6
- package/dist/connect/connect.module.d.ts.map +1 -1
- package/dist/connect/connect.module.js +1 -2
- package/dist/connect/connect.repository.d.ts +23 -23
- package/dist/connect/connect.repository.d.ts.map +1 -1
- package/dist/connect/connect.repository.js +37 -49
- package/dist/connect/connect.service.d.ts +7 -8
- package/dist/connect/connect.service.d.ts.map +1 -1
- package/dist/connect/connect.service.js +54 -51
- package/dist/connect/dto/create-connect-session.dto.d.ts +1 -1
- package/dist/connect/dto/create-connect-session.dto.d.ts.map +1 -1
- package/dist/connect/dto/create-connect-session.dto.js +7 -8
- package/dist/connect/dto/create-test-session.dto.d.ts +1 -0
- package/dist/connect/dto/create-test-session.dto.d.ts.map +1 -1
- package/dist/connect/dto/create-test-session.dto.js +10 -3
- package/dist/connections/connections.controller.d.ts +4 -3
- package/dist/connections/connections.controller.d.ts.map +1 -1
- package/dist/connections/connections.controller.js +13 -11
- package/dist/connections/connections.repository.d.ts +24 -17
- package/dist/connections/connections.repository.d.ts.map +1 -1
- package/dist/connections/connections.repository.js +21 -43
- package/dist/connections/connections.service.d.ts +48 -13
- package/dist/connections/connections.service.d.ts.map +1 -1
- package/dist/connections/connections.service.js +111 -32
- package/dist/connections/dto/list-connections.dto.d.ts +3 -1
- package/dist/connections/dto/list-connections.dto.d.ts.map +1 -1
- package/dist/connections/dto/list-connections.dto.js +26 -4
- package/dist/connections/environment-connections.controller.d.ts +4 -3
- package/dist/connections/environment-connections.controller.d.ts.map +1 -1
- package/dist/connections/environment-connections.controller.js +14 -12
- package/dist/credentials/credentials.module.d.ts.map +1 -1
- package/dist/credentials/credentials.module.js +0 -2
- package/dist/credentials/credentials.repository.d.ts +5 -2
- package/dist/credentials/credentials.repository.d.ts.map +1 -1
- package/dist/credentials/credentials.repository.js +10 -3
- package/dist/credentials/credentials.service.d.ts +8 -4
- package/dist/credentials/credentials.service.d.ts.map +1 -1
- package/dist/credentials/credentials.service.js +27 -16
- package/dist/egress/egress.listener.d.ts +1 -3
- package/dist/egress/egress.listener.d.ts.map +1 -1
- package/dist/egress/egress.listener.js +3 -7
- package/dist/egress/egress.repository.d.ts +13 -6
- package/dist/egress/egress.repository.d.ts.map +1 -1
- package/dist/egress/egress.repository.js +31 -44
- package/dist/generated/prisma/browser.d.ts +0 -5
- package/dist/generated/prisma/browser.d.ts.map +1 -1
- package/dist/generated/prisma/client.d.ts +0 -5
- package/dist/generated/prisma/client.d.ts.map +1 -1
- package/dist/generated/prisma/commonInputTypes.d.ts +0 -55
- package/dist/generated/prisma/commonInputTypes.d.ts.map +1 -1
- package/dist/generated/prisma/internal/class.d.ts +0 -11
- 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 +1 -114
- package/dist/generated/prisma/internal/prismaNamespace.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespace.js +2 -29
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +0 -30
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +2 -29
- package/dist/generated/prisma/models/Account.d.ts +26 -344
- package/dist/generated/prisma/models/Account.d.ts.map +1 -1
- package/dist/generated/prisma/models/Environment.d.ts +0 -258
- package/dist/generated/prisma/models/Environment.d.ts.map +1 -1
- package/dist/generated/prisma/models/User.d.ts +2 -60
- package/dist/generated/prisma/models/User.d.ts.map +1 -1
- package/dist/generated/prisma/models.d.ts +0 -1
- package/dist/generated/prisma/models.d.ts.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/integrations/integrations.controller.d.ts +2 -0
- package/dist/integrations/integrations.controller.d.ts.map +1 -1
- package/dist/integrations/integrations.controller.js +1 -0
- package/dist/integrations/integrations.module.d.ts.map +1 -1
- package/dist/integrations/integrations.module.js +3 -1
- 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/proxy/proxy.controller.d.ts +9 -5
- package/dist/proxy/proxy.controller.d.ts.map +1 -1
- package/dist/proxy/proxy.controller.js +18 -13
- package/dist/proxy/proxy.module.d.ts.map +1 -1
- package/dist/proxy/proxy.module.js +1 -2
- package/dist/proxy/proxy.repository.d.ts +11 -14
- package/dist/proxy/proxy.repository.d.ts.map +1 -1
- package/dist/proxy/proxy.repository.js +17 -27
- package/dist/proxy/proxy.service.d.ts +6 -8
- package/dist/proxy/proxy.service.d.ts.map +1 -1
- package/dist/proxy/proxy.service.js +34 -28
- package/package.json +4 -4
- package/prisma/migrations/{20260929101936_init → 20261008090000_init}/migration.sql +5 -58
- package/prisma/schema.prisma +2 -43
- package/dist/configurations/configurations.repository.d.ts +0 -43
- package/dist/configurations/configurations.repository.d.ts.map +0 -1
- package/dist/configurations/configurations.repository.js +0 -76
- package/dist/generated/prisma/models/Configuration.d.ts +0 -1385
- package/dist/generated/prisma/models/Configuration.d.ts.map +0 -1
- package/dist/generated/prisma/models/Configuration.js +0 -1
- package/prisma/migrations/20260930102529_connection_config/migration.sql +0 -2
|
@@ -16,10 +16,11 @@ import { ListConnectionsDto } from './dto/list-connections.dto.js';
|
|
|
16
16
|
export declare class EnvironmentConnectionsController {
|
|
17
17
|
private readonly connections;
|
|
18
18
|
constructor(connections: ConnectionsService);
|
|
19
|
-
list(session: UserSession, environmentId: string, filters: ListConnectionsDto): Promise<import("./connections.
|
|
20
|
-
get(session: UserSession, environmentId: string, id: string): Promise<import("./connections.
|
|
21
|
-
revoke(session: UserSession, environmentId: string, id: string): Promise<{
|
|
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
22
|
id: string;
|
|
23
|
+
provider: string;
|
|
23
24
|
revoked: true;
|
|
24
25
|
}>;
|
|
25
26
|
}
|
|
@@ -1 +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,
|
|
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"}
|
|
@@ -25,18 +25,18 @@ let EnvironmentConnectionsController = class EnvironmentConnectionsController {
|
|
|
25
25
|
list(session, environmentId, filters) {
|
|
26
26
|
return this.connections.listForMember(getActiveOrganizationId(session), session.user.id, environmentId, filters);
|
|
27
27
|
}
|
|
28
|
-
get(session, environmentId, id) {
|
|
29
|
-
return this.connections.getForMember(getActiveOrganizationId(session), session.user.id, environmentId, id);
|
|
28
|
+
get(session, environmentId, provider, id) {
|
|
29
|
+
return this.connections.getForMember(getActiveOrganizationId(session), session.user.id, environmentId, provider, id);
|
|
30
30
|
}
|
|
31
|
-
revoke(session, environmentId, id) {
|
|
32
|
-
return this.connections.revokeForMember(getActiveOrganizationId(session), session.user.id, environmentId, id);
|
|
31
|
+
revoke(session, environmentId, provider, id) {
|
|
32
|
+
return this.connections.revokeForMember(getActiveOrganizationId(session), session.user.id, environmentId, provider, id);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
__decorate([
|
|
36
36
|
Get(),
|
|
37
37
|
ApiOperation({
|
|
38
38
|
summary: 'List the connections in one environment',
|
|
39
|
-
description: '
|
|
39
|
+
description: 'Returns connections from every installed provider, newest first. Tokens and secrets are never included.',
|
|
40
40
|
}),
|
|
41
41
|
ApiOkResponse({ description: 'Connections in this environment.' }),
|
|
42
42
|
__param(0, Session()),
|
|
@@ -47,30 +47,32 @@ __decorate([
|
|
|
47
47
|
__metadata("design:returntype", void 0)
|
|
48
48
|
], EnvironmentConnectionsController.prototype, "list", null);
|
|
49
49
|
__decorate([
|
|
50
|
-
Get(':id'),
|
|
50
|
+
Get(':provider/:id'),
|
|
51
51
|
ApiOperation({ summary: 'Get one connection' }),
|
|
52
52
|
ApiNotFoundResponse({
|
|
53
53
|
description: 'No such connection in an environment you can reach.',
|
|
54
54
|
}),
|
|
55
55
|
__param(0, Session()),
|
|
56
56
|
__param(1, Param('environmentId')),
|
|
57
|
-
__param(2, Param('
|
|
57
|
+
__param(2, Param('provider')),
|
|
58
|
+
__param(3, Param('id')),
|
|
58
59
|
__metadata("design:type", Function),
|
|
59
|
-
__metadata("design:paramtypes", [Object, String, String]),
|
|
60
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
60
61
|
__metadata("design:returntype", void 0)
|
|
61
62
|
], EnvironmentConnectionsController.prototype, "get", null);
|
|
62
63
|
__decorate([
|
|
63
|
-
Delete(':id'),
|
|
64
|
+
Delete(':provider/:id'),
|
|
64
65
|
ApiOperation({
|
|
65
66
|
summary: 'Revoke a connection',
|
|
66
|
-
description: 'Deletes the credential
|
|
67
|
+
description: 'Deletes the credential and the provider’s connection row. Kosha logins are never affected.',
|
|
67
68
|
}),
|
|
68
69
|
ApiOkResponse({ description: 'The revoked connection id.' }),
|
|
69
70
|
__param(0, Session()),
|
|
70
71
|
__param(1, Param('environmentId')),
|
|
71
|
-
__param(2, Param('
|
|
72
|
+
__param(2, Param('provider')),
|
|
73
|
+
__param(3, Param('id')),
|
|
72
74
|
__metadata("design:type", Function),
|
|
73
|
-
__metadata("design:paramtypes", [Object, String, String]),
|
|
75
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
74
76
|
__metadata("design:returntype", void 0)
|
|
75
77
|
], EnvironmentConnectionsController.prototype, "revoke", null);
|
|
76
78
|
EnvironmentConnectionsController = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.module.d.ts","sourceRoot":"","sources":["../../src/credentials/credentials.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credentials.module.d.ts","sourceRoot":"","sources":["../../src/credentials/credentials.module.ts"],"names":[],"mappings":"AAIA,qBAIa,iBAAiB;CAAG"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { Module } from '@nestjs/common';
|
|
3
|
-
import { ConfigurationsModule } from '../configurations/configurations.module.js';
|
|
4
3
|
import { CredentialsRepository } from './credentials.repository.js';
|
|
5
4
|
import { CredentialsService } from './credentials.service.js';
|
|
6
5
|
let CredentialsModule = class CredentialsModule {
|
|
7
6
|
};
|
|
8
7
|
CredentialsModule = __decorate([
|
|
9
8
|
Module({
|
|
10
|
-
imports: [ConfigurationsModule],
|
|
11
9
|
providers: [CredentialsService, CredentialsRepository],
|
|
12
10
|
exports: [CredentialsService],
|
|
13
11
|
})
|
|
@@ -2,7 +2,10 @@ import { PrismaService } from '../prisma/prisma.service.js';
|
|
|
2
2
|
export declare class CredentialsRepository {
|
|
3
3
|
private readonly prisma;
|
|
4
4
|
constructor(prisma: PrismaService);
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Replaces the envelope in place, after a refresh minted a new token. The
|
|
7
|
+
* grant is rewritten too: a provider may report a different one.
|
|
8
|
+
*/
|
|
9
|
+
replaceEnvelope(id: string, accessToken: string, accessTokenExpiresAt: Date | null, scope?: string | null): Promise<void>;
|
|
7
10
|
}
|
|
8
11
|
//# sourceMappingURL=credentials.repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.repository.d.ts","sourceRoot":"","sources":["../../src/credentials/credentials.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,qBACa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD
|
|
1
|
+
{"version":3,"file":"credentials.repository.d.ts","sourceRoot":"","sources":["../../src/credentials/credentials.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,qBACa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD;;;OAGG;IACG,eAAe,CACnB,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,MAAM,EACnB,oBAAoB,EAAE,IAAI,GAAG,IAAI,EACjC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,IAAI,CAAC;CAUjB"}
|
|
@@ -6,11 +6,18 @@ let CredentialsRepository = class CredentialsRepository {
|
|
|
6
6
|
constructor(prisma) {
|
|
7
7
|
this.prisma = prisma;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Replaces the envelope in place, after a refresh minted a new token. The
|
|
11
|
+
* grant is rewritten too: a provider may report a different one.
|
|
12
|
+
*/
|
|
13
|
+
async replaceEnvelope(id, accessToken, accessTokenExpiresAt, scope) {
|
|
11
14
|
await this.prisma.account.update({
|
|
12
15
|
where: { id },
|
|
13
|
-
data: {
|
|
16
|
+
data: {
|
|
17
|
+
accessToken,
|
|
18
|
+
accessTokenExpiresAt,
|
|
19
|
+
...(scope === undefined ? {} : { scope }),
|
|
20
|
+
},
|
|
14
21
|
});
|
|
15
22
|
}
|
|
16
23
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { KoshaIntegration } from '@kosha-ai/integration-sdk';
|
|
2
|
-
import {
|
|
2
|
+
import type { ResolvedKoshaConfig } from '../config/kosha-config.js';
|
|
3
|
+
import type { ProviderConfiguration } from '../integrations/provider-store.js';
|
|
3
4
|
import { CryptoService } from '../crypto/crypto.service.js';
|
|
4
5
|
import type { Account } from '../generated/prisma/client.js';
|
|
5
6
|
import { CredentialsRepository } from './credentials.repository.js';
|
|
@@ -21,9 +22,9 @@ export interface ResolvedCredential {
|
|
|
21
22
|
export declare class CredentialsService {
|
|
22
23
|
private readonly crypto;
|
|
23
24
|
private readonly credentials;
|
|
24
|
-
private readonly
|
|
25
|
+
private readonly config;
|
|
25
26
|
private readonly logger;
|
|
26
|
-
constructor(crypto: CryptoService, credentials: CredentialsRepository,
|
|
27
|
+
constructor(crypto: CryptoService, credentials: CredentialsRepository, config: ResolvedKoshaConfig);
|
|
27
28
|
/**
|
|
28
29
|
* Returns a usable access token, refreshing first when the stored one has
|
|
29
30
|
* expired and the provider supports it.
|
|
@@ -32,8 +33,11 @@ export declare class CredentialsService {
|
|
|
32
33
|
* the whole consent flow again for a token the provider was willing to
|
|
33
34
|
* renew.
|
|
34
35
|
*/
|
|
35
|
-
resolve(account: Account, integration: KoshaIntegration): Promise<ResolvedCredential>;
|
|
36
|
+
resolve(account: Account, integration: KoshaIntegration, configuration: ProviderConfiguration): Promise<ResolvedCredential>;
|
|
36
37
|
private refresh;
|
|
38
|
+
/** Where the provider sends the end user back. */
|
|
39
|
+
private callbackUrlFor;
|
|
40
|
+
private openCredentials;
|
|
37
41
|
/**
|
|
38
42
|
* What an outbound request needs, whatever the credential's shape. A
|
|
39
43
|
* client-credentials provider carries no token of its own: the integration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.service.d.ts","sourceRoot":"","sources":["../../src/credentials/credentials.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"credentials.service.d.ts","sourceRoot":"","sources":["../../src/credentials/credentials.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAM/E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,mEAAmE;IACnE,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,qBACa,kBAAkB;IAI3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW;IACN,OAAO,CAAC,QAAQ,CAAC,MAAM;IAL/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;gBAG3C,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,qBAAqB,EACZ,MAAM,EAAE,mBAAmB;IAGpE;;;;;;;OAOG;IACG,OAAO,CACX,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,gBAAgB,EAC7B,aAAa,EAAE,qBAAqB,GACnC,OAAO,CAAC,kBAAkB,CAAC;YAyBhB,OAAO;IA4DrB,kDAAkD;IAClD,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,eAAe;IAUvB;;;;OAIG;IACH,OAAO,CAAC,MAAM;YAqCA,qBAAqB;CAoBpC"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
var CredentialsService_1;
|
|
2
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
3
3
|
import { Injectable, Logger, UnauthorizedException } from '@nestjs/common';
|
|
4
|
-
import {
|
|
4
|
+
import { Inject } from '@nestjs/common';
|
|
5
|
+
import { KOSHA_CONFIG } from '../config/tokens.js';
|
|
5
6
|
import { ENVELOPE_VERSION, expiryOf, } from '../crypto/credential-envelope.js';
|
|
6
7
|
import { CryptoService } from '../crypto/crypto.service.js';
|
|
7
8
|
import { CredentialsRepository } from './credentials.repository.js';
|
|
8
9
|
let CredentialsService = CredentialsService_1 = class CredentialsService {
|
|
9
10
|
crypto;
|
|
10
11
|
credentials;
|
|
11
|
-
|
|
12
|
+
config;
|
|
12
13
|
logger = new Logger(CredentialsService_1.name);
|
|
13
|
-
constructor(crypto, credentials,
|
|
14
|
+
constructor(crypto, credentials, config) {
|
|
14
15
|
this.crypto = crypto;
|
|
15
16
|
this.credentials = credentials;
|
|
16
|
-
this.
|
|
17
|
+
this.config = config;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* Returns a usable access token, refreshing first when the stored one has
|
|
@@ -23,7 +24,7 @@ let CredentialsService = CredentialsService_1 = class CredentialsService {
|
|
|
23
24
|
* the whole consent flow again for a token the provider was willing to
|
|
24
25
|
* renew.
|
|
25
26
|
*/
|
|
26
|
-
async resolve(account, integration) {
|
|
27
|
+
async resolve(account, integration, configuration) {
|
|
27
28
|
if (!account.accessToken) {
|
|
28
29
|
throw new UnauthorizedException('Connection has no stored credential');
|
|
29
30
|
}
|
|
@@ -37,19 +38,19 @@ let CredentialsService = CredentialsService_1 = class CredentialsService {
|
|
|
37
38
|
if (!canRefresh) {
|
|
38
39
|
throw new UnauthorizedException('Connection token expired; the end user must reconnect');
|
|
39
40
|
}
|
|
40
|
-
return this.refresh(account, integration, refreshToken);
|
|
41
|
+
return this.refresh(account, integration, configuration, refreshToken);
|
|
41
42
|
}
|
|
42
|
-
async refresh(account, integration, refreshToken) {
|
|
43
|
-
const
|
|
44
|
-
const settings = (configuration.settings ?? {});
|
|
43
|
+
async refresh(account, integration, configuration, refreshToken) {
|
|
44
|
+
const credentials = this.openCredentials(configuration);
|
|
45
45
|
try {
|
|
46
46
|
const tokens = await integration.auth.refresh?.({
|
|
47
47
|
client: {
|
|
48
48
|
clientId: String(credentials['clientId'] ?? ''),
|
|
49
49
|
clientSecret: String(credentials['clientSecret'] ?? ''),
|
|
50
|
-
redirectUri:
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
redirectUri: this.callbackUrlFor(integration.key),
|
|
51
|
+
// The refresh_token grant carries no scope; the provider returns
|
|
52
|
+
// whatever the original consent granted.
|
|
53
|
+
scopes: [],
|
|
53
54
|
},
|
|
54
55
|
refreshToken,
|
|
55
56
|
});
|
|
@@ -68,7 +69,7 @@ let CredentialsService = CredentialsService_1 = class CredentialsService {
|
|
|
68
69
|
: {}),
|
|
69
70
|
};
|
|
70
71
|
const expiresAt = expiryOf(envelope);
|
|
71
|
-
await this.credentials.replaceEnvelope(account.id, this.crypto.sealEnvelope(envelope), expiresAt);
|
|
72
|
+
await this.credentials.replaceEnvelope(account.id, this.crypto.sealEnvelope(envelope), expiresAt, tokens.scope ?? undefined);
|
|
72
73
|
await this.runTokenRefreshedHook(account.id, integration, tokens);
|
|
73
74
|
return this.usable(envelope, expiresAt, true);
|
|
74
75
|
}
|
|
@@ -77,6 +78,16 @@ let CredentialsService = CredentialsService_1 = class CredentialsService {
|
|
|
77
78
|
throw new UnauthorizedException('Connection token expired and could not be refreshed; the end user must reconnect');
|
|
78
79
|
}
|
|
79
80
|
}
|
|
81
|
+
/** Where the provider sends the end user back. */
|
|
82
|
+
callbackUrlFor(provider) {
|
|
83
|
+
const { publicUrl, globalPrefix } = this.config.server;
|
|
84
|
+
return `${publicUrl}/${globalPrefix}/connect/callback/${provider}`;
|
|
85
|
+
}
|
|
86
|
+
openCredentials(configuration) {
|
|
87
|
+
if (!configuration.credentials)
|
|
88
|
+
return {};
|
|
89
|
+
return JSON.parse(this.crypto.decrypt(configuration.credentials));
|
|
90
|
+
}
|
|
80
91
|
/**
|
|
81
92
|
* What an outbound request needs, whatever the credential's shape. A
|
|
82
93
|
* client-credentials provider carries no token of its own: the integration
|
|
@@ -128,8 +139,8 @@ let CredentialsService = CredentialsService_1 = class CredentialsService {
|
|
|
128
139
|
};
|
|
129
140
|
CredentialsService = CredentialsService_1 = __decorate([
|
|
130
141
|
Injectable(),
|
|
142
|
+
__param(2, Inject(KOSHA_CONFIG)),
|
|
131
143
|
__metadata("design:paramtypes", [CryptoService,
|
|
132
|
-
CredentialsRepository,
|
|
133
|
-
ConfigurationsService])
|
|
144
|
+
CredentialsRepository, Object])
|
|
134
145
|
], CredentialsService);
|
|
135
146
|
export { CredentialsService };
|
|
@@ -3,7 +3,6 @@ import { CaService } from './ca.service.js';
|
|
|
3
3
|
import type { ResolvedKoshaConfig } from '../config/kosha-config.js';
|
|
4
4
|
import { CredentialsService } from '../credentials/credentials.service.js';
|
|
5
5
|
import { GrantsService } from './grants.service.js';
|
|
6
|
-
import { IntegrationRegistry } from '../integrations/integration.registry.js';
|
|
7
6
|
import { HostRulesService } from './host-rules.service.js';
|
|
8
7
|
export declare class EgressListener implements OnApplicationBootstrap, OnApplicationShutdown {
|
|
9
8
|
private readonly config;
|
|
@@ -11,14 +10,13 @@ export declare class EgressListener implements OnApplicationBootstrap, OnApplica
|
|
|
11
10
|
private readonly hostRules;
|
|
12
11
|
private readonly ca;
|
|
13
12
|
private readonly credentials;
|
|
14
|
-
private readonly registry;
|
|
15
13
|
private readonly logger;
|
|
16
14
|
/** Reused so a clone's many requests do not each pay for a TLS handshake. */
|
|
17
15
|
private readonly upstreamAgent;
|
|
18
16
|
private server?;
|
|
19
17
|
private mitmServer?;
|
|
20
18
|
private pruneTimer?;
|
|
21
|
-
constructor(config: ResolvedKoshaConfig, grants: GrantsService, hostRules: HostRulesService, ca: CaService, credentials: CredentialsService
|
|
19
|
+
constructor(config: ResolvedKoshaConfig, grants: GrantsService, hostRules: HostRulesService, ca: CaService, credentials: CredentialsService);
|
|
22
20
|
onApplicationBootstrap(): Promise<void>;
|
|
23
21
|
onApplicationShutdown(): void;
|
|
24
22
|
private createProxyServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"egress.listener.d.ts","sourceRoot":"","sources":["../../src/egress/egress.listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAC;AAWxB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAc,MAAM,qBAAqB,CAAC;AAChE,OAAO,
|
|
1
|
+
{"version":3,"file":"egress.listener.d.ts","sourceRoot":"","sources":["../../src/egress/egress.listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAC;AAWxB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAc,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACL,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AAgGjC,qBACa,cACX,YAAW,sBAAsB,EAAE,qBAAqB;IAahC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAf9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmC;IAC1D,6EAA6E;IAC7E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAG3B;IACH,OAAO,CAAC,MAAM,CAAC,CAAc;IAC7B,OAAO,CAAC,UAAU,CAAC,CAAc;IACjC,OAAO,CAAC,UAAU,CAAC,CAAiB;gBAGK,MAAM,EAAE,mBAAmB,EACjD,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,gBAAgB,EAC3B,EAAE,EAAE,SAAS,EACb,WAAW,EAAE,kBAAkB;IAG5C,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B7C,qBAAqB,IAAI,IAAI;IAM7B,OAAO,CAAC,iBAAiB;YA6BX,aAAa;IAwD3B,8EAA8E;IAC9E,OAAO,CAAC,MAAM;IAuBd,iFAAiF;IACjF,OAAO,CAAC,SAAS;IA4BjB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;YAYV,OAAO;CA8FtB"}
|
|
@@ -9,7 +9,6 @@ import tls from 'node:tls';
|
|
|
9
9
|
import { CaService } from './ca.service.js';
|
|
10
10
|
import { CredentialsService } from '../credentials/credentials.service.js';
|
|
11
11
|
import { GrantsService } from './grants.service.js';
|
|
12
|
-
import { IntegrationRegistry } from '../integrations/integration.registry.js';
|
|
13
12
|
import { HostRulesService, } from './host-rules.service.js';
|
|
14
13
|
import { KOSHA_CONFIG } from '../config/tokens.js';
|
|
15
14
|
/**
|
|
@@ -95,7 +94,6 @@ let EgressListener = EgressListener_1 = class EgressListener {
|
|
|
95
94
|
hostRules;
|
|
96
95
|
ca;
|
|
97
96
|
credentials;
|
|
98
|
-
registry;
|
|
99
97
|
logger = new Logger(EgressListener_1.name);
|
|
100
98
|
/** Reused so a clone's many requests do not each pay for a TLS handshake. */
|
|
101
99
|
upstreamAgent = new https.Agent({
|
|
@@ -105,13 +103,12 @@ let EgressListener = EgressListener_1 = class EgressListener {
|
|
|
105
103
|
server;
|
|
106
104
|
mitmServer;
|
|
107
105
|
pruneTimer;
|
|
108
|
-
constructor(config, grants, hostRules, ca, credentials
|
|
106
|
+
constructor(config, grants, hostRules, ca, credentials) {
|
|
109
107
|
this.config = config;
|
|
110
108
|
this.grants = grants;
|
|
111
109
|
this.hostRules = hostRules;
|
|
112
110
|
this.ca = ca;
|
|
113
111
|
this.credentials = credentials;
|
|
114
|
-
this.registry = registry;
|
|
115
112
|
}
|
|
116
113
|
async onApplicationBootstrap() {
|
|
117
114
|
if (!this.config.egress.enabled)
|
|
@@ -255,7 +252,7 @@ let EgressListener = EgressListener_1 = class EgressListener {
|
|
|
255
252
|
if (borrowable === null) {
|
|
256
253
|
throw new Error(`This grant can no longer use ${rule.providerKey}. The connection may have been revoked.`);
|
|
257
254
|
}
|
|
258
|
-
const credential = await this.credentials.resolve(borrowable.account,
|
|
255
|
+
const credential = await this.credentials.resolve(borrowable.account, borrowable.integration, borrowable.configuration);
|
|
259
256
|
injected = rule.headers({
|
|
260
257
|
accessToken: credential.accessToken,
|
|
261
258
|
tokenType: credential.tokenType,
|
|
@@ -322,7 +319,6 @@ EgressListener = EgressListener_1 = __decorate([
|
|
|
322
319
|
__metadata("design:paramtypes", [Object, GrantsService,
|
|
323
320
|
HostRulesService,
|
|
324
321
|
CaService,
|
|
325
|
-
CredentialsService
|
|
326
|
-
IntegrationRegistry])
|
|
322
|
+
CredentialsService])
|
|
327
323
|
], EgressListener);
|
|
328
324
|
export { EgressListener };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { KoshaIntegration } from '@kosha-ai/integration-sdk';
|
|
2
|
+
import type { Account } from '../generated/prisma/client.js';
|
|
3
|
+
import { IntegrationRegistry } from '../integrations/integration.registry.js';
|
|
4
|
+
import { ProviderStore, type ProviderConfiguration } from '../integrations/provider-store.js';
|
|
2
5
|
import { PrismaService } from '../prisma/prisma.service.js';
|
|
3
6
|
export interface GrantRow {
|
|
4
7
|
organizationId: string;
|
|
@@ -10,14 +13,17 @@ export interface GrantRow {
|
|
|
10
13
|
label?: string;
|
|
11
14
|
expiresAt: Date;
|
|
12
15
|
}
|
|
13
|
-
/** A credential the broker may borrow, with
|
|
16
|
+
/** A credential the broker may borrow, with what it takes to refresh it. */
|
|
14
17
|
export interface BorrowableCredential {
|
|
15
18
|
account: Account;
|
|
16
|
-
configuration:
|
|
19
|
+
configuration: ProviderConfiguration;
|
|
20
|
+
integration: KoshaIntegration;
|
|
17
21
|
}
|
|
18
22
|
export declare class EgressRepository {
|
|
19
23
|
private readonly prisma;
|
|
20
|
-
|
|
24
|
+
private readonly store;
|
|
25
|
+
private readonly registry;
|
|
26
|
+
constructor(prisma: PrismaService, store: ProviderStore, registry: IntegrationRegistry);
|
|
21
27
|
/**
|
|
22
28
|
* The person a grant is minted for. A `user` row exists per environment, so
|
|
23
29
|
* finding one by its derived address settles the environment too — which is
|
|
@@ -48,8 +54,9 @@ export declare class EgressRepository {
|
|
|
48
54
|
* own user, never by anything in a request — that is what stops a grant
|
|
49
55
|
* reaching another tenant's credential.
|
|
50
56
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
57
|
+
* Starts from the provider's connection row, which an operator's password
|
|
58
|
+
* never has, so a login can never be lent. A person connected through two
|
|
59
|
+
* configurations lends the newest.
|
|
53
60
|
*/
|
|
54
61
|
findCredentialFor(userId: string, integrationKey: string): Promise<BorrowableCredential | null>;
|
|
55
62
|
/** Which of these integrations this person has actually connected. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"egress.repository.d.ts","sourceRoot":"","sources":["../../src/egress/egress.repository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"egress.repository.d.ts","sourceRoot":"","sources":["../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C;IAO9D,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ3E,aAAa,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;IAezB,mBAAmB,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAOxD;;;;;;;;OAQG;IACG,iBAAiB,CACrB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAsBvC,sEAAsE;IAChE,wBAAwB,CAC5B,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,MAAM,EAAE,CAAC;CAgBrB"}
|
|
@@ -2,11 +2,17 @@ import { __decorate, __metadata } from "tslib";
|
|
|
2
2
|
import { Injectable } from '@nestjs/common';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { derivedEmail } from '../connect/connect.repository.js';
|
|
5
|
+
import { IntegrationRegistry } from '../integrations/integration.registry.js';
|
|
6
|
+
import { ProviderStore, } from '../integrations/provider-store.js';
|
|
5
7
|
import { PrismaService } from '../prisma/prisma.service.js';
|
|
6
8
|
let EgressRepository = class EgressRepository {
|
|
7
9
|
prisma;
|
|
8
|
-
|
|
10
|
+
store;
|
|
11
|
+
registry;
|
|
12
|
+
constructor(prisma, store, registry) {
|
|
9
13
|
this.prisma = prisma;
|
|
14
|
+
this.store = store;
|
|
15
|
+
this.registry = registry;
|
|
10
16
|
}
|
|
11
17
|
/**
|
|
12
18
|
* The person a grant is minted for. A `user` row exists per environment, so
|
|
@@ -57,60 +63,41 @@ let EgressRepository = class EgressRepository {
|
|
|
57
63
|
* own user, never by anything in a request — that is what stops a grant
|
|
58
64
|
* reaching another tenant's credential.
|
|
59
65
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
66
|
+
* Starts from the provider's connection row, which an operator's password
|
|
67
|
+
* never has, so a login can never be lent. A person connected through two
|
|
68
|
+
* configurations lends the newest.
|
|
62
69
|
*/
|
|
63
70
|
async findCredentialFor(userId, integrationKey) {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
select: { id: true },
|
|
67
|
-
});
|
|
68
|
-
if (configurations.length === 0)
|
|
71
|
+
const integration = this.registry.find(integrationKey);
|
|
72
|
+
if (!integration)
|
|
69
73
|
return null;
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
userId,
|
|
73
|
-
providerId: { in: configurations.map((row) => row.id) },
|
|
74
|
-
NOT: { environmentId: null },
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
if (!account)
|
|
74
|
+
const [connection] = await this.store.listConnectionsForUser(integration, userId);
|
|
75
|
+
if (!connection)
|
|
78
76
|
return null;
|
|
79
|
-
const configuration = await
|
|
80
|
-
where: { id:
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
const [account, configuration] = await Promise.all([
|
|
78
|
+
this.prisma.account.findUnique({ where: { id: connection.accountId } }),
|
|
79
|
+
this.store.findConfigurationWithCredentials(integration, connection.configurationId),
|
|
80
|
+
]);
|
|
81
|
+
if (!account || !configuration)
|
|
83
82
|
return null;
|
|
84
|
-
return { account, configuration };
|
|
83
|
+
return { account, configuration, integration };
|
|
85
84
|
}
|
|
86
85
|
/** Which of these integrations this person has actually connected. */
|
|
87
86
|
async connectedIntegrationKeys(userId, integrationKeys) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const byId = new Map(configurations.map((row) => [row.id, row.integrationKey]));
|
|
97
|
-
const accounts = await this.prisma.account.findMany({
|
|
98
|
-
where: {
|
|
99
|
-
userId,
|
|
100
|
-
providerId: { in: [...byId.keys()] },
|
|
101
|
-
NOT: { environmentId: null },
|
|
102
|
-
},
|
|
103
|
-
select: { providerId: true },
|
|
104
|
-
});
|
|
105
|
-
return [
|
|
106
|
-
...new Set(accounts
|
|
107
|
-
.map((row) => byId.get(row.providerId))
|
|
108
|
-
.filter((key) => key !== undefined)),
|
|
109
|
-
];
|
|
87
|
+
const connected = await Promise.all(integrationKeys.map(async (key) => {
|
|
88
|
+
const integration = this.registry.find(key);
|
|
89
|
+
if (!integration)
|
|
90
|
+
return null;
|
|
91
|
+
const connections = await this.store.listConnectionsForUser(integration, userId);
|
|
92
|
+
return connections.length > 0 ? key : null;
|
|
93
|
+
}));
|
|
94
|
+
return connected.filter((key) => key !== null);
|
|
110
95
|
}
|
|
111
96
|
};
|
|
112
97
|
EgressRepository = __decorate([
|
|
113
98
|
Injectable(),
|
|
114
|
-
__metadata("design:paramtypes", [PrismaService
|
|
99
|
+
__metadata("design:paramtypes", [PrismaService,
|
|
100
|
+
ProviderStore,
|
|
101
|
+
IntegrationRegistry])
|
|
115
102
|
], EgressRepository);
|
|
116
103
|
export { EgressRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/generated/prisma/browser.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,MAAM,MAAM,sCAAsC,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,KAAK,MAAM,MAAM,YAAY,CAAA;AACpC,cAAc,YAAY,CAAC;AAC3B;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAA;AACnC;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAA;AACzC;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAA;AACzC;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,iBAAiB,CAAA;AACnD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,iBAAiB,CAAA;AACnD;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,WA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