@kosha-ai/server 0.1.0 → 1.0.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 +48 -2
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +24 -6
- package/dist/configurations/configurations.controller.d.ts +11 -136
- package/dist/configurations/configurations.controller.d.ts.map +1 -1
- package/dist/configurations/configurations.controller.js +58 -25
- package/dist/configurations/configurations.module.d.ts.map +1 -1
- package/dist/configurations/configurations.module.js +4 -1
- package/dist/configurations/configurations.repository.d.ts +43 -0
- package/dist/configurations/configurations.repository.d.ts.map +1 -0
- package/dist/configurations/configurations.repository.js +76 -0
- package/dist/configurations/configurations.service.d.ts +38 -194
- package/dist/configurations/configurations.service.d.ts.map +1 -1
- package/dist/configurations/configurations.service.js +118 -110
- package/dist/configurations/dto/create-configuration.dto.d.ts +8 -0
- package/dist/configurations/dto/create-configuration.dto.d.ts.map +1 -0
- package/dist/configurations/dto/create-configuration.dto.js +54 -0
- package/dist/configurations/dto/update-configuration.dto.d.ts +7 -0
- package/dist/configurations/dto/update-configuration.dto.d.ts.map +1 -0
- package/dist/configurations/dto/update-configuration.dto.js +39 -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 +45 -15
- package/dist/connect/connect.module.d.ts.map +1 -1
- package/dist/connect/connect.module.js +4 -2
- 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 +146 -0
- package/dist/connect/connect.service.d.ts +28 -19
- package/dist/connect/connect.service.d.ts.map +1 -1
- package/dist/connect/connect.service.js +149 -163
- 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 +55 -0
- package/dist/connect/dto/create-test-session.dto.d.ts +10 -0
- package/dist/connect/dto/create-test-session.dto.d.ts.map +1 -0
- package/dist/connect/dto/create-test-session.dto.js +34 -0
- package/dist/connections/connections.controller.d.ts +8 -61
- package/dist/connections/connections.controller.d.ts.map +1 -1
- package/dist/connections/connections.controller.js +31 -9
- 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 +24 -0
- package/dist/connections/connections.repository.d.ts.map +1 -0
- package/dist/connections/connections.repository.js +66 -0
- package/dist/connections/connections.service.d.ts +24 -69
- package/dist/connections/connections.service.d.ts.map +1 -1
- package/dist/connections/connections.service.js +59 -56
- package/dist/connections/dto/list-connections.dto.d.ts +5 -0
- package/dist/connections/dto/list-connections.dto.d.ts.map +1 -0
- package/dist/connections/dto/list-connections.dto.js +25 -0
- package/dist/connections/environment-connections.controller.d.ts +26 -0
- package/dist/connections/environment-connections.controller.d.ts.map +1 -0
- package/dist/connections/environment-connections.controller.js +81 -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.js +3 -3
- package/dist/credentials/credentials.repository.d.ts +8 -0
- package/dist/credentials/credentials.repository.d.ts.map +1 -0
- package/dist/credentials/credentials.repository.js +21 -0
- package/dist/credentials/credentials.service.d.ts +19 -29
- package/dist/credentials/credentials.service.d.ts.map +1 -1
- package/dist/credentials/credentials.service.js +84 -57
- 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 +3 -1
- package/dist/egress/egress.listener.d.ts.map +1 -1
- package/dist/egress/egress.listener.js +12 -8
- 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 +58 -0
- package/dist/egress/egress.repository.d.ts.map +1 -0
- package/dist/egress/egress.repository.js +116 -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 +14 -37
- package/dist/generated/prisma/browser.d.ts.map +1 -1
- package/dist/generated/prisma/client.d.ts +14 -37
- package/dist/generated/prisma/client.d.ts.map +1 -1
- package/dist/generated/prisma/commonInputTypes.d.ts +104 -145
- 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 +20 -53
- 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 +215 -519
- package/dist/generated/prisma/internal/prismaNamespace.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespace.js +38 -90
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +37 -92
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +38 -90
- package/dist/generated/prisma/models/Account.d.ts +344 -26
- package/dist/generated/prisma/models/Account.d.ts.map +1 -1
- package/dist/generated/prisma/models/Configuration.d.ts +218 -851
- package/dist/generated/prisma/models/Configuration.d.ts.map +1 -1
- 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 +1644 -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 +338 -2
- package/dist/generated/prisma/models/User.d.ts.map +1 -1
- package/dist/generated/prisma/models.d.ts +3 -6
- package/dist/generated/prisma/models.d.ts.map +1 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/integrations/integrations.controller.d.ts +2 -1
- package/dist/integrations/integrations.controller.d.ts.map +1 -1
- package/dist/integrations/integrations.module.d.ts.map +1 -1
- package/dist/integrations/integrations.module.js +0 -2
- package/dist/kosha.module.d.ts.map +1 -1
- package/dist/kosha.module.js +9 -3
- package/dist/proxy/proxy.controller.d.ts +8 -3
- package/dist/proxy/proxy.controller.d.ts.map +1 -1
- package/dist/proxy/proxy.controller.js +26 -10
- package/dist/proxy/proxy.module.d.ts.map +1 -1
- package/dist/proxy/proxy.module.js +5 -2
- package/dist/proxy/proxy.repository.d.ts +24 -0
- package/dist/proxy/proxy.repository.d.ts.map +1 -0
- package/dist/proxy/proxy.repository.js +47 -0
- package/dist/proxy/proxy.service.d.ts +17 -5
- package/dist/proxy/proxy.service.d.ts.map +1 -1
- package/dist/proxy/proxy.service.js +58 -27
- package/package.json +7 -4
- package/prisma/migrations/20260929101936_init/migration.sql +345 -0
- package/prisma/migrations/20260930102529_connection_config/migration.sql +2 -0
- package/prisma/schema.prisma +93 -198
- 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/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/20260908000000_init/migration.sql +0 -209
- 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/{ConnectSession.js → Environment.js} +0 -0
- /package/dist/generated/prisma/models/{Connection.js → Team.js} +0 -0
- /package/dist/generated/prisma/models/{ConnectionCredential.js → TeamMember.js} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PrismaService } from '../prisma/prisma.service.js';
|
|
2
|
+
export declare class CredentialsRepository {
|
|
3
|
+
private readonly prisma;
|
|
4
|
+
constructor(prisma: PrismaService);
|
|
5
|
+
/** Replaces the envelope in place, after a refresh minted a new token. */
|
|
6
|
+
replaceEnvelope(id: string, accessToken: string, accessTokenExpiresAt: Date | null): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=credentials.repository.d.ts.map
|
|
@@ -0,0 +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,0EAA0E;IACpE,eAAe,CACnB,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,MAAM,EACnB,oBAAoB,EAAE,IAAI,GAAG,IAAI,GAChC,OAAO,CAAC,IAAI,CAAC;CAMjB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { PrismaService } from '../prisma/prisma.service.js';
|
|
4
|
+
let CredentialsRepository = class CredentialsRepository {
|
|
5
|
+
prisma;
|
|
6
|
+
constructor(prisma) {
|
|
7
|
+
this.prisma = prisma;
|
|
8
|
+
}
|
|
9
|
+
/** Replaces the envelope in place, after a refresh minted a new token. */
|
|
10
|
+
async replaceEnvelope(id, accessToken, accessTokenExpiresAt) {
|
|
11
|
+
await this.prisma.account.update({
|
|
12
|
+
where: { id },
|
|
13
|
+
data: { accessToken, accessTokenExpiresAt },
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
CredentialsRepository = __decorate([
|
|
18
|
+
Injectable(),
|
|
19
|
+
__metadata("design:paramtypes", [PrismaService])
|
|
20
|
+
], CredentialsRepository);
|
|
21
|
+
export { CredentialsRepository };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import type { KoshaIntegration } from '@kosha-ai/integration-sdk';
|
|
1
2
|
import { ConfigurationsService } from '../configurations/configurations.service.js';
|
|
2
|
-
import { ConnectService } from '../connect/connect.service.js';
|
|
3
3
|
import { CryptoService } from '../crypto/crypto.service.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import type { Account } from '../generated/prisma/client.js';
|
|
5
|
+
import { CredentialsRepository } from './credentials.repository.js';
|
|
6
6
|
/**
|
|
7
|
-
* Turning a stored
|
|
7
|
+
* Turning a stored credential into something that can sign an outbound
|
|
8
|
+
* request.
|
|
8
9
|
*
|
|
9
10
|
* Its own service rather than a private method on the proxy, because the REST
|
|
10
11
|
* proxy and the egress broker both need this and two copies could disagree
|
|
11
|
-
* about when a
|
|
12
|
+
* about when a credential is dead.
|
|
12
13
|
*/
|
|
13
14
|
export interface ResolvedCredential {
|
|
14
15
|
accessToken: string;
|
|
@@ -17,39 +18,28 @@ export interface ResolvedCredential {
|
|
|
17
18
|
/** True when we minted a new token, so the old one is now dead. */
|
|
18
19
|
refreshed: boolean;
|
|
19
20
|
}
|
|
20
|
-
export interface ResolvableConnection {
|
|
21
|
-
id: string;
|
|
22
|
-
configurationId: string;
|
|
23
|
-
configuration: {
|
|
24
|
-
provider: {
|
|
25
|
-
key: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
credential: {
|
|
29
|
-
accessToken: string;
|
|
30
|
-
refreshToken: string | null;
|
|
31
|
-
tokenType: string | null;
|
|
32
|
-
expiresAt: Date | null;
|
|
33
|
-
} | null;
|
|
34
|
-
}
|
|
35
21
|
export declare class CredentialsService {
|
|
36
|
-
private readonly prisma;
|
|
37
22
|
private readonly crypto;
|
|
38
|
-
private readonly
|
|
39
|
-
private readonly connect;
|
|
23
|
+
private readonly credentials;
|
|
40
24
|
private readonly configurations;
|
|
41
25
|
private readonly logger;
|
|
42
|
-
constructor(
|
|
26
|
+
constructor(crypto: CryptoService, credentials: CredentialsRepository, configurations: ConfigurationsService);
|
|
43
27
|
/**
|
|
44
28
|
* Returns a usable access token, refreshing first when the stored one has
|
|
45
|
-
* expired and the provider supports
|
|
29
|
+
* expired and the provider supports it.
|
|
46
30
|
*
|
|
47
|
-
* Without this an expired token is a dead end for the end user: they
|
|
48
|
-
*
|
|
31
|
+
* Without this an expired token is a dead end for the end user: they walk
|
|
32
|
+
* the whole consent flow again for a token the provider was willing to
|
|
49
33
|
* renew.
|
|
50
34
|
*/
|
|
51
|
-
|
|
35
|
+
resolve(account: Account, integration: KoshaIntegration): Promise<ResolvedCredential>;
|
|
36
|
+
private refresh;
|
|
37
|
+
/**
|
|
38
|
+
* What an outbound request needs, whatever the credential's shape. A
|
|
39
|
+
* client-credentials provider carries no token of its own: the integration
|
|
40
|
+
* signs from its configuration, so there is nothing to hand it here.
|
|
41
|
+
*/
|
|
42
|
+
private usable;
|
|
52
43
|
private runTokenRefreshedHook;
|
|
53
|
-
private markExpired;
|
|
54
44
|
}
|
|
55
45
|
//# sourceMappingURL=credentials.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.service.d.ts","sourceRoot":"","sources":["../../src/credentials/credentials.service.ts"],"names":[],"mappings":"
|
|
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;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAMpF,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;IAC5B,OAAO,CAAC,QAAQ,CAAC,cAAc;IALjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;gBAG3C,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,qBAAqB,EAClC,cAAc,EAAE,qBAAqB;IAGxD;;;;;;;OAOG;IACG,OAAO,CACX,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,gBAAgB,GAC5B,OAAO,CAAC,kBAAkB,CAAC;YAyBhB,OAAO;IAgErB;;;;OAIG;IACH,OAAO,CAAC,MAAM;YAqCA,qBAAqB;CAoBpC"}
|
|
@@ -1,84 +1,119 @@
|
|
|
1
1
|
var CredentialsService_1;
|
|
2
2
|
import { __decorate, __metadata } from "tslib";
|
|
3
|
-
import {
|
|
3
|
+
import { Injectable, Logger, UnauthorizedException } from '@nestjs/common';
|
|
4
4
|
import { ConfigurationsService } from '../configurations/configurations.service.js';
|
|
5
|
-
import {
|
|
5
|
+
import { ENVELOPE_VERSION, expiryOf, } from '../crypto/credential-envelope.js';
|
|
6
6
|
import { CryptoService } from '../crypto/crypto.service.js';
|
|
7
|
-
import {
|
|
8
|
-
import { PrismaService } from '../prisma/prisma.service.js';
|
|
7
|
+
import { CredentialsRepository } from './credentials.repository.js';
|
|
9
8
|
let CredentialsService = CredentialsService_1 = class CredentialsService {
|
|
10
|
-
prisma;
|
|
11
9
|
crypto;
|
|
12
|
-
|
|
13
|
-
connect;
|
|
10
|
+
credentials;
|
|
14
11
|
configurations;
|
|
15
12
|
logger = new Logger(CredentialsService_1.name);
|
|
16
|
-
constructor(
|
|
17
|
-
this.prisma = prisma;
|
|
13
|
+
constructor(crypto, credentials, configurations) {
|
|
18
14
|
this.crypto = crypto;
|
|
19
|
-
this.
|
|
20
|
-
this.connect = connect;
|
|
15
|
+
this.credentials = credentials;
|
|
21
16
|
this.configurations = configurations;
|
|
22
17
|
}
|
|
23
18
|
/**
|
|
24
19
|
* Returns a usable access token, refreshing first when the stored one has
|
|
25
|
-
* expired and the provider supports
|
|
20
|
+
* expired and the provider supports it.
|
|
26
21
|
*
|
|
27
|
-
* Without this an expired token is a dead end for the end user: they
|
|
28
|
-
*
|
|
22
|
+
* Without this an expired token is a dead end for the end user: they walk
|
|
23
|
+
* the whole consent flow again for a token the provider was willing to
|
|
29
24
|
* renew.
|
|
30
25
|
*/
|
|
31
|
-
async
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
throw new ForbiddenException('Connection has no stored credential');
|
|
26
|
+
async resolve(account, integration) {
|
|
27
|
+
if (!account.accessToken) {
|
|
28
|
+
throw new UnauthorizedException('Connection has no stored credential');
|
|
35
29
|
}
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
const integration = this.registry.get(connection.configuration.provider.key);
|
|
46
|
-
const canRefresh = typeof integration.auth.refresh === 'function' && credential.refreshToken;
|
|
30
|
+
const envelope = this.crypto.openEnvelope(account.accessToken);
|
|
31
|
+
const expiresAt = expiryOf(envelope);
|
|
32
|
+
const expired = expiresAt !== null && expiresAt <= new Date();
|
|
33
|
+
if (!expired)
|
|
34
|
+
return this.usable(envelope, expiresAt, false);
|
|
35
|
+
const refreshToken = envelope.type === 'oauth2' ? envelope.refreshToken : undefined;
|
|
36
|
+
const canRefresh = typeof integration.auth.refresh === 'function' && refreshToken;
|
|
47
37
|
if (!canRefresh) {
|
|
48
|
-
await this.markExpired(connection.id, 'Access token expired');
|
|
49
38
|
throw new UnauthorizedException('Connection token expired; the end user must reconnect');
|
|
50
39
|
}
|
|
51
|
-
|
|
40
|
+
return this.refresh(account, integration, refreshToken);
|
|
41
|
+
}
|
|
42
|
+
async refresh(account, integration, refreshToken) {
|
|
43
|
+
const { configuration, credentials } = await this.configurations.getWithCredentials(account.providerId);
|
|
44
|
+
const settings = (configuration.settings ?? {});
|
|
52
45
|
try {
|
|
53
46
|
const tokens = await integration.auth.refresh?.({
|
|
54
47
|
client: {
|
|
55
|
-
clientId:
|
|
56
|
-
clientSecret:
|
|
57
|
-
redirectUri:
|
|
58
|
-
this.configurations.callbackUrlFor(configuration.
|
|
59
|
-
scopes:
|
|
48
|
+
clientId: String(credentials['clientId'] ?? ''),
|
|
49
|
+
clientSecret: String(credentials['clientSecret'] ?? ''),
|
|
50
|
+
redirectUri: settings.redirectUri ??
|
|
51
|
+
this.configurations.callbackUrlFor(configuration.integrationKey),
|
|
52
|
+
scopes: settings.scopes ?? [],
|
|
60
53
|
},
|
|
61
|
-
refreshToken
|
|
54
|
+
refreshToken,
|
|
62
55
|
});
|
|
63
56
|
if (!tokens)
|
|
64
57
|
throw new Error('Refresh returned no tokens');
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
const envelope = {
|
|
59
|
+
v: ENVELOPE_VERSION,
|
|
60
|
+
type: 'oauth2',
|
|
68
61
|
accessToken: tokens.accessToken,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
...(tokens.refreshToken ? { refreshToken: tokens.refreshToken } : {}),
|
|
63
|
+
...(tokens.tokenType ? { tokenType: tokens.tokenType } : {}),
|
|
64
|
+
...(tokens.expiresInSeconds
|
|
65
|
+
? {
|
|
66
|
+
expiresAt: new Date(Date.now() + tokens.expiresInSeconds * 1000).toISOString(),
|
|
67
|
+
}
|
|
68
|
+
: {}),
|
|
74
69
|
};
|
|
70
|
+
const expiresAt = expiryOf(envelope);
|
|
71
|
+
await this.credentials.replaceEnvelope(account.id, this.crypto.sealEnvelope(envelope), expiresAt);
|
|
72
|
+
await this.runTokenRefreshedHook(account.id, integration, tokens);
|
|
73
|
+
return this.usable(envelope, expiresAt, true);
|
|
75
74
|
}
|
|
76
75
|
catch (error) {
|
|
77
|
-
|
|
78
|
-
await this.markExpired(connection.id, `Token refresh failed: ${message}`);
|
|
76
|
+
this.logger.warn(`Refresh failed for ${integration.key}: ${error instanceof Error ? error.message : error}`);
|
|
79
77
|
throw new UnauthorizedException('Connection token expired and could not be refreshed; the end user must reconnect');
|
|
80
78
|
}
|
|
81
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* What an outbound request needs, whatever the credential's shape. A
|
|
82
|
+
* client-credentials provider carries no token of its own: the integration
|
|
83
|
+
* signs from its configuration, so there is nothing to hand it here.
|
|
84
|
+
*/
|
|
85
|
+
usable(envelope, expiresAt, refreshed) {
|
|
86
|
+
switch (envelope.type) {
|
|
87
|
+
case 'oauth2':
|
|
88
|
+
return {
|
|
89
|
+
accessToken: envelope.accessToken,
|
|
90
|
+
tokenType: envelope.tokenType ?? null,
|
|
91
|
+
expiresAt,
|
|
92
|
+
refreshed,
|
|
93
|
+
};
|
|
94
|
+
case 'api_key':
|
|
95
|
+
return {
|
|
96
|
+
accessToken: envelope.key,
|
|
97
|
+
tokenType: null,
|
|
98
|
+
expiresAt: null,
|
|
99
|
+
refreshed,
|
|
100
|
+
};
|
|
101
|
+
case 'app':
|
|
102
|
+
return {
|
|
103
|
+
accessToken: envelope.installationId,
|
|
104
|
+
tokenType: null,
|
|
105
|
+
expiresAt: null,
|
|
106
|
+
refreshed,
|
|
107
|
+
};
|
|
108
|
+
case 'oauth2_cc':
|
|
109
|
+
return {
|
|
110
|
+
accessToken: '',
|
|
111
|
+
tokenType: null,
|
|
112
|
+
expiresAt: null,
|
|
113
|
+
refreshed,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
82
117
|
async runTokenRefreshedHook(connectionId, integration, tokens) {
|
|
83
118
|
const hook = integration.hooks?.onTokenRefreshed;
|
|
84
119
|
if (!hook)
|
|
@@ -90,19 +125,11 @@ let CredentialsService = CredentialsService_1 = class CredentialsService {
|
|
|
90
125
|
this.logger.error(`onTokenRefreshed hook failed for "${integration.key}": ${error instanceof Error ? error.message : error}`);
|
|
91
126
|
}
|
|
92
127
|
}
|
|
93
|
-
async markExpired(connectionId, reason) {
|
|
94
|
-
await this.prisma.connection.update({
|
|
95
|
-
where: { id: connectionId },
|
|
96
|
-
data: { status: 'EXPIRED', errorMessage: reason },
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
128
|
};
|
|
100
129
|
CredentialsService = CredentialsService_1 = __decorate([
|
|
101
130
|
Injectable(),
|
|
102
|
-
__metadata("design:paramtypes", [
|
|
103
|
-
|
|
104
|
-
IntegrationRegistry,
|
|
105
|
-
ConnectService,
|
|
131
|
+
__metadata("design:paramtypes", [CryptoService,
|
|
132
|
+
CredentialsRepository,
|
|
106
133
|
ConfigurationsService])
|
|
107
134
|
], CredentialsService);
|
|
108
135
|
export { CredentialsService };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a stored credential actually is.
|
|
3
|
+
*
|
|
4
|
+
* `account.accessToken` holds one of these, encrypted — not a bare token. The
|
|
5
|
+
* database knows nothing about auth types, so the discriminator travels with
|
|
6
|
+
* the secret rather than sitting in a column, and a provider that needs
|
|
7
|
+
* different fields needs no migration.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ENVELOPE_VERSION = 1;
|
|
10
|
+
interface Versioned {
|
|
11
|
+
v: typeof ENVELOPE_VERSION;
|
|
12
|
+
}
|
|
13
|
+
/** A token pair from an authorization-code flow. */
|
|
14
|
+
export interface OAuth2Envelope extends Versioned {
|
|
15
|
+
type: 'oauth2';
|
|
16
|
+
accessToken: string;
|
|
17
|
+
refreshToken?: string;
|
|
18
|
+
tokenType?: string;
|
|
19
|
+
/** ISO 8601. Mirrored into `account.accessTokenExpiresAt` on write. */
|
|
20
|
+
expiresAt?: string;
|
|
21
|
+
}
|
|
22
|
+
/** A key the end user pasted, such as Apollo's. */
|
|
23
|
+
export interface ApiKeyEnvelope extends Versioned {
|
|
24
|
+
type: 'api_key';
|
|
25
|
+
key: string;
|
|
26
|
+
}
|
|
27
|
+
/** A GitHub App install: tokens are minted per call from the installation. */
|
|
28
|
+
export interface AppEnvelope extends Versioned {
|
|
29
|
+
type: 'app';
|
|
30
|
+
installationId: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Client credentials, like Zoom's. The secret lives entirely in the
|
|
34
|
+
* configuration, so the connection records nothing but its own existence.
|
|
35
|
+
*/
|
|
36
|
+
export interface ClientCredentialsEnvelope extends Versioned {
|
|
37
|
+
type: 'oauth2_cc';
|
|
38
|
+
}
|
|
39
|
+
export type CredentialEnvelope = OAuth2Envelope | ApiKeyEnvelope | AppEnvelope | ClientCredentialsEnvelope;
|
|
40
|
+
export type CredentialEnvelopeType = CredentialEnvelope['type'];
|
|
41
|
+
export declare class InvalidEnvelopeError extends Error {
|
|
42
|
+
constructor(reason: string);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Rejects rather than guesses. A credential we cannot read is a connection the
|
|
46
|
+
* end user must redo, and that is a better outcome than sending a provider
|
|
47
|
+
* something we mis-parsed.
|
|
48
|
+
*/
|
|
49
|
+
export declare function parseEnvelope(json: string): CredentialEnvelope;
|
|
50
|
+
/**
|
|
51
|
+
* The expiry to mirror into `account.accessTokenExpiresAt`, so the refresh
|
|
52
|
+
* sweep can find expiring credentials without decrypting any of them.
|
|
53
|
+
*/
|
|
54
|
+
export declare function expiryOf(envelope: CredentialEnvelope): Date | null;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=credential-envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-envelope.d.ts","sourceRoot":"","sources":["../../src/crypto/credential-envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,UAAU,SAAS;IACjB,CAAC,EAAE,OAAO,gBAAgB,CAAC;CAC5B;AAED,oDAAoD;AACpD,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,mDAAmD;AACnD,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,8EAA8E;AAC9E,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,IAAI,EAAE,KAAK,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,yBAA0B,SAAQ,SAAS;IAC1D,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,MAAM,kBAAkB,GAC5B,cAAc,GAAG,cAAc,GAAG,WAAW,GAAG,yBAAyB,CAAC;AAE5E,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAEhE,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,MAAM,EAAE,MAAM;CAI3B;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CA6C9D;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,GAAG,IAAI,CAKlE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a stored credential actually is.
|
|
3
|
+
*
|
|
4
|
+
* `account.accessToken` holds one of these, encrypted — not a bare token. The
|
|
5
|
+
* database knows nothing about auth types, so the discriminator travels with
|
|
6
|
+
* the secret rather than sitting in a column, and a provider that needs
|
|
7
|
+
* different fields needs no migration.
|
|
8
|
+
*/
|
|
9
|
+
export const ENVELOPE_VERSION = 1;
|
|
10
|
+
export class InvalidEnvelopeError extends Error {
|
|
11
|
+
constructor(reason) {
|
|
12
|
+
super(`Stored credential is unusable: ${reason}`);
|
|
13
|
+
this.name = 'InvalidEnvelopeError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Rejects rather than guesses. A credential we cannot read is a connection the
|
|
18
|
+
* end user must redo, and that is a better outcome than sending a provider
|
|
19
|
+
* something we mis-parsed.
|
|
20
|
+
*/
|
|
21
|
+
export function parseEnvelope(json) {
|
|
22
|
+
let value;
|
|
23
|
+
try {
|
|
24
|
+
value = JSON.parse(json);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
throw new InvalidEnvelopeError('not JSON');
|
|
28
|
+
}
|
|
29
|
+
if (typeof value !== 'object' || value === null) {
|
|
30
|
+
throw new InvalidEnvelopeError('not an object');
|
|
31
|
+
}
|
|
32
|
+
const envelope = value;
|
|
33
|
+
if (envelope.v !== ENVELOPE_VERSION) {
|
|
34
|
+
throw new InvalidEnvelopeError(`version ${String(envelope.v)} is not supported, expected ${ENVELOPE_VERSION}`);
|
|
35
|
+
}
|
|
36
|
+
switch (envelope.type) {
|
|
37
|
+
case 'oauth2':
|
|
38
|
+
if (!isNonEmptyString(envelope.accessToken)) {
|
|
39
|
+
throw new InvalidEnvelopeError('oauth2 envelope has no accessToken');
|
|
40
|
+
}
|
|
41
|
+
return envelope;
|
|
42
|
+
case 'api_key':
|
|
43
|
+
if (!isNonEmptyString(envelope.key)) {
|
|
44
|
+
throw new InvalidEnvelopeError('api_key envelope has no key');
|
|
45
|
+
}
|
|
46
|
+
return envelope;
|
|
47
|
+
case 'app':
|
|
48
|
+
if (!isNonEmptyString(envelope.installationId)) {
|
|
49
|
+
throw new InvalidEnvelopeError('app envelope has no installationId');
|
|
50
|
+
}
|
|
51
|
+
return envelope;
|
|
52
|
+
case 'oauth2_cc':
|
|
53
|
+
return envelope;
|
|
54
|
+
default:
|
|
55
|
+
throw new InvalidEnvelopeError(`unknown type "${String(envelope.type)}"`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The expiry to mirror into `account.accessTokenExpiresAt`, so the refresh
|
|
60
|
+
* sweep can find expiring credentials without decrypting any of them.
|
|
61
|
+
*/
|
|
62
|
+
export function expiryOf(envelope) {
|
|
63
|
+
if (envelope.type !== 'oauth2' || !envelope.expiresAt)
|
|
64
|
+
return null;
|
|
65
|
+
const expiry = new Date(envelope.expiresAt);
|
|
66
|
+
return Number.isNaN(expiry.getTime()) ? null : expiry;
|
|
67
|
+
}
|
|
68
|
+
function isNonEmptyString(value) {
|
|
69
|
+
return typeof value === 'string' && value.length > 0;
|
|
70
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ResolvedKoshaConfig } from '../config/kosha-config.js';
|
|
2
|
+
import { type CredentialEnvelope } from './credential-envelope.js';
|
|
2
3
|
export declare class MissingEncryptionKeyError extends Error {
|
|
3
4
|
constructor();
|
|
4
5
|
}
|
|
@@ -16,6 +17,13 @@ export declare class CryptoService {
|
|
|
16
17
|
/** `iv.authTag.ciphertext`, each part base64. */
|
|
17
18
|
encrypt(plaintext: string): string;
|
|
18
19
|
decrypt(payload: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* A credential goes to rest as an encrypted envelope carrying its own type
|
|
22
|
+
* and version, so the column it lives in needs to know neither.
|
|
23
|
+
*/
|
|
24
|
+
sealEnvelope(envelope: CredentialEnvelope): string;
|
|
25
|
+
/** Throws rather than returning a half-understood credential. */
|
|
26
|
+
openEnvelope(payload: string): CredentialEnvelope;
|
|
19
27
|
private requireKey;
|
|
20
28
|
}
|
|
21
29
|
//# sourceMappingURL=crypto.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.service.d.ts","sourceRoot":"","sources":["../../src/crypto/crypto.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"crypto.service.d.ts","sourceRoot":"","sources":["../../src/crypto/crypto.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAMlC,qBAAa,yBAA0B,SAAQ,KAAK;;CAOnD;AAED;;;;;;GAMG;AACH,qBACa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAS;gBAEI,MAAM,EAAE,mBAAmB;IAgB7D,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,iDAAiD;IACjD,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAgBlC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAoBhC;;;OAGG;IACH,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM;IAIlD,iEAAiE;IACjE,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB;IAIjD,OAAO,CAAC,UAAU;CAInB"}
|
|
@@ -2,6 +2,7 @@ import { __decorate, __metadata, __param } from "tslib";
|
|
|
2
2
|
import { Inject, Injectable } from '@nestjs/common';
|
|
3
3
|
import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto';
|
|
4
4
|
import { KOSHA_CONFIG } from '../config/tokens.js';
|
|
5
|
+
import { parseEnvelope, } from './credential-envelope.js';
|
|
5
6
|
const ALGORITHM = 'aes-256-gcm';
|
|
6
7
|
const IV_LENGTH = 12;
|
|
7
8
|
const KEY_LENGTH = 32;
|
|
@@ -63,6 +64,17 @@ let CryptoService = class CryptoService {
|
|
|
63
64
|
decipher.final(),
|
|
64
65
|
]).toString('utf8');
|
|
65
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* A credential goes to rest as an encrypted envelope carrying its own type
|
|
69
|
+
* and version, so the column it lives in needs to know neither.
|
|
70
|
+
*/
|
|
71
|
+
sealEnvelope(envelope) {
|
|
72
|
+
return this.encrypt(JSON.stringify(envelope));
|
|
73
|
+
}
|
|
74
|
+
/** Throws rather than returning a half-understood credential. */
|
|
75
|
+
openEnvelope(payload) {
|
|
76
|
+
return parseEnvelope(this.decrypt(payload));
|
|
77
|
+
}
|
|
66
78
|
requireKey() {
|
|
67
79
|
if (!this.key)
|
|
68
80
|
throw new MissingEncryptionKeyError();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mint-grant.dto.d.ts","sourceRoot":"","sources":["../../../src/egress/dto/mint-grant.dto.ts"],"names":[],"mappings":"AAUA,qBAAa,YAAY;IASvB,cAAc,EAAG,MAAM,CAAC;IAUxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAOxB,SAAS,EAAG,MAAM,CAAC;IAMnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
3
|
+
import { IsArray, IsDateString, IsOptional, IsString, MaxLength, MinLength, } from 'class-validator';
|
|
4
|
+
export class MintGrantDto {
|
|
5
|
+
externalUserId;
|
|
6
|
+
providerKeys;
|
|
7
|
+
expiresAt;
|
|
8
|
+
label;
|
|
9
|
+
}
|
|
10
|
+
__decorate([
|
|
11
|
+
ApiProperty({
|
|
12
|
+
example: 'user_9',
|
|
13
|
+
description: 'The app’s own id for the person whose credentials are borrowed.',
|
|
14
|
+
}),
|
|
15
|
+
IsString(),
|
|
16
|
+
MinLength(1),
|
|
17
|
+
MaxLength(255),
|
|
18
|
+
__metadata("design:type", String)
|
|
19
|
+
], MintGrantDto.prototype, "externalUserId", void 0);
|
|
20
|
+
__decorate([
|
|
21
|
+
ApiPropertyOptional({
|
|
22
|
+
example: ['github'],
|
|
23
|
+
description: 'Narrows the grant to these integrations. Omit for every provider this person has connected.',
|
|
24
|
+
}),
|
|
25
|
+
IsOptional(),
|
|
26
|
+
IsArray(),
|
|
27
|
+
IsString({ each: true }),
|
|
28
|
+
__metadata("design:type", Array)
|
|
29
|
+
], MintGrantDto.prototype, "providerKeys", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
ApiProperty({
|
|
32
|
+
example: '2026-10-01T12:00:00.000Z',
|
|
33
|
+
description: 'When the grant dies. At most 25 hours away.',
|
|
34
|
+
}),
|
|
35
|
+
IsDateString(),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], MintGrantDto.prototype, "expiresAt", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
ApiPropertyOptional({ description: 'For reading a grant list later.' }),
|
|
40
|
+
IsOptional(),
|
|
41
|
+
IsString(),
|
|
42
|
+
MaxLength(200),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], MintGrantDto.prototype, "label", void 0);
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { type ApiKeyRequest } from '../auth/api-key.guard.js';
|
|
2
|
+
import { MintGrantDto } from './dto/mint-grant.dto.js';
|
|
2
3
|
import { GrantsService } from './grants.service.js';
|
|
3
|
-
export interface MintGrantBody {
|
|
4
|
-
endUserExternalId?: string;
|
|
5
|
-
/** Narrows the grant. Omit for every provider this end user has connected. */
|
|
6
|
-
providerKeys?: string[];
|
|
7
|
-
expiresAt?: string;
|
|
8
|
-
label?: string;
|
|
9
|
-
}
|
|
10
4
|
/**
|
|
11
5
|
* Minting and revoking egress grants. `ApiKeyGuard` rather than `OrgAuthGuard`
|
|
12
6
|
* because handing a sandbox an identity is an errand for an app's backend, not
|
|
@@ -15,7 +9,7 @@ export interface MintGrantBody {
|
|
|
15
9
|
export declare class EgressController {
|
|
16
10
|
private readonly grants;
|
|
17
11
|
constructor(grants: GrantsService);
|
|
18
|
-
mint(request: ApiKeyRequest, body:
|
|
12
|
+
mint(request: ApiKeyRequest, body: MintGrantDto): Promise<import("./grants.service.js").MintedGrant>;
|
|
19
13
|
revoke(request: ApiKeyRequest, id: string): Promise<{
|
|
20
14
|
grantId: string;
|
|
21
15
|
revoked: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"egress.controller.d.ts","sourceRoot":"","sources":["../../src/egress/egress.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"egress.controller.d.ts","sourceRoot":"","sources":["../../src/egress/egress.controller.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;GAIG;AACH,qBAKa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAe5C,IAAI,CAAQ,OAAO,EAAE,aAAa,EAAU,IAAI,EAAE,YAAY;IAoB9D,MAAM,CAAQ,OAAO,EAAE,aAAa,EAAe,EAAE,EAAE,MAAM;;;;CAIpE"}
|