@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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
3
|
+
import { IsObject, IsOptional, IsString, MaxLength, MinLength, } from 'class-validator';
|
|
4
|
+
export class UpdateConfigurationDto {
|
|
5
|
+
name;
|
|
6
|
+
credentials;
|
|
7
|
+
}
|
|
8
|
+
__decorate([
|
|
9
|
+
ApiPropertyOptional({ example: 'GitHub' }),
|
|
10
|
+
IsOptional(),
|
|
11
|
+
IsString(),
|
|
12
|
+
MinLength(1),
|
|
13
|
+
MaxLength(64),
|
|
14
|
+
__metadata("design:type", String)
|
|
15
|
+
], UpdateConfigurationDto.prototype, "name", void 0);
|
|
16
|
+
__decorate([
|
|
17
|
+
ApiPropertyOptional({
|
|
18
|
+
description: 'Replaces the stored secrets. Omit to leave them alone.',
|
|
19
|
+
}),
|
|
20
|
+
IsOptional(),
|
|
21
|
+
IsObject(),
|
|
22
|
+
__metadata("design:type", Object)
|
|
23
|
+
], UpdateConfigurationDto.prototype, "credentials", void 0);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type UserSession } from '@thallesp/nestjs-better-auth';
|
|
2
2
|
import type { Response } from 'express';
|
|
3
3
|
import { type ApiKeyRequest } from '../auth/api-key.guard.js';
|
|
4
|
-
import { ConnectService
|
|
4
|
+
import { ConnectService } from './connect.service.js';
|
|
5
|
+
import { CreateConnectSessionDto } from './dto/create-connect-session.dto.js';
|
|
6
|
+
import { CreateTestSessionDto } from './dto/create-test-session.dto.js';
|
|
5
7
|
export declare class ConnectController {
|
|
6
8
|
private readonly connect;
|
|
7
9
|
private readonly logger;
|
|
@@ -12,20 +14,16 @@ export declare class ConnectController {
|
|
|
12
14
|
* session. `AllowAnonymous` disables the session guard so `OrgAuthGuard`
|
|
13
15
|
* can authenticate either way.
|
|
14
16
|
*/
|
|
15
|
-
createSession(request: ApiKeyRequest, body:
|
|
17
|
+
createSession(request: ApiKeyRequest, body: CreateConnectSessionDto): Promise<import("./connect.service.js").ConnectSessionResult>;
|
|
16
18
|
/**
|
|
17
19
|
* Admin-only: runs the same flow with the signed-in admin standing in for an
|
|
18
20
|
* end user, so an operator can verify a configuration without wiring up
|
|
19
21
|
* their backend first.
|
|
20
22
|
*/
|
|
21
|
-
createTestSession(session: UserSession, body:
|
|
22
|
-
configurationId?: string;
|
|
23
|
-
slug?: string;
|
|
24
|
-
redirectUrl?: string;
|
|
25
|
-
}): Promise<import("./connect.service.js").ConnectSessionResult>;
|
|
23
|
+
createTestSession(session: UserSession, environmentId: string, body: CreateTestSessionDto): Promise<import("./connect.service.js").ConnectSessionResult>;
|
|
26
24
|
/** The URL the end user's browser opens. Redirects to the provider. */
|
|
27
25
|
start(token: string, res: Response): Promise<void>;
|
|
28
26
|
/** Where the provider sends the end user back. */
|
|
29
|
-
callback(
|
|
27
|
+
callback(provider: string, code: string | undefined, state: string | undefined, providerError: string | undefined, providerErrorDescription: string | undefined, res: Response): Promise<void>;
|
|
30
28
|
}
|
|
31
29
|
//# sourceMappingURL=connect.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.controller.d.ts","sourceRoot":"","sources":["../../src/connect/connect.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.controller.d.ts","sourceRoot":"","sources":["../../src/connect/connect.controller.ts"],"names":[],"mappings":"AAsBA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,KAAK,aAAa,EAAgB,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,qBAEa,iBAAiB;IAGhB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;gBAEhC,OAAO,EAAE,cAAc;IAEpD;;;;;OAKG;IAcH,aAAa,CACJ,OAAO,EAAE,aAAa,EACrB,IAAI,EAAE,uBAAuB;IAevC;;;;OAIG;IAOH,iBAAiB,CACJ,OAAO,EAAE,WAAW,EACP,aAAa,EAAE,MAAM,EACrC,IAAI,EAAE,oBAAoB;IAepC,uEAAuE;IAIjE,KAAK,CAAiB,KAAK,EAAE,MAAM,EAAS,GAAG,EAAE,QAAQ;IAY/D,kDAAkD;IAI5C,QAAQ,CACO,QAAQ,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,GAAG,SAAS,EACvB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,aAAa,EAAE,MAAM,GAAG,SAAS,EACrB,wBAAwB,EAAE,MAAM,GAAG,SAAS,EACjE,GAAG,EAAE,QAAQ;CAuDvB"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
var ConnectController_1;
|
|
2
2
|
import { __decorate, __metadata, __param } from "tslib";
|
|
3
|
-
import { BadRequestException, Body, Controller, Get, Logger, Param, Post, Query, Req, Res, UseGuards, } from '@nestjs/common';
|
|
3
|
+
import { BadRequestException, ConflictException, Body, Controller, Get, Logger, Param, Post, Query, Req, Res, UseGuards, } from '@nestjs/common';
|
|
4
|
+
import { ApiBadRequestResponse, ApiCreatedResponse, ApiExcludeEndpoint, ApiOperation, ApiSecurity, ApiTags, } from '@nestjs/swagger';
|
|
4
5
|
import { AllowAnonymous, Session, } from '@thallesp/nestjs-better-auth';
|
|
5
6
|
import { OrgAuthGuard } from '../auth/api-key.guard.js';
|
|
6
7
|
import { getActiveOrganizationId } from '../common/active-organization.js';
|
|
7
|
-
import { ConnectService
|
|
8
|
+
import { ConnectService } from './connect.service.js';
|
|
9
|
+
import { CreateConnectSessionDto } from './dto/create-connect-session.dto.js';
|
|
10
|
+
import { CreateTestSessionDto } from './dto/create-test-session.dto.js';
|
|
8
11
|
let ConnectController = ConnectController_1 = class ConnectController {
|
|
9
12
|
connect;
|
|
10
13
|
logger = new Logger(ConnectController_1.name);
|
|
@@ -18,16 +21,20 @@ let ConnectController = ConnectController_1 = class ConnectController {
|
|
|
18
21
|
* can authenticate either way.
|
|
19
22
|
*/
|
|
20
23
|
createSession(request, body) {
|
|
21
|
-
|
|
24
|
+
if (!request.environmentId) {
|
|
25
|
+
throw new BadRequestException('This route needs an API key, which is what names the environment');
|
|
26
|
+
}
|
|
27
|
+
return this.connect.createSession(request.organizationId, request.environmentId, body);
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
30
|
* Admin-only: runs the same flow with the signed-in admin standing in for an
|
|
25
31
|
* end user, so an operator can verify a configuration without wiring up
|
|
26
32
|
* their backend first.
|
|
27
33
|
*/
|
|
28
|
-
createTestSession(session, body) {
|
|
29
|
-
return this.connect.createSession(getActiveOrganizationId(session), {
|
|
30
|
-
|
|
34
|
+
createTestSession(session, environmentId, body) {
|
|
35
|
+
return this.connect.createSession(getActiveOrganizationId(session), environmentId, {
|
|
36
|
+
externalUserId: `kosha-admin:${session.user.id}`,
|
|
37
|
+
provider: body.provider,
|
|
31
38
|
configurationId: body?.configurationId,
|
|
32
39
|
configurationSlug: body?.slug,
|
|
33
40
|
redirectUrl: body?.redirectUrl,
|
|
@@ -45,7 +52,7 @@ let ConnectController = ConnectController_1 = class ConnectController {
|
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
54
|
/** Where the provider sends the end user back. */
|
|
48
|
-
async callback(
|
|
55
|
+
async callback(provider, code, state, providerError, providerErrorDescription, res) {
|
|
49
56
|
if (providerError || providerErrorDescription) {
|
|
50
57
|
res
|
|
51
58
|
.status(400)
|
|
@@ -59,7 +66,7 @@ let ConnectController = ConnectController_1 = class ConnectController {
|
|
|
59
66
|
return;
|
|
60
67
|
}
|
|
61
68
|
try {
|
|
62
|
-
const { redirectUrl } = await this.connect.handleCallback(
|
|
69
|
+
const { redirectUrl } = await this.connect.handleCallback(provider, code, state);
|
|
63
70
|
if (redirectUrl) {
|
|
64
71
|
const url = new URL(redirectUrl);
|
|
65
72
|
url.searchParams.set('kosha_status', 'success');
|
|
@@ -69,7 +76,14 @@ let ConnectController = ConnectController_1 = class ConnectController {
|
|
|
69
76
|
res.send('Connected. You can close this window.');
|
|
70
77
|
}
|
|
71
78
|
catch (error) {
|
|
72
|
-
this.logger.warn(`Connect callback failed for "${
|
|
79
|
+
this.logger.warn(`Connect callback failed for "${provider}": ${error instanceof Error ? error.message : error}`);
|
|
80
|
+
// A conflict is worth saying out loud: somebody is already connected,
|
|
81
|
+
// and the end user can do something about it. Everything else stays
|
|
82
|
+
// vague, since this URL is reached by a browser we do not trust.
|
|
83
|
+
if (error instanceof ConflictException) {
|
|
84
|
+
res.status(409).send(error.message);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
73
87
|
res
|
|
74
88
|
.status(400)
|
|
75
89
|
.send(error instanceof BadRequestException
|
|
@@ -82,23 +96,38 @@ __decorate([
|
|
|
82
96
|
Post('sessions'),
|
|
83
97
|
AllowAnonymous(),
|
|
84
98
|
UseGuards(OrgAuthGuard),
|
|
99
|
+
ApiSecurity('x-api-key'),
|
|
100
|
+
ApiOperation({
|
|
101
|
+
summary: 'Start a connect flow for one of the app’s users',
|
|
102
|
+
description: 'The environment comes from the API key. Name the provider and the configuration slug it was set up under.',
|
|
103
|
+
}),
|
|
104
|
+
ApiCreatedResponse({ description: 'A connect URL and when it expires.' }),
|
|
105
|
+
ApiBadRequestResponse({
|
|
106
|
+
description: 'Unknown configuration, or no environment on the key.',
|
|
107
|
+
}),
|
|
85
108
|
__param(0, Req()),
|
|
86
109
|
__param(1, Body()),
|
|
87
110
|
__metadata("design:type", Function),
|
|
88
|
-
__metadata("design:paramtypes", [Object,
|
|
111
|
+
__metadata("design:paramtypes", [Object, CreateConnectSessionDto]),
|
|
89
112
|
__metadata("design:returntype", void 0)
|
|
90
113
|
], ConnectController.prototype, "createSession", null);
|
|
91
114
|
__decorate([
|
|
92
|
-
Post('sessions/test'),
|
|
115
|
+
Post('sessions/test/:environmentId'),
|
|
116
|
+
ApiOperation({
|
|
117
|
+
summary: 'Run the same flow as the signed-in admin',
|
|
118
|
+
description: 'For verifying a configuration before the consuming app is wired up.',
|
|
119
|
+
}),
|
|
93
120
|
__param(0, Session()),
|
|
94
|
-
__param(1,
|
|
121
|
+
__param(1, Param('environmentId')),
|
|
122
|
+
__param(2, Body()),
|
|
95
123
|
__metadata("design:type", Function),
|
|
96
|
-
__metadata("design:paramtypes", [Object,
|
|
124
|
+
__metadata("design:paramtypes", [Object, String, CreateTestSessionDto]),
|
|
97
125
|
__metadata("design:returntype", void 0)
|
|
98
126
|
], ConnectController.prototype, "createTestSession", null);
|
|
99
127
|
__decorate([
|
|
100
128
|
Get(':token/start'),
|
|
101
129
|
AllowAnonymous(),
|
|
130
|
+
ApiExcludeEndpoint(),
|
|
102
131
|
__param(0, Param('token')),
|
|
103
132
|
__param(1, Res()),
|
|
104
133
|
__metadata("design:type", Function),
|
|
@@ -106,9 +135,10 @@ __decorate([
|
|
|
106
135
|
__metadata("design:returntype", Promise)
|
|
107
136
|
], ConnectController.prototype, "start", null);
|
|
108
137
|
__decorate([
|
|
109
|
-
Get('callback/:
|
|
138
|
+
Get('callback/:provider'),
|
|
110
139
|
AllowAnonymous(),
|
|
111
|
-
|
|
140
|
+
ApiExcludeEndpoint(),
|
|
141
|
+
__param(0, Param('provider')),
|
|
112
142
|
__param(1, Query('code')),
|
|
113
143
|
__param(2, Query('state')),
|
|
114
144
|
__param(3, Query('error')),
|
|
@@ -119,6 +149,7 @@ __decorate([
|
|
|
119
149
|
__metadata("design:returntype", Promise)
|
|
120
150
|
], ConnectController.prototype, "callback", null);
|
|
121
151
|
ConnectController = ConnectController_1 = __decorate([
|
|
152
|
+
ApiTags('connect'),
|
|
122
153
|
Controller('connect'),
|
|
123
154
|
__metadata("design:paramtypes", [ConnectService])
|
|
124
155
|
], ConnectController);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.module.d.ts","sourceRoot":"","sources":["../../src/connect/connect.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.module.d.ts","sourceRoot":"","sources":["../../src/connect/connect.module.ts"],"names":[],"mappings":"AAMA,qBAMa,aAAa;CAAG"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { Module } from '@nestjs/common';
|
|
3
|
-
import {
|
|
3
|
+
import { EnvironmentsModule } from '../environments/environments.module.js';
|
|
4
4
|
import { ConnectController } from './connect.controller.js';
|
|
5
|
+
import { ConnectRepository } from './connect.repository.js';
|
|
5
6
|
import { ConnectService } from './connect.service.js';
|
|
6
7
|
let ConnectModule = class ConnectModule {
|
|
7
8
|
};
|
|
8
9
|
ConnectModule = __decorate([
|
|
9
10
|
Module({
|
|
10
|
-
imports: [
|
|
11
|
+
imports: [EnvironmentsModule],
|
|
11
12
|
controllers: [ConnectController],
|
|
12
|
-
providers: [ConnectService],
|
|
13
|
+
providers: [ConnectService, ConnectRepository],
|
|
13
14
|
exports: [ConnectService],
|
|
14
15
|
})
|
|
15
16
|
], ConnectModule);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Account, Prisma, User } from '../generated/prisma/client.js';
|
|
2
|
+
import { PrismaService } from '../prisma/prisma.service.js';
|
|
3
|
+
/**
|
|
4
|
+
* What a connect flow remembers between the link being handed out and the
|
|
5
|
+
* provider sending the end user back. Lives in `verification`, which is Better
|
|
6
|
+
* Auth's own key/value store, so there is no table of ours for it.
|
|
7
|
+
*/
|
|
8
|
+
export interface ConnectState {
|
|
9
|
+
organizationId: string;
|
|
10
|
+
environmentId: string;
|
|
11
|
+
environmentSlug: string;
|
|
12
|
+
/** Which provider's tables this flow writes to. */
|
|
13
|
+
provider: string;
|
|
14
|
+
configurationId: string;
|
|
15
|
+
externalUserId: string;
|
|
16
|
+
redirectUrl?: string | null;
|
|
17
|
+
/** PKCE, present only once the authorization URL has been built. */
|
|
18
|
+
codeVerifier?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface StoreCredentialInput {
|
|
21
|
+
userId: string;
|
|
22
|
+
/** The provider, which is what Better Auth means by `providerId`. */
|
|
23
|
+
provider: string;
|
|
24
|
+
/** The provider's own id for the account. */
|
|
25
|
+
accountId: string;
|
|
26
|
+
/** Already an encrypted envelope by the time it arrives here. */
|
|
27
|
+
accessToken: string;
|
|
28
|
+
accessTokenExpiresAt: Date | null;
|
|
29
|
+
/** What the provider granted, which can be less than was asked for. */
|
|
30
|
+
scope: string | null;
|
|
31
|
+
}
|
|
32
|
+
export declare class ConnectRepository {
|
|
33
|
+
private readonly prisma;
|
|
34
|
+
constructor(prisma: PrismaService);
|
|
35
|
+
putSession(token: string, state: ConnectState, expiresAt: Date): Promise<void>;
|
|
36
|
+
takeSession(token: string): Promise<ConnectState | null>;
|
|
37
|
+
putState(state: string, payload: ConnectState, expiresAt: Date): Promise<void>;
|
|
38
|
+
takeState(state: string): Promise<ConnectState | null>;
|
|
39
|
+
/** Nothing else sweeps these, so the connect flow has to. */
|
|
40
|
+
deleteExpired(now?: Date): Promise<number>;
|
|
41
|
+
/**
|
|
42
|
+
* The person a credential belongs to. `email` is derived and carries the
|
|
43
|
+
* environment, which is what keeps the same person in sandbox and production
|
|
44
|
+
* as two rows without a second scope column.
|
|
45
|
+
*/
|
|
46
|
+
upsertEndUser(environmentSlug: string, externalUserId: string): Promise<User>;
|
|
47
|
+
/**
|
|
48
|
+
* Writes the credential and lets the provider record its own connection in
|
|
49
|
+
* the same transaction, so a credential nothing points at cannot exist.
|
|
50
|
+
*/
|
|
51
|
+
storeCredential(input: StoreCredentialInput, link: (tx: Prisma.TransactionClient, accountId: string) => Promise<unknown>): Promise<Account>;
|
|
52
|
+
updateCredential(id: string, changes: {
|
|
53
|
+
accountId?: string;
|
|
54
|
+
accessToken: string;
|
|
55
|
+
accessTokenExpiresAt: Date | null;
|
|
56
|
+
/** Rewritten on refresh: a provider may report a different grant. */
|
|
57
|
+
scope?: string | null;
|
|
58
|
+
}): Promise<Account>;
|
|
59
|
+
private take;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Better Auth requires `user.email` to be present and unique, while an end
|
|
63
|
+
* user exists per environment. The derived form encodes both, so the same
|
|
64
|
+
* person in sandbox and production is two rows rather than a unique violation.
|
|
65
|
+
*
|
|
66
|
+
* `.internal` is reserved for private use, so the address can never resolve or
|
|
67
|
+
* receive mail — an end user has none to store.
|
|
68
|
+
*/
|
|
69
|
+
export declare function derivedEmail(environmentSlug: string, externalUserId: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Gets the app's user id back out of a stored email, the reverse of
|
|
72
|
+
* {@link derivedEmail}: `production.user_9@kosha.internal` → `user_9`.
|
|
73
|
+
*
|
|
74
|
+
* Uses `derivedEmail` to know what comes before and after the id, so a change
|
|
75
|
+
* to the email format cannot break it.
|
|
76
|
+
*/
|
|
77
|
+
export declare function externalUserIdOf(environmentSlug: string, email: string): string;
|
|
78
|
+
//# sourceMappingURL=connect.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect.repository.d.ts","sourceRoot":"","sources":["../../src/connect/connect.repository.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AASD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,IAAI,GAAG,IAAI,CAAC;IAClC,uEAAuE;IACvE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,qBACa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAE5C,UAAU,CACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,IAAI,GACd,OAAO,CAAC,IAAI,CAAC;IAWhB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAIlD,QAAQ,CACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,IAAI,GACd,OAAO,CAAC,IAAI,CAAC;IAWhB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAItD,6DAA6D;IACvD,aAAa,CAAC,GAAG,OAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAatD;;;;OAIG;IACG,aAAa,CACjB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC;IAYhB;;;OAGG;IACH,eAAe,CACb,KAAK,EAAE,oBAAoB,EAC3B,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,iBAAiB,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAC1E,OAAO,CAAC,OAAO,CAAC;IAmBnB,gBAAgB,CACd,EAAE,EAAE,MAAM,EACV,OAAO,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,oBAAoB,EAAE,IAAI,GAAG,IAAI,CAAC;QAClC,qEAAqE;QACrE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,GACA,OAAO,CAAC,OAAO,CAAC;YAIL,IAAI;CAanB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE,MAAM,GACZ,MAAM,CAGR"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { PrismaService } from '../prisma/prisma.service.js';
|
|
5
|
+
/**
|
|
6
|
+
* Namespaced, because `verification` is shared with email verification and
|
|
7
|
+
* password reset.
|
|
8
|
+
*/
|
|
9
|
+
const SESSION_PREFIX = 'kosha:connect:';
|
|
10
|
+
const STATE_PREFIX = 'kosha:state:';
|
|
11
|
+
let ConnectRepository = class ConnectRepository {
|
|
12
|
+
prisma;
|
|
13
|
+
constructor(prisma) {
|
|
14
|
+
this.prisma = prisma;
|
|
15
|
+
}
|
|
16
|
+
async putSession(token, state, expiresAt) {
|
|
17
|
+
await this.prisma.verification.create({
|
|
18
|
+
data: {
|
|
19
|
+
id: randomUUID(),
|
|
20
|
+
identifier: `${SESSION_PREFIX}${token}`,
|
|
21
|
+
value: JSON.stringify(state),
|
|
22
|
+
expiresAt,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
takeSession(token) {
|
|
27
|
+
return this.take(`${SESSION_PREFIX}${token}`);
|
|
28
|
+
}
|
|
29
|
+
async putState(state, payload, expiresAt) {
|
|
30
|
+
await this.prisma.verification.create({
|
|
31
|
+
data: {
|
|
32
|
+
id: randomUUID(),
|
|
33
|
+
identifier: `${STATE_PREFIX}${state}`,
|
|
34
|
+
value: JSON.stringify(payload),
|
|
35
|
+
expiresAt,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
takeState(state) {
|
|
40
|
+
return this.take(`${STATE_PREFIX}${state}`);
|
|
41
|
+
}
|
|
42
|
+
/** Nothing else sweeps these, so the connect flow has to. */
|
|
43
|
+
async deleteExpired(now = new Date()) {
|
|
44
|
+
const { count } = await this.prisma.verification.deleteMany({
|
|
45
|
+
where: {
|
|
46
|
+
expiresAt: { lt: now },
|
|
47
|
+
OR: [
|
|
48
|
+
{ identifier: { startsWith: SESSION_PREFIX } },
|
|
49
|
+
{ identifier: { startsWith: STATE_PREFIX } },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
return count;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The person a credential belongs to. `email` is derived and carries the
|
|
57
|
+
* environment, which is what keeps the same person in sandbox and production
|
|
58
|
+
* as two rows without a second scope column.
|
|
59
|
+
*/
|
|
60
|
+
async upsertEndUser(environmentSlug, externalUserId) {
|
|
61
|
+
const email = derivedEmail(environmentSlug, externalUserId);
|
|
62
|
+
return this.prisma.user.upsert({
|
|
63
|
+
where: { email },
|
|
64
|
+
create: { email, name: externalUserId, emailVerified: false },
|
|
65
|
+
// Nothing of ours lives on this row, so a second connect by the same
|
|
66
|
+
// person has nothing to write.
|
|
67
|
+
update: {},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Writes the credential and lets the provider record its own connection in
|
|
72
|
+
* the same transaction, so a credential nothing points at cannot exist.
|
|
73
|
+
*/
|
|
74
|
+
storeCredential(input, link) {
|
|
75
|
+
return this.prisma.$transaction(async (tx) => {
|
|
76
|
+
const account = await tx.account.create({
|
|
77
|
+
data: {
|
|
78
|
+
id: randomUUID(),
|
|
79
|
+
userId: input.userId,
|
|
80
|
+
providerId: input.provider,
|
|
81
|
+
accountId: input.accountId,
|
|
82
|
+
accessToken: input.accessToken,
|
|
83
|
+
accessTokenExpiresAt: input.accessTokenExpiresAt,
|
|
84
|
+
scope: input.scope,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
await link(tx, account.id);
|
|
88
|
+
return account;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
updateCredential(id, changes) {
|
|
92
|
+
return this.prisma.account.update({ where: { id }, data: changes });
|
|
93
|
+
}
|
|
94
|
+
async take(identifier) {
|
|
95
|
+
const row = await this.prisma.verification.findFirst({
|
|
96
|
+
where: { identifier },
|
|
97
|
+
});
|
|
98
|
+
if (!row)
|
|
99
|
+
return null;
|
|
100
|
+
// Burnt before any network work, so a replayed callback cannot mint a
|
|
101
|
+
// second credential.
|
|
102
|
+
await this.prisma.verification.delete({ where: { id: row.id } });
|
|
103
|
+
if (row.expiresAt < new Date())
|
|
104
|
+
return null;
|
|
105
|
+
return JSON.parse(row.value);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
ConnectRepository = __decorate([
|
|
109
|
+
Injectable(),
|
|
110
|
+
__metadata("design:paramtypes", [PrismaService])
|
|
111
|
+
], ConnectRepository);
|
|
112
|
+
export { ConnectRepository };
|
|
113
|
+
/**
|
|
114
|
+
* Better Auth requires `user.email` to be present and unique, while an end
|
|
115
|
+
* user exists per environment. The derived form encodes both, so the same
|
|
116
|
+
* person in sandbox and production is two rows rather than a unique violation.
|
|
117
|
+
*
|
|
118
|
+
* `.internal` is reserved for private use, so the address can never resolve or
|
|
119
|
+
* receive mail — an end user has none to store.
|
|
120
|
+
*/
|
|
121
|
+
export function derivedEmail(environmentSlug, externalUserId) {
|
|
122
|
+
return `${environmentSlug}.${externalUserId}@kosha.internal`;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Gets the app's user id back out of a stored email, the reverse of
|
|
126
|
+
* {@link derivedEmail}: `production.user_9@kosha.internal` → `user_9`.
|
|
127
|
+
*
|
|
128
|
+
* Uses `derivedEmail` to know what comes before and after the id, so a change
|
|
129
|
+
* to the email format cannot break it.
|
|
130
|
+
*/
|
|
131
|
+
export function externalUserIdOf(environmentSlug, email) {
|
|
132
|
+
const [prefix, suffix] = derivedEmail(environmentSlug, '\0').split('\0');
|
|
133
|
+
return email.slice(prefix.length, email.length - suffix.length);
|
|
134
|
+
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import type { TokenSet } from '@kosha-ai/integration-sdk';
|
|
2
2
|
import type { ResolvedKoshaConfig } from '../config/kosha-config.js';
|
|
3
|
-
import { ConfigurationsService } from '../configurations/configurations.service.js';
|
|
4
3
|
import { CryptoService } from '../crypto/crypto.service.js';
|
|
4
|
+
import { EnvironmentsService } from '../environments/environments.service.js';
|
|
5
5
|
import { IntegrationRegistry } from '../integrations/integration.registry.js';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
configurationId?: string;
|
|
10
|
-
configurationSlug?: string;
|
|
11
|
-
redirectUrl?: string;
|
|
12
|
-
}
|
|
6
|
+
import { ProviderStore } from '../integrations/provider-store.js';
|
|
7
|
+
import { ConnectRepository } from './connect.repository.js';
|
|
8
|
+
import type { CreateConnectSessionDto } from './dto/create-connect-session.dto.js';
|
|
13
9
|
export interface ConnectSessionResult {
|
|
14
10
|
token: string;
|
|
15
11
|
connectUrl: string;
|
|
@@ -21,34 +17,46 @@ export interface CallbackResult {
|
|
|
21
17
|
}
|
|
22
18
|
/**
|
|
23
19
|
* Drives the OAuth handshake that turns an end user's consent into a stored,
|
|
24
|
-
* encrypted
|
|
20
|
+
* encrypted credential.
|
|
25
21
|
*
|
|
26
22
|
* Providers are resolved through {@link IntegrationRegistry}, so nothing here
|
|
27
23
|
* knows what GitHub or Slack are.
|
|
28
24
|
*/
|
|
29
25
|
export declare class ConnectService {
|
|
30
|
-
private readonly
|
|
26
|
+
private readonly connect;
|
|
31
27
|
private readonly crypto;
|
|
32
|
-
private readonly
|
|
28
|
+
private readonly store;
|
|
29
|
+
private readonly environments;
|
|
33
30
|
private readonly registry;
|
|
34
31
|
private readonly config;
|
|
35
32
|
private readonly logger;
|
|
36
|
-
constructor(
|
|
33
|
+
constructor(connect: ConnectRepository, crypto: CryptoService, store: ProviderStore, environments: EnvironmentsService, registry: IntegrationRegistry, config: ResolvedKoshaConfig);
|
|
37
34
|
/**
|
|
38
|
-
* Called by the
|
|
39
|
-
*
|
|
35
|
+
* Called by the consuming app's backend to start a connect flow for one of
|
|
36
|
+
* its users. The environment comes from the API key, never from the body.
|
|
40
37
|
*/
|
|
41
|
-
createSession(organizationId: string, input:
|
|
38
|
+
createSession(organizationId: string, environmentId: string, input: CreateConnectSessionDto): Promise<ConnectSessionResult>;
|
|
42
39
|
/**
|
|
43
|
-
* Exchanges a connect
|
|
44
|
-
*
|
|
45
|
-
*
|
|
40
|
+
* Exchanges a connect token for the provider's authorize URL, carrying the
|
|
41
|
+
* flow's state — and, where the provider supports it, a PKCE verifier —
|
|
42
|
+
* across the redirect.
|
|
46
43
|
*/
|
|
47
44
|
buildAuthorizationRedirect(token: string): Promise<string>;
|
|
48
45
|
/** Handles the provider's redirect back to Kosha. */
|
|
49
|
-
handleCallback(
|
|
50
|
-
/**
|
|
51
|
-
|
|
46
|
+
handleCallback(provider: string, code: string, state: string): Promise<CallbackResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Writes the credential, refusing when one is already there.
|
|
49
|
+
*
|
|
50
|
+
* Replacing silently would let somebody take over a credential a colleague
|
|
51
|
+
* connected, with no trace. Reconnecting means revoking first, which is a
|
|
52
|
+
* deliberate act by someone who can see what they are replacing.
|
|
53
|
+
*/
|
|
54
|
+
private writeCredential;
|
|
55
|
+
/** Persists a refreshed token set. Shared with the refresh path. */
|
|
56
|
+
replaceCredential(accountId: string, tokens: TokenSet): Promise<void>;
|
|
57
|
+
private envelopeFor;
|
|
58
|
+
private clientContextFor;
|
|
59
|
+
private resolveConfiguration;
|
|
52
60
|
/** An integration's hook must never take the request down with it. */
|
|
53
61
|
private runHook;
|
|
54
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.service.d.ts","sourceRoot":"","sources":["../../src/connect/connect.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.service.d.ts","sourceRoot":"","sources":["../../src/connect/connect.service.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAoB,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAOrE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EACL,aAAa,EAEd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAqB,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAKnF,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAMD;;;;;;GAMG;AACH,qBACa,cAAc;IAIvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM;IAR/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmC;gBAGvC,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,aAAa,EACpB,YAAY,EAAE,mBAAmB,EACjC,QAAQ,EAAE,mBAAmB,EACP,MAAM,EAAE,mBAAmB;IAGpE;;;OAGG;IACG,aAAa,CACjB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,oBAAoB,CAAC;IAuDhC;;;;OAIG;IACG,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgChE,qDAAqD;IAC/C,cAAc,CAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,cAAc,CAAC;IAsD1B;;;;;;OAMG;YACW,eAAe;IAgD7B,oEAAoE;IAC9D,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3E,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,gBAAgB;YAuBV,oBAAoB;IA8BlC,sEAAsE;YACxD,OAAO;CActB"}
|