@gitpod/gitpod-protocol 0.1.5-release-2022.6.1.0 → 0.1.5-release-2022.9.2.1
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/data/gitpod-schema.json +63 -129
- package/lib/accounting-protocol.d.ts +1 -0
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +4 -0
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +7 -0
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/attribution.d.ts +20 -0
- package/lib/attribution.d.ts.map +1 -0
- package/lib/attribution.js +40 -0
- package/lib/attribution.js.map +1 -0
- package/lib/billing-mode.d.ts +41 -0
- package/lib/billing-mode.d.ts.map +1 -0
- package/lib/billing-mode.js +44 -0
- package/lib/billing-mode.js.map +1 -0
- package/lib/blocked-repositories-protocol.d.ts +13 -0
- package/lib/blocked-repositories-protocol.d.ts.map +1 -0
- package/lib/blocked-repositories-protocol.js +8 -0
- package/lib/blocked-repositories-protocol.js.map +1 -0
- package/lib/encryption/encryption-engine.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.js +3 -3
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +1 -1
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/key-provider.js +1 -1
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/experiments/configcat-server.d.ts +2 -0
- package/lib/experiments/configcat-server.d.ts.map +1 -1
- package/lib/experiments/configcat-server.js +3 -1
- package/lib/experiments/configcat-server.js.map +1 -1
- package/lib/experiments/configcat.d.ts +4 -2
- package/lib/experiments/configcat.d.ts.map +1 -1
- package/lib/experiments/configcat.js +13 -3
- package/lib/experiments/configcat.js.map +1 -1
- package/lib/experiments/types.d.ts +8 -3
- package/lib/experiments/types.d.ts.map +1 -1
- package/lib/experiments/types.js +2 -0
- package/lib/experiments/types.js.map +1 -1
- package/lib/gitpod-service.d.ts +32 -15
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +13 -1
- package/lib/gitpod-service.js.map +1 -1
- package/lib/ide-protocol.d.ts +8 -0
- package/lib/ide-protocol.d.ts.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +1 -17
- package/lib/messaging/client-call-metrics.d.ts.map +1 -1
- package/lib/messaging/client-call-metrics.js +1 -2
- package/lib/messaging/client-call-metrics.js.map +1 -1
- package/lib/messaging/error.d.ts +5 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +11 -3
- package/lib/messaging/error.js.map +1 -1
- package/lib/plans.d.ts +1 -0
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +4 -0
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +88 -4
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +116 -3
- package/lib/protocol.js.map +1 -1
- package/lib/protocol.spec.d.ts +7 -0
- package/lib/protocol.spec.d.ts.map +1 -0
- package/lib/protocol.spec.js +127 -0
- package/lib/protocol.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +1 -0
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +4 -0
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +13 -1
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/usage.d.ts +61 -0
- package/lib/usage.d.ts.map +1 -0
- package/lib/usage.js +14 -0
- package/lib/usage.js.map +1 -0
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +5 -0
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/gitpod-host-url.d.ts +3 -0
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +18 -0
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/grpc.d.ts +19 -0
- package/lib/util/grpc.d.ts.map +1 -1
- package/lib/util/grpc.js +73 -1
- package/lib/util/grpc.js.map +1 -1
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +8 -1
- package/lib/util/logging.js.map +1 -1
- package/lib/util/logging.spec.d.ts +7 -0
- package/lib/util/logging.spec.d.ts.map +1 -0
- package/lib/util/logging.spec.js +52 -0
- package/lib/util/logging.spec.js.map +1 -0
- package/lib/util/timeutil.d.ts +1 -0
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +7 -1
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts +2 -0
- package/lib/util/timeutil.spec.d.ts.map +1 -1
- package/lib/util/timeutil.spec.js +34 -0
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/webhook-event.d.ts +44 -0
- package/lib/webhook-event.d.ts.map +1 -0
- package/lib/webhook-event.js +8 -0
- package/lib/webhook-event.js.map +1 -0
- package/lib/workspace-class.d.ts +14 -0
- package/lib/workspace-class.d.ts.map +1 -0
- package/lib/workspace-class.js +8 -0
- package/lib/workspace-class.js.map +1 -0
- package/lib/workspace-cluster.d.ts +5 -7
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +2 -0
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.d.ts +3 -3
- package/lib/wsready.d.ts.map +1 -1
- package/lib/wsready.js +0 -2
- package/lib/wsready.js.map +1 -1
- package/package.json +5 -2
- package/pkg-yarn.lock +3 -2
- package/provenance-bundle.jsonl +1 -1
- package/src/accounting-protocol.ts +3 -0
- package/src/admin-protocol.ts +10 -0
- package/src/attribution.ts +48 -0
- package/src/billing-mode.ts +77 -0
- package/src/blocked-repositories-protocol.ts +13 -0
- package/src/encryption/encryption-engine.spec.ts +1 -1
- package/src/encryption/encryption-engine.ts +7 -3
- package/src/encryption/key-provider.ts +1 -1
- package/src/experiments/configcat-server.ts +4 -0
- package/src/experiments/configcat.ts +14 -5
- package/src/experiments/types.ts +13 -7
- package/src/gitpod-service.ts +54 -14
- package/src/ide-protocol.ts +10 -0
- package/src/index.ts +1 -0
- package/src/messaging/client-call-metrics.ts +1 -20
- package/src/messaging/error.ts +16 -4
- package/src/plans.ts +4 -0
- package/src/protocol.spec.ts +97 -0
- package/src/protocol.ts +192 -6
- package/src/team-subscription-protocol.ts +3 -0
- package/src/teams-projects-protocol.ts +14 -1
- package/src/usage.ts +71 -0
- package/src/util/garbage-collected-cache.ts +5 -0
- package/src/util/gitpod-host-url.ts +21 -0
- package/src/util/grpc.ts +89 -0
- package/src/util/logging.spec.ts +23 -0
- package/src/util/logging.ts +11 -2
- package/src/util/timeutil.spec.ts +28 -1
- package/src/util/timeutil.ts +6 -0
- package/src/webhook-event.ts +55 -0
- package/src/workspace-class.ts +14 -0
- package/src/workspace-cluster.ts +2 -4
- package/src/workspace-instance.ts +8 -0
- package/src/wsready.ts +5 -4
|
@@ -40,7 +40,7 @@ export class EncryptionEngineImpl {
|
|
|
40
40
|
encrypt(data: string, key: Buffer): EncryptedData {
|
|
41
41
|
const iv = crypto.randomBytes(16);
|
|
42
42
|
const cipher = crypto.createCipheriv(this.algorithm, key, iv);
|
|
43
|
-
const encrypted = cipher.update(
|
|
43
|
+
const encrypted = cipher.update(Buffer.from(data, "utf8"));
|
|
44
44
|
const finalEncrypted = Buffer.concat([encrypted, cipher.final()]);
|
|
45
45
|
return {
|
|
46
46
|
data: finalEncrypted.toString(this.enc),
|
|
@@ -51,8 +51,12 @@ export class EncryptionEngineImpl {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
decrypt(encryptedData: EncryptedData, key: Buffer): string {
|
|
54
|
-
const decipher = crypto.createDecipheriv(
|
|
55
|
-
|
|
54
|
+
const decipher = crypto.createDecipheriv(
|
|
55
|
+
this.algorithm,
|
|
56
|
+
key,
|
|
57
|
+
Buffer.from(encryptedData.keyParams.iv, this.enc),
|
|
58
|
+
);
|
|
59
|
+
let decrypted = decipher.update(Buffer.from(encryptedData.data, this.enc));
|
|
56
60
|
const finalDecrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
57
61
|
return finalDecrypted.toString("utf8");
|
|
58
62
|
}
|
|
@@ -12,6 +12,9 @@ import { newAlwaysReturningDefaultValueClient } from "./always-default";
|
|
|
12
12
|
|
|
13
13
|
let client: Client | undefined;
|
|
14
14
|
|
|
15
|
+
export type ConfigCatClientFactory = () => Client;
|
|
16
|
+
export const ConfigCatClientFactory = Symbol("ConfigCatClientFactory");
|
|
17
|
+
|
|
15
18
|
export function getExperimentsClientForBackend(): Client {
|
|
16
19
|
// We have already instantiated a client, we can just re-use it.
|
|
17
20
|
if (client !== undefined) {
|
|
@@ -28,6 +31,7 @@ export function getExperimentsClientForBackend(): Client {
|
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
const configCatClient = configcat.createClient(sdkKey, {
|
|
34
|
+
pollIntervalSeconds: 3 * 60, // 3 minutes
|
|
31
35
|
logger: configcat.createConsoleLogger(LogLevel.Error),
|
|
32
36
|
maxInitWaitTimeSeconds: 0,
|
|
33
37
|
});
|
|
@@ -5,14 +5,17 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Attributes, Client } from "./types";
|
|
8
|
-
import { User } from "configcat-common/lib/RolloutEvaluator";
|
|
8
|
+
import { User as ConfigCatUser } from "configcat-common/lib/RolloutEvaluator";
|
|
9
9
|
import { IConfigCatClient } from "configcat-common/lib/ConfigCatClient";
|
|
10
|
+
import { User } from "../protocol";
|
|
10
11
|
|
|
12
|
+
export const USER_ID_ATTRIBUTE = "user_id";
|
|
11
13
|
export const PROJECT_ID_ATTRIBUTE = "project_id";
|
|
12
14
|
export const TEAM_ID_ATTRIBUTE = "team_id";
|
|
13
15
|
export const TEAM_IDS_ATTRIBUTE = "team_ids";
|
|
14
16
|
export const TEAM_NAME_ATTRIBUTE = "team_name";
|
|
15
17
|
export const TEAM_NAMES_ATTRIBUTE = "team_names";
|
|
18
|
+
export const BILLING_TIER_ATTRIBUTE = "billing_tier";
|
|
16
19
|
|
|
17
20
|
export class ConfigCatClient implements Client {
|
|
18
21
|
private client: IConfigCatClient;
|
|
@@ -30,11 +33,14 @@ export class ConfigCatClient implements Client {
|
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
export function attributesToUser(attributes: Attributes):
|
|
34
|
-
const userId = attributes.
|
|
35
|
-
const email = attributes.email || "";
|
|
36
|
+
export function attributesToUser(attributes: Attributes): ConfigCatUser {
|
|
37
|
+
const userId = attributes.user?.id || "";
|
|
38
|
+
const email = User.is(attributes.user) ? User.getPrimaryEmail(attributes.user) : attributes.user?.email || "";
|
|
36
39
|
|
|
37
40
|
const custom: { [key: string]: string } = {};
|
|
41
|
+
if (userId) {
|
|
42
|
+
custom[USER_ID_ATTRIBUTE] = userId;
|
|
43
|
+
}
|
|
38
44
|
if (attributes.projectId) {
|
|
39
45
|
custom[PROJECT_ID_ATTRIBUTE] = attributes.projectId;
|
|
40
46
|
}
|
|
@@ -48,6 +54,9 @@ export function attributesToUser(attributes: Attributes): User {
|
|
|
48
54
|
custom[TEAM_NAMES_ATTRIBUTE] = attributes.teams.map((t) => t.name).join(",");
|
|
49
55
|
custom[TEAM_IDS_ATTRIBUTE] = attributes.teams.map((t) => t.id).join(",");
|
|
50
56
|
}
|
|
57
|
+
if (attributes.billingTier) {
|
|
58
|
+
custom[BILLING_TIER_ATTRIBUTE] = attributes.billingTier;
|
|
59
|
+
}
|
|
51
60
|
|
|
52
|
-
return new
|
|
61
|
+
return new ConfigCatUser(userId, email, "", custom);
|
|
53
62
|
}
|
package/src/experiments/types.ts
CHANGED
|
@@ -4,24 +4,30 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { BillingTier, User } from "../protocol";
|
|
7
8
|
import { Team } from "../teams-projects-protocol";
|
|
8
9
|
|
|
10
|
+
export const Client = Symbol("Client");
|
|
11
|
+
|
|
9
12
|
// Attributes define attributes which can be used to segment audiences.
|
|
10
13
|
// Set the attributes which you want to use to group audiences into.
|
|
11
14
|
export interface Attributes {
|
|
12
|
-
|
|
13
|
-
email?: string;
|
|
15
|
+
// user.id is mapped to ConfigCat's "identifier" + "custom.user_id"
|
|
16
|
+
user?: User | { id: string; email?: string };
|
|
17
|
+
|
|
18
|
+
// The BillingTier of this particular user
|
|
19
|
+
billingTier?: BillingTier;
|
|
14
20
|
|
|
15
|
-
// Currently selected Gitpod Project ID
|
|
21
|
+
// Currently selected Gitpod Project ID (mapped to "custom.project_id")
|
|
16
22
|
projectId?: string;
|
|
17
23
|
|
|
18
|
-
// Currently selected Gitpod Team ID
|
|
24
|
+
// Currently selected Gitpod Team ID (mapped to "custom.team_id")
|
|
19
25
|
teamId?: string;
|
|
20
|
-
// Currently selected Gitpod Team Name
|
|
26
|
+
// Currently selected Gitpod Team Name (mapped to "custom.team_name")
|
|
21
27
|
teamName?: string;
|
|
22
28
|
|
|
23
|
-
// All the Gitpod Teams that the user is a member (or owner) of
|
|
24
|
-
teams?:
|
|
29
|
+
// All the Gitpod Teams that the user is a member (or owner) of (mapped to "custom.team_names" and "custom.team_ids")
|
|
30
|
+
teams?: Team[];
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
export interface Client {
|
package/src/gitpod-service.ts
CHANGED
|
@@ -24,6 +24,9 @@ import {
|
|
|
24
24
|
GuessGitTokenScopesParams,
|
|
25
25
|
GuessedGitTokenScopes,
|
|
26
26
|
ProjectEnvVar,
|
|
27
|
+
PrebuiltWorkspace,
|
|
28
|
+
UserSSHPublicKeyValue,
|
|
29
|
+
SSHPublicKeyValue,
|
|
27
30
|
} from "./protocol";
|
|
28
31
|
import {
|
|
29
32
|
Team,
|
|
@@ -34,6 +37,7 @@ import {
|
|
|
34
37
|
PrebuildWithStatus,
|
|
35
38
|
StartPrebuildResult,
|
|
36
39
|
PartialProject,
|
|
40
|
+
PrebuildEvent,
|
|
37
41
|
} from "./teams-projects-protocol";
|
|
38
42
|
import { JsonRpcProxy, JsonRpcServer } from "./messaging/proxy-factory";
|
|
39
43
|
import { Disposable, CancellationTokenSource } from "vscode-jsonrpc";
|
|
@@ -56,7 +60,9 @@ import {
|
|
|
56
60
|
import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from "./analytics";
|
|
57
61
|
import { IDEServer } from "./ide-protocol";
|
|
58
62
|
import { InstallationAdminSettings, TelemetryData } from "./installation-admin-protocol";
|
|
59
|
-
import {
|
|
63
|
+
import { ListUsageRequest, ListUsageResponse } from "./usage";
|
|
64
|
+
import { SupportedWorkspaceClass } from "./workspace-class";
|
|
65
|
+
import { BillingMode } from "./billing-mode";
|
|
60
66
|
|
|
61
67
|
export interface GitpodClient {
|
|
62
68
|
onInstanceUpdate(instance: WorkspaceInstance): void;
|
|
@@ -64,6 +70,8 @@ export interface GitpodClient {
|
|
|
64
70
|
|
|
65
71
|
onPrebuildUpdate(update: PrebuildWithStatus): void;
|
|
66
72
|
|
|
73
|
+
onNotificationUpdated(): void;
|
|
74
|
+
|
|
67
75
|
onCreditAlert(creditAlert: CreditAlert): void;
|
|
68
76
|
|
|
69
77
|
//#region propagating reconnection to iframe
|
|
@@ -78,6 +86,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
78
86
|
getLoggedInUser(): Promise<User>;
|
|
79
87
|
getTerms(): Promise<Terms>;
|
|
80
88
|
updateLoggedInUser(user: Partial<User>): Promise<User>;
|
|
89
|
+
sendPhoneNumberVerificationToken(phoneNumber: string): Promise<void>;
|
|
90
|
+
verifyPhoneNumberVerificationToken(phoneNumber: string, token: string): Promise<boolean>;
|
|
81
91
|
getAuthProviders(): Promise<AuthProviderInfo[]>;
|
|
82
92
|
getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
|
|
83
93
|
updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
|
|
@@ -148,6 +158,12 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
148
158
|
setEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
149
159
|
deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
|
|
150
160
|
|
|
161
|
+
// User SSH Keys
|
|
162
|
+
hasSSHPublicKey(): Promise<boolean>;
|
|
163
|
+
getSSHPublicKeys(): Promise<UserSSHPublicKeyValue[]>;
|
|
164
|
+
addSSHPublicKey(value: SSHPublicKeyValue): Promise<UserSSHPublicKeyValue>;
|
|
165
|
+
deleteSSHPublicKey(id: string): Promise<void>;
|
|
166
|
+
|
|
151
167
|
// Teams
|
|
152
168
|
getTeams(): Promise<Team[]>;
|
|
153
169
|
getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
|
|
@@ -171,14 +187,12 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
171
187
|
getTeamProjects(teamId: string): Promise<Project[]>;
|
|
172
188
|
getUserProjects(): Promise<Project[]>;
|
|
173
189
|
getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
|
|
190
|
+
getPrebuildEvents(projectId: string): Promise<PrebuildEvent[]>;
|
|
174
191
|
findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
|
|
192
|
+
findPrebuildByWorkspaceID(workspaceId: string): Promise<PrebuiltWorkspace | undefined>;
|
|
193
|
+
getPrebuild(prebuildId: string): Promise<PrebuildWithStatus | undefined>;
|
|
175
194
|
triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
|
|
176
195
|
cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
|
|
177
|
-
fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
|
|
178
|
-
guessProjectConfiguration(projectId: string): Promise<string | undefined>;
|
|
179
|
-
fetchRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
|
|
180
|
-
guessRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
|
|
181
|
-
setProjectConfiguration(projectId: string, configString: string): Promise<void>;
|
|
182
196
|
updateProjectPartial(partialProject: PartialProject): Promise<void>;
|
|
183
197
|
setProjectEnvironmentVariable(projectId: string, name: string, value: string, censored: boolean): Promise<void>;
|
|
184
198
|
getProjectEnvironmentVariables(projectId: string): Promise<ProjectEnvVar[]>;
|
|
@@ -194,7 +208,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
194
208
|
deleteGitpodToken(tokenHash: string): Promise<void>;
|
|
195
209
|
|
|
196
210
|
// misc
|
|
197
|
-
sendFeedback(feedback: string): Promise<string | undefined>;
|
|
198
211
|
isGitHubAppEnabled(): Promise<boolean>;
|
|
199
212
|
registerGithubApp(installationId: string): Promise<void>;
|
|
200
213
|
|
|
@@ -273,9 +286,19 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
273
286
|
|
|
274
287
|
getStripePublishableKey(): Promise<string>;
|
|
275
288
|
getStripeSetupIntentClientSecret(): Promise<string>;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
289
|
+
findStripeSubscriptionId(attributionId: string): Promise<string | undefined>;
|
|
290
|
+
createStripeCustomerIfNeeded(attributionId: string, currency: string): Promise<void>;
|
|
291
|
+
subscribeToStripe(attributionId: string, setupIntentId: string): Promise<void>;
|
|
292
|
+
getStripePortalUrl(attributionId: string): Promise<string>;
|
|
293
|
+
getUsageLimit(attributionId: string): Promise<number | undefined>;
|
|
294
|
+
setUsageLimit(attributionId: string, usageLimit: number): Promise<void>;
|
|
295
|
+
|
|
296
|
+
listUsage(req: ListUsageRequest): Promise<ListUsageResponse>;
|
|
297
|
+
|
|
298
|
+
setUsageAttribution(usageAttribution: string): Promise<void>;
|
|
299
|
+
|
|
300
|
+
getBillingModeForUser(): Promise<BillingMode>;
|
|
301
|
+
getBillingModeForTeam(teamId: string): Promise<BillingMode>;
|
|
279
302
|
|
|
280
303
|
/**
|
|
281
304
|
* Analytics
|
|
@@ -283,6 +306,13 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
|
|
|
283
306
|
trackEvent(event: RemoteTrackMessage): Promise<void>;
|
|
284
307
|
trackLocation(event: RemotePageMessage): Promise<void>;
|
|
285
308
|
identifyUser(event: RemoteIdentifyMessage): Promise<void>;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Frontend notifications
|
|
312
|
+
*/
|
|
313
|
+
getNotifications(): Promise<string[]>;
|
|
314
|
+
|
|
315
|
+
getSupportedWorkspaceClasses(): Promise<SupportedWorkspaceClass[]>;
|
|
286
316
|
}
|
|
287
317
|
|
|
288
318
|
export interface RateLimiterError {
|
|
@@ -297,9 +327,7 @@ export interface RateLimiterError {
|
|
|
297
327
|
|
|
298
328
|
export interface CreateProjectParams {
|
|
299
329
|
name: string;
|
|
300
|
-
slug
|
|
301
|
-
account: string;
|
|
302
|
-
provider: string;
|
|
330
|
+
slug: string;
|
|
303
331
|
cloneUrl: string;
|
|
304
332
|
teamId?: string;
|
|
305
333
|
userId?: string;
|
|
@@ -364,7 +392,7 @@ export const createServerMock = function <C extends GitpodClient, S extends Gitp
|
|
|
364
392
|
get: (target: S, property: keyof S) => {
|
|
365
393
|
const result = target[property];
|
|
366
394
|
if (!result) {
|
|
367
|
-
throw new Error(`Method ${property} not implemented`);
|
|
395
|
+
throw new Error(`Method ${String(property)} not implemented`);
|
|
368
396
|
}
|
|
369
397
|
return result;
|
|
370
398
|
},
|
|
@@ -538,6 +566,18 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
|
|
|
538
566
|
}
|
|
539
567
|
}
|
|
540
568
|
}
|
|
569
|
+
|
|
570
|
+
onNotificationUpdated(): void {
|
|
571
|
+
for (const client of this.clients) {
|
|
572
|
+
if (client.onNotificationUpdated) {
|
|
573
|
+
try {
|
|
574
|
+
client.onNotificationUpdated();
|
|
575
|
+
} catch (error) {
|
|
576
|
+
console.error(error);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
541
581
|
}
|
|
542
582
|
|
|
543
583
|
export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
|
package/src/ide-protocol.ts
CHANGED
|
@@ -116,4 +116,14 @@ export interface IDEOption {
|
|
|
116
116
|
* we resolve the tag regularly to the most recent image version.
|
|
117
117
|
*/
|
|
118
118
|
resolveImageDigest?: boolean;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The plugin image ref for the IDE image, this image ref always resolve to digest.
|
|
122
|
+
*/
|
|
123
|
+
pluginImage?: string;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The latest plugin image ref for the latest IDE image, this image ref always resolve to digest.
|
|
127
|
+
*/
|
|
128
|
+
pluginLatestImage?: string;
|
|
119
129
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,26 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { injectable } from "inversify";
|
|
8
8
|
import * as prometheusClient from "prom-client";
|
|
9
|
-
|
|
10
|
-
type GrpcMethodType = "unary" | "client_stream" | "server_stream" | "bidi_stream";
|
|
11
|
-
export interface IGrpcCallMetricsLabels {
|
|
12
|
-
service: string;
|
|
13
|
-
method: string;
|
|
14
|
-
type: GrpcMethodType;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface IGrpcCallMetricsLabelsWithCode extends IGrpcCallMetricsLabels {
|
|
18
|
-
code: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const IClientCallMetrics = Symbol("IClientCallMetrics");
|
|
22
|
-
|
|
23
|
-
export interface IClientCallMetrics {
|
|
24
|
-
started(labels: IGrpcCallMetricsLabels): void;
|
|
25
|
-
sent(labels: IGrpcCallMetricsLabels): void;
|
|
26
|
-
received(labels: IGrpcCallMetricsLabels): void;
|
|
27
|
-
handled(labels: IGrpcCallMetricsLabelsWithCode): void;
|
|
28
|
-
}
|
|
9
|
+
import { IClientCallMetrics, IGrpcCallMetricsLabels, IGrpcCallMetricsLabelsWithCode } from "../util/grpc";
|
|
29
10
|
|
|
30
11
|
@injectable()
|
|
31
12
|
export class PrometheusClientCallMetrics implements IClientCallMetrics {
|
package/src/messaging/error.ts
CHANGED
|
@@ -26,21 +26,30 @@ export namespace ErrorCodes {
|
|
|
26
26
|
// 410 No User
|
|
27
27
|
export const SETUP_REQUIRED = 410;
|
|
28
28
|
|
|
29
|
+
// 411 No User
|
|
30
|
+
export const NEEDS_VERIFICATION = 411;
|
|
31
|
+
|
|
29
32
|
// 429 Too Many Requests
|
|
30
33
|
export const TOO_MANY_REQUESTS = 429;
|
|
31
34
|
|
|
32
35
|
// 430 Repository not whitelisted (custom status code)
|
|
33
36
|
export const REPOSITORY_NOT_WHITELISTED = 430;
|
|
34
37
|
|
|
38
|
+
// 450 Payment error
|
|
39
|
+
export const PAYMENT_ERROR = 450;
|
|
40
|
+
|
|
41
|
+
// 451 Out of credits
|
|
42
|
+
export const PAYMENT_SPENDING_LIMIT_REACHED = 451;
|
|
43
|
+
|
|
44
|
+
// 455 Invalid cost center (custom status code)
|
|
45
|
+
export const INVALID_COST_CENTER = 455;
|
|
46
|
+
|
|
35
47
|
// 460 Context Parse Error (custom status code)
|
|
36
48
|
export const CONTEXT_PARSE_ERROR = 460;
|
|
37
49
|
|
|
38
|
-
// 461 Invalid gitpod yml
|
|
50
|
+
// 461 Invalid gitpod yml (custom status code)
|
|
39
51
|
export const INVALID_GITPOD_YML = 461;
|
|
40
52
|
|
|
41
|
-
// 450 Payment error
|
|
42
|
-
export const PAYMENT_ERROR = 450;
|
|
43
|
-
|
|
44
53
|
// 470 User Blocked (custom status code)
|
|
45
54
|
export const USER_BLOCKED = 470;
|
|
46
55
|
|
|
@@ -85,4 +94,7 @@ export namespace ErrorCodes {
|
|
|
85
94
|
|
|
86
95
|
// 640 Headless logs are not available (yet)
|
|
87
96
|
export const HEADLESS_LOG_NOT_YET_AVAILABLE = 640;
|
|
97
|
+
|
|
98
|
+
// 650 Invalid Value
|
|
99
|
+
export const INVALID_VALUE = 650;
|
|
88
100
|
}
|
package/src/plans.ts
CHANGED
|
@@ -482,6 +482,10 @@ export namespace Plans {
|
|
|
482
482
|
);
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
+
export function isFreeTier(chargebeeId: string | undefined): boolean {
|
|
486
|
+
return chargebeeId === Plans.FREE.chargebeeId || chargebeeId === Plans.FREE_50.chargebeeId;
|
|
487
|
+
}
|
|
488
|
+
|
|
485
489
|
export function isFreeNonTransientPlan(chargebeeId: string | undefined): boolean {
|
|
486
490
|
return chargebeeId === Plans.FREE_OPEN_SOURCE.chargebeeId;
|
|
487
491
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
+
* See License-AGPL.txt in the project root for license information.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { suite, test } from "mocha-typescript";
|
|
8
|
+
import * as chai from "chai";
|
|
9
|
+
import { SSHPublicKeyValue } from ".";
|
|
10
|
+
|
|
11
|
+
const expect = chai.expect;
|
|
12
|
+
|
|
13
|
+
@suite
|
|
14
|
+
class TestSSHPublicKeyValue {
|
|
15
|
+
private key =
|
|
16
|
+
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCnrN9UdK1bNGPmZfenTWXLuYYDjlYvZE8S+WOfP08WpR1GETzX5ZvgYOEZGwEE8KUPHC9cge4Hvo/ydIS9aqbZ5MiVGJ8cAIq1Ic89SjlDWU6fl8TwIqOPCi2imAASlEDP4q8vMLK1N6UOW1EVbxyL3uybGd10ysC1t1FxFPveIGNsYE/MOQeuEWS16AplpXYXIfVRSlgAskeBft2w8Ud3B4gNe8ECLA/FXu96UpvZkdtOarA3JZ9Z27GveNJg9Mtmmw0+US0KXiO9x9NyH7G8+mqVDwDY+nNvaFA5gtQxkkl/uY2oz9k/B4Rjlj3jOiUXe5uQs3XUm5m8g9a9fh62DabLpA2fEvtfg+a/VqNe52dNa5YjupwvBd6Inb5uMW/TYjNl6bNHPlXFKw/nwLOVzukpkjxMZUKS6+4BGkpoasj6y2rTU/wkpbdD8J7yjI1p6J9aKkC6KksIWgN7xGmHkv2PCGDqMHTNbnQyowtNKMgA/667vAYJ0qW7HAHBFXJRs6uRi/DI3+c1QV2s4wPCpEHDIYApovQ0fbON4WDPoGMyHd7kPh9xB/bX7Dj0uMXImu1pdTd62fQ/1XXX64+vjAAXS/P9RSCD0RCRt/K3LPKl2m7GPI3y1niaE52XhxZw+ms9ays6NasNVMw/ZC+f02Ti+L5FBEVf8230RVVRQ== notfound@gitpod.io";
|
|
17
|
+
|
|
18
|
+
@test public testValidate() {
|
|
19
|
+
const key = this.key;
|
|
20
|
+
const [t, k, e] = key.split(" ");
|
|
21
|
+
expect(
|
|
22
|
+
SSHPublicKeyValue.getData({
|
|
23
|
+
key,
|
|
24
|
+
name: "NiceName",
|
|
25
|
+
}),
|
|
26
|
+
).to.deep.equal({ type: t, key: k, email: e });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@test public testValidateWithDiffType() {
|
|
30
|
+
const key = this.key;
|
|
31
|
+
const [_, k, e] = key.split(" ");
|
|
32
|
+
expect(
|
|
33
|
+
SSHPublicKeyValue.getData({
|
|
34
|
+
key: key.replace("ssh-rsa", "sk-ecdsa-sha2-nistp256@openssh.com"),
|
|
35
|
+
name: "NiceName",
|
|
36
|
+
}),
|
|
37
|
+
).to.deep.equal({ type: "sk-ecdsa-sha2-nistp256@openssh.com", key: k, email: e });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@test public testValidateWithoutEmail() {
|
|
41
|
+
const key = this.key;
|
|
42
|
+
const [t, k, _] = key.split(" ");
|
|
43
|
+
expect(
|
|
44
|
+
SSHPublicKeyValue.getData({
|
|
45
|
+
key: key.replace(" notfound@gitpod.io", ""),
|
|
46
|
+
name: "NiceName",
|
|
47
|
+
}),
|
|
48
|
+
).to.deep.equal({ type: t, key: k, email: undefined });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@test public testValidateWithoutEmailButEndsWithSpaces() {
|
|
52
|
+
const key = this.key;
|
|
53
|
+
const [t, k, _] = key.split(" ");
|
|
54
|
+
expect(
|
|
55
|
+
SSHPublicKeyValue.getData({
|
|
56
|
+
key: key.replace("notfound@gitpod.io", " "),
|
|
57
|
+
name: "NiceName",
|
|
58
|
+
}),
|
|
59
|
+
).to.deep.equal({ type: t, key: k, email: undefined });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@test public testValidateWithError() {
|
|
63
|
+
expect(() =>
|
|
64
|
+
SSHPublicKeyValue.getData({
|
|
65
|
+
key: "Hello World",
|
|
66
|
+
name: "NiceName",
|
|
67
|
+
}),
|
|
68
|
+
).throw("Key is invalid");
|
|
69
|
+
|
|
70
|
+
expect(() =>
|
|
71
|
+
SSHPublicKeyValue.getData({
|
|
72
|
+
key: "",
|
|
73
|
+
name: "NiceName",
|
|
74
|
+
}),
|
|
75
|
+
).throw("Key is invalid");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@test public testGetFingerprint() {
|
|
79
|
+
const key = this.key;
|
|
80
|
+
expect(
|
|
81
|
+
SSHPublicKeyValue.getFingerprint({
|
|
82
|
+
key,
|
|
83
|
+
name: "NiceName",
|
|
84
|
+
}),
|
|
85
|
+
).to.equal("ykjP/b5aqoa3envmXzWpPMCGgEFMu3QvubfSTNrJCMA=");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@test public testGetFingerprintWithIncorrectPublicKey() {
|
|
89
|
+
expect(() =>
|
|
90
|
+
SSHPublicKeyValue.getFingerprint({
|
|
91
|
+
key: "Hello World",
|
|
92
|
+
name: "NiceName",
|
|
93
|
+
}),
|
|
94
|
+
).to.throw("Key is invalid");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
module.exports = new TestSSHPublicKeyValue(); // Only to circumvent no usage warning :-/
|