@gitpod/gitpod-protocol 0.1.5-pd-update-to-node-14-fork.2 → 0.1.5-pd-add-latest-jb.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/data/gitpod-schema.json +21 -2
- package/lib/accounting-protocol.d.ts +0 -1
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +10 -11
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +8 -2
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +2 -13
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +1 -0
- package/lib/analytics.d.ts.map +1 -1
- package/lib/context-url.d.ts +1 -0
- package/lib/context-url.d.ts.map +1 -1
- package/lib/context-url.js +7 -5
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.js +45 -48
- package/lib/context-url.spec.js.map +1 -1
- package/lib/email-protocol.js +4 -4
- package/lib/email-protocol.js.map +1 -1
- package/lib/encryption/container-module.js +4 -4
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.js +19 -20
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +29 -36
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.js +29 -43
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.js +25 -30
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.js +12 -13
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.js +25 -41
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +116 -116
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +33 -11
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +151 -295
- package/lib/gitpod-service.js.map +1 -1
- package/lib/ide-protocol.d.ts +105 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/ide-protocol.js +8 -0
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +13 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -0
- package/lib/installation-admin-protocol.js +8 -0
- package/lib/installation-admin-protocol.js.map +1 -0
- package/lib/messaging/browser/connection.js +91 -156
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.js +35 -55
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.js +17 -18
- package/lib/messaging/client-call-metrics.js.map +1 -1
- package/lib/messaging/connection-error-handler.js +11 -23
- package/lib/messaging/connection-error-handler.js.map +1 -1
- package/lib/messaging/error.d.ts +1 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +2 -2
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/node/connection.d.ts +1 -17
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +23 -59
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.js +71 -162
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/oss-allowlist.d.ts +14 -0
- package/lib/oss-allowlist.d.ts.map +1 -0
- package/lib/oss-allowlist.js +8 -0
- package/lib/oss-allowlist.js.map +1 -0
- package/lib/permission.js +12 -12
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +1 -1
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +38 -57
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +33 -44
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +57 -115
- package/lib/protocol.js.map +1 -1
- package/lib/snapshot-url.d.ts +14 -0
- package/lib/snapshot-url.d.ts.map +1 -0
- package/lib/snapshot-url.js +26 -0
- package/lib/snapshot-url.js.map +1 -0
- package/lib/snapshot-url.spec.d.ts +7 -0
- package/lib/snapshot-url.spec.d.ts.map +1 -0
- package/lib/snapshot-url.spec.js +41 -0
- package/lib/snapshot-url.spec.js.map +1 -0
- package/lib/team-subscription-protocol.js +13 -13
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +9 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js +4 -15
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/util/analytics.js +25 -32
- package/lib/util/analytics.js.map +1 -1
- package/lib/util/async-iterator.js +55 -133
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js +17 -59
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +8 -8
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deferred.js +10 -12
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.js +26 -39
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.js +58 -74
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts +1 -0
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +26 -46
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +29 -68
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +57 -78
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +20 -0
- package/lib/util/gitpod-cookie.d.ts.map +1 -0
- package/lib/util/gitpod-cookie.js +44 -0
- package/lib/util/gitpod-cookie.js.map +1 -0
- package/lib/util/gitpod-host-url.d.ts +1 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +93 -103
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +87 -135
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.js +3 -3
- package/lib/util/grpc.js.map +1 -1
- package/lib/util/jaeger-client-types.d.ts +68 -0
- package/lib/util/jaeger-client-types.d.ts.map +1 -0
- package/lib/util/jaeger-client-types.js +8 -0
- package/lib/util/jaeger-client-types.js.map +1 -0
- package/lib/util/logging.d.ts +32 -32
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +50 -113
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.js +2 -2
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/parse-workspace-id.d.ts +10 -0
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +31 -7
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +4 -0
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +123 -84
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.js +16 -55
- package/lib/util/queue.js.map +1 -1
- package/lib/util/queue.spec.js +144 -288
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/repeat.d.ts +15 -0
- package/lib/util/repeat.d.ts.map +1 -0
- package/lib/util/repeat.js +55 -0
- package/lib/util/repeat.js.map +1 -0
- package/lib/util/safe-promise.js +9 -12
- package/lib/util/safe-promise.js.map +1 -1
- package/lib/util/semaphore.js +15 -46
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.js +6 -6
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.js +16 -16
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.js +21 -24
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +51 -5
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +196 -62
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.d.ts +7 -0
- package/lib/util/tracing.spec.d.ts.map +1 -0
- package/lib/util/tracing.spec.js +121 -0
- package/lib/util/tracing.spec.js.map +1 -0
- package/lib/util/workspace-port-authentication.js +2 -2
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +11 -1
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +3 -3
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +3 -2
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.js +1 -1
- package/package.json +22 -13
- package/pkg-yarn.lock +12 -7
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +1 -3
- package/src/admin-protocol.ts +9 -3
- package/src/analytics.ts +2 -0
- package/src/context-url.ts +3 -1
- package/src/email-protocol.ts +1 -1
- package/src/gitpod-service.ts +42 -20
- package/src/ide-frontend-service.ts +1 -1
- package/src/ide-protocol.ts +119 -0
- package/src/index.ts +3 -0
- package/src/installation-admin-protocol.ts +14 -0
- package/src/messaging/error.ts +2 -2
- package/src/messaging/node/connection.ts +21 -68
- package/src/oss-allowlist.ts +15 -0
- package/src/protocol.ts +49 -46
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +1 -1
- package/src/teams-projects-protocol.ts +12 -1
- package/src/util/garbage-collected-cache.ts +7 -1
- package/src/util/generate-workspace-id.spec.ts +17 -0
- package/src/util/generate-workspace-id.ts +20 -2
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/gitpod-host-url.ts +11 -11
- package/src/util/grpc.ts +3 -3
- package/src/util/jaeger-client-types.ts +102 -0
- package/src/util/logging.ts +32 -32
- package/src/util/parse-workspace-id.spec.ts +21 -1
- package/src/util/parse-workspace-id.ts +32 -6
- package/src/util/repeat.ts +45 -0
- package/src/util/tracing.spec.ts +83 -0
- package/src/util/tracing.ts +183 -18
- package/src/workspace-cluster.ts +8 -1
- package/src/workspace-instance.ts +9 -6
- package/src/wsready.ts +1 -1
- package/lib/util/repeater.d.ts +0 -22
- package/lib/util/repeater.d.ts.map +0 -1
- package/lib/util/repeater.js +0 -118
- package/lib/util/repeater.js.map +0 -1
- package/src/util/jaeger-client.d.ts +0 -105
- package/src/util/repeater.ts +0 -49
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021 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
|
+
/**
|
|
8
|
+
* `IDEServer` provides a list of available IDEs.
|
|
9
|
+
*/
|
|
10
|
+
export interface IDEServer {
|
|
11
|
+
/**
|
|
12
|
+
* Returns the IDE preferences.
|
|
13
|
+
*/
|
|
14
|
+
getIDEOptions(): Promise<IDEOptions>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface IDEOptions {
|
|
18
|
+
/**
|
|
19
|
+
* A list of available IDEs.
|
|
20
|
+
*/
|
|
21
|
+
options: { [key: string]: IDEOption };
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The default (browser) IDE when the user has not specified one.
|
|
25
|
+
*/
|
|
26
|
+
defaultIde: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The default desktop IDE when the user has not specified one.
|
|
30
|
+
*/
|
|
31
|
+
defaultDesktopIde: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Client specific IDE options.
|
|
35
|
+
*/
|
|
36
|
+
clients?: { [id: string]: IDEClient };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface IDEClient {
|
|
40
|
+
/**
|
|
41
|
+
* The default desktop IDE when the user has not specified one.
|
|
42
|
+
*/
|
|
43
|
+
defaultDesktopIDE?: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Desktop IDEs supported by the client.
|
|
47
|
+
*/
|
|
48
|
+
desktopIDEs?: string[]
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Steps to install the client on user machine.
|
|
52
|
+
*/
|
|
53
|
+
installationSteps?: string[]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface IDEOption {
|
|
57
|
+
/**
|
|
58
|
+
* To ensure a stable order one can set an `orderKey`.
|
|
59
|
+
*/
|
|
60
|
+
orderKey?: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Human readable title text of the IDE (plain text only).
|
|
64
|
+
*/
|
|
65
|
+
title: string;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The type of the IDE, currently 'browser' or 'desktop'.
|
|
69
|
+
*/
|
|
70
|
+
type: 'browser' | 'desktop';
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The logo for the IDE. That could be a key in (see
|
|
74
|
+
* components/dashboard/src/images/ideLogos.ts) or a URL.
|
|
75
|
+
*/
|
|
76
|
+
logo: string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Text of an optional tooltip (plain text only).
|
|
80
|
+
*/
|
|
81
|
+
tooltip?: string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Text of an optional label next to the IDE option like “Insiders” (plain
|
|
85
|
+
* text only).
|
|
86
|
+
*/
|
|
87
|
+
label?: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Notes to the IDE option that are renderd in the preferences when a user
|
|
91
|
+
* chooses this IDE.
|
|
92
|
+
*/
|
|
93
|
+
notes?: string[];
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* If `true` this IDE option is not visible in the IDE preferences.
|
|
97
|
+
*/
|
|
98
|
+
hidden?: boolean;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The image ref to the IDE image.
|
|
102
|
+
*/
|
|
103
|
+
image: string;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The latest image ref to the IDE image, this image ref always resolve to digest.
|
|
107
|
+
*/
|
|
108
|
+
latestImage?: string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* When this is `true`, the tag of this image is resolved to the latest
|
|
112
|
+
* image digest regularly.
|
|
113
|
+
*
|
|
114
|
+
* This is useful if this image points to a tag like `nightly` that will be
|
|
115
|
+
* updated regularly. When `resolveImageDigest` is `true`, we make sure that
|
|
116
|
+
* we resolve the tag regularly to the most recent image version.
|
|
117
|
+
*/
|
|
118
|
+
resolveImageDigest?: boolean;
|
|
119
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -17,3 +17,6 @@ export * from './email-protocol';
|
|
|
17
17
|
export * from './headless-workspace-log';
|
|
18
18
|
export * from './context-url';
|
|
19
19
|
export * from './teams-projects-protocol';
|
|
20
|
+
export * from './snapshot-url';
|
|
21
|
+
export * from './oss-allowlist';
|
|
22
|
+
export * from './installation-admin-protocol';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 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
|
+
export interface InstallationAdminSettings {
|
|
8
|
+
sendTelemetry: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface InstallationAdmin {
|
|
12
|
+
id: string;
|
|
13
|
+
settings: InstallationAdminSettings;
|
|
14
|
+
}
|
package/src/messaging/error.ts
CHANGED
|
@@ -76,6 +76,6 @@ export namespace ErrorCodes {
|
|
|
76
76
|
// 620 Team Subscription Assignment Failed
|
|
77
77
|
export const TEAM_SUBSCRIPTION_ASSIGNMENT_FAILED = 620;
|
|
78
78
|
|
|
79
|
-
//
|
|
80
|
-
export const
|
|
79
|
+
// 630 Snapshot Error
|
|
80
|
+
export const SNAPSHOT_ERROR = 630;
|
|
81
81
|
}
|
|
@@ -6,81 +6,34 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import * as ws from "ws";
|
|
9
|
-
import
|
|
10
|
-
import * as https from "https";
|
|
11
|
-
import * as url from "url";
|
|
12
|
-
import * as net from "net";
|
|
13
|
-
import { MessageConnection } from "vscode-jsonrpc";
|
|
14
|
-
import { createWebSocketConnection, IWebSocket } from "vscode-ws-jsonrpc";
|
|
15
|
-
import { log } from '../../util/logging';
|
|
9
|
+
import { IWebSocket } from "vscode-ws-jsonrpc";
|
|
16
10
|
|
|
17
|
-
export
|
|
18
|
-
readonly server: http.Server | https.Server;
|
|
19
|
-
readonly path?: string;
|
|
20
|
-
matches?(request: http.IncomingMessage): boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function createServerWebSocketConnection(options: IServerOptions, onConnect: (connection: MessageConnection) => void): void {
|
|
24
|
-
openJsonRpcSocket(options, socket => {
|
|
25
|
-
onConnect(createWebSocketConnection(socket, console));
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function openJsonRpcSocket(options: IServerOptions, onOpen: (socket: IWebSocket) => void): void {
|
|
30
|
-
openSocket(options, socket => {
|
|
31
|
-
const webSocket = toIWebSocket(socket);
|
|
32
|
-
onOpen(webSocket);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface OnOpen {
|
|
37
|
-
(webSocket: ws, request: http.IncomingMessage, socket: net.Socket, head: Buffer): void;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function openSocket(options: IServerOptions, onOpen: OnOpen): void {
|
|
41
|
-
const wss = new ws.Server({
|
|
42
|
-
noServer: true,
|
|
43
|
-
perMessageDeflate: {
|
|
44
|
-
// don't compress if a message is less than 256kb
|
|
45
|
-
threshold: 256 * 1024
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
options.server.on('upgrade', (request: http.IncomingMessage, socket: net.Socket, head: Buffer) => {
|
|
49
|
-
const pathname = request.url ? url.parse(request.url).pathname : undefined;
|
|
50
|
-
if (options.path && pathname === options.path || options.matches && options.matches(request)) {
|
|
51
|
-
wss.handleUpgrade(request, socket, head, webSocket => {
|
|
52
|
-
if (webSocket.readyState === webSocket.OPEN) {
|
|
53
|
-
onOpen(webSocket, request, socket, head);
|
|
54
|
-
} else {
|
|
55
|
-
webSocket.on('open', () => onOpen(webSocket, request, socket, head));
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function toIWebSocket(webSocket: ws) {
|
|
63
|
-
let sendsAfterOpen = 0;
|
|
11
|
+
export function toIWebSocket(ws: ws) {
|
|
64
12
|
return <IWebSocket>{
|
|
65
13
|
send: content => {
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
//log.debug(`Repeated try to send on closed web socket (readyState was ${webSocket.readyState})`, { ws });
|
|
69
|
-
}
|
|
14
|
+
if (ws.readyState >= ws.CLOSING) {
|
|
15
|
+
// ws is already CLOSING/CLOSED, send() would just return an error.
|
|
70
16
|
return;
|
|
71
17
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
18
|
+
|
|
19
|
+
// in general send-errors should trigger an 'error' event already, we just make sure it actually happens.
|
|
20
|
+
try {
|
|
21
|
+
ws.send(content, err => {
|
|
22
|
+
if (!err) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
ws.emit('error', err);
|
|
26
|
+
});
|
|
27
|
+
} catch (err) {
|
|
28
|
+
ws.emit('error', err);
|
|
29
|
+
}
|
|
77
30
|
},
|
|
78
|
-
onMessage: cb =>
|
|
79
|
-
onError: cb =>
|
|
80
|
-
onClose: cb =>
|
|
31
|
+
onMessage: cb => ws.on('message', cb),
|
|
32
|
+
onError: cb => ws.on('error', cb),
|
|
33
|
+
onClose: cb => ws.on('close', cb),
|
|
81
34
|
dispose: () => {
|
|
82
|
-
if (
|
|
83
|
-
|
|
35
|
+
if (ws.readyState < ws.CLOSING) {
|
|
36
|
+
ws.close();
|
|
84
37
|
}
|
|
85
38
|
}
|
|
86
39
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021 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
|
+
export interface OssAllowList {
|
|
8
|
+
/**
|
|
9
|
+
* A string that identifies a GitHub/GitLab/Bitbucket identity of the form "<host>/<profilename>"
|
|
10
|
+
* E.g., "github.com/geropl"
|
|
11
|
+
*/
|
|
12
|
+
identity: string,
|
|
13
|
+
|
|
14
|
+
deleted?: boolean,
|
|
15
|
+
}
|
package/src/protocol.ts
CHANGED
|
@@ -104,6 +104,9 @@ export interface AdditionalUserData {
|
|
|
104
104
|
oauthClientsApproved?: { [key: string]: string }
|
|
105
105
|
// to remember GH Orgs the user installed/updated the GH App for
|
|
106
106
|
knownGitHubOrgs?: string[];
|
|
107
|
+
|
|
108
|
+
// Git clone URL pointing to the user's dotfile repo
|
|
109
|
+
dotfileRepo?: string;
|
|
107
110
|
}
|
|
108
111
|
|
|
109
112
|
export interface EmailNotificationSettings {
|
|
@@ -114,6 +117,9 @@ export interface EmailNotificationSettings {
|
|
|
114
117
|
|
|
115
118
|
export type IDESettings = {
|
|
116
119
|
defaultIde?: string
|
|
120
|
+
useDesktopIde?: boolean
|
|
121
|
+
defaultDesktopIde?: string
|
|
122
|
+
useLatestVersion?: boolean
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
export interface UserPlatform {
|
|
@@ -135,14 +141,6 @@ export interface UserPlatform {
|
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
export interface UserFeatureSettings {
|
|
138
|
-
/**
|
|
139
|
-
* This field is used as marker to grant users a free trial for using private repositories,
|
|
140
|
-
* independent of any subscription or Chargebee.
|
|
141
|
-
* - it is set when the user uses their first private repo
|
|
142
|
-
* - whether the trial is expired or not is juged by the UserService
|
|
143
|
-
*/
|
|
144
|
-
privateRepoTrialStartDate?: string;
|
|
145
|
-
|
|
146
144
|
/**
|
|
147
145
|
* Permanent feature flags are added to each and every workspace instance
|
|
148
146
|
* this user starts.
|
|
@@ -157,12 +155,23 @@ export interface UserFeatureSettings {
|
|
|
157
155
|
export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
|
|
158
156
|
export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
|
|
159
157
|
|
|
160
|
-
export interface
|
|
161
|
-
id?: string;
|
|
158
|
+
export interface EnvVarWithValue {
|
|
162
159
|
name: string;
|
|
163
|
-
repositoryPattern: string;
|
|
164
160
|
value: string;
|
|
165
161
|
}
|
|
162
|
+
|
|
163
|
+
export interface ProjectEnvVarWithValue extends EnvVarWithValue {
|
|
164
|
+
id: string;
|
|
165
|
+
projectId: string;
|
|
166
|
+
censored: boolean;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export type ProjectEnvVar = Omit<ProjectEnvVarWithValue, 'value'>;
|
|
170
|
+
|
|
171
|
+
export interface UserEnvVarValue extends EnvVarWithValue {
|
|
172
|
+
id?: string;
|
|
173
|
+
repositoryPattern: string; // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
174
|
+
}
|
|
166
175
|
export interface UserEnvVar extends UserEnvVarValue {
|
|
167
176
|
id: string;
|
|
168
177
|
userId: string;
|
|
@@ -171,10 +180,12 @@ export interface UserEnvVar extends UserEnvVarValue {
|
|
|
171
180
|
|
|
172
181
|
export namespace UserEnvVar {
|
|
173
182
|
|
|
183
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
174
184
|
export function normalizeRepoPattern(pattern: string) {
|
|
175
185
|
return pattern.toLocaleLowerCase();
|
|
176
186
|
}
|
|
177
187
|
|
|
188
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
178
189
|
export function score(value: UserEnvVarValue): number {
|
|
179
190
|
// We use a score to enforce precedence:
|
|
180
191
|
// value/value = 0
|
|
@@ -197,6 +208,7 @@ export namespace UserEnvVar {
|
|
|
197
208
|
return score;
|
|
198
209
|
}
|
|
199
210
|
|
|
211
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
200
212
|
export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
|
|
201
213
|
let result = vars.filter(e => {
|
|
202
214
|
const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
|
|
@@ -244,6 +256,7 @@ export namespace UserEnvVar {
|
|
|
244
256
|
return result;
|
|
245
257
|
}
|
|
246
258
|
|
|
259
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
247
260
|
export function splitRepositoryPattern(repositoryPattern: string): string[] {
|
|
248
261
|
const patterns = repositoryPattern.split('/');
|
|
249
262
|
const repoPattern = patterns.pop() || "";
|
|
@@ -378,11 +391,16 @@ export interface PendingGithubEvent {
|
|
|
378
391
|
export interface Snapshot {
|
|
379
392
|
id: string;
|
|
380
393
|
creationTime: string;
|
|
394
|
+
availableTime?: string;
|
|
381
395
|
originalWorkspaceId: string;
|
|
382
396
|
bucketId: string;
|
|
383
397
|
layoutData?: string;
|
|
398
|
+
state: SnapshotState;
|
|
399
|
+
message?: string;
|
|
384
400
|
}
|
|
385
401
|
|
|
402
|
+
export type SnapshotState = 'pending' | 'available' | 'error';
|
|
403
|
+
|
|
386
404
|
export interface LayoutData {
|
|
387
405
|
workspaceId: string;
|
|
388
406
|
lastUpdatedTime: string;
|
|
@@ -559,6 +577,9 @@ export interface WorkspaceConfig {
|
|
|
559
577
|
github?: GithubAppConfig;
|
|
560
578
|
vscode?: VSCodeConfig;
|
|
561
579
|
|
|
580
|
+
/** deprecated. Enabled by default **/
|
|
581
|
+
experimentalNetwork?: boolean;
|
|
582
|
+
|
|
562
583
|
/**
|
|
563
584
|
* Where the config object originates from.
|
|
564
585
|
*
|
|
@@ -586,7 +607,7 @@ export interface GithubAppPrebuildConfig {
|
|
|
586
607
|
branches?: boolean
|
|
587
608
|
pullRequests?: boolean
|
|
588
609
|
pullRequestsFromForks?: boolean
|
|
589
|
-
addCheck?: boolean
|
|
610
|
+
addCheck?: boolean | 'prevent-merge-on-error'
|
|
590
611
|
addBadge?: boolean
|
|
591
612
|
addLabel?: boolean | string
|
|
592
613
|
addComment?: boolean
|
|
@@ -682,6 +703,8 @@ export interface PortConfig {
|
|
|
682
703
|
port: number;
|
|
683
704
|
onOpen?: PortOnOpen;
|
|
684
705
|
visibility?: PortVisibility;
|
|
706
|
+
description?: string;
|
|
707
|
+
name?: string;
|
|
685
708
|
}
|
|
686
709
|
export namespace PortConfig {
|
|
687
710
|
export function is(config: any): config is PortConfig {
|
|
@@ -769,6 +792,7 @@ export namespace ExternalImageConfigFile {
|
|
|
769
792
|
|
|
770
793
|
export interface WorkspaceContext {
|
|
771
794
|
title: string;
|
|
795
|
+
/** This contains the URL portion of the contextURL (which might contain other modifiers as well). It's optional because it's not set for older workspaces. */
|
|
772
796
|
normalizedContextURL?: string;
|
|
773
797
|
forceCreateNewWorkspace?: boolean;
|
|
774
798
|
forceImageBuild?: boolean;
|
|
@@ -868,8 +892,20 @@ export namespace PrebuiltWorkspaceContext {
|
|
|
868
892
|
}
|
|
869
893
|
}
|
|
870
894
|
|
|
895
|
+
export interface WithReferrerContext extends WorkspaceContext {
|
|
896
|
+
referrer: string
|
|
897
|
+
referrerIde?: string
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
export namespace WithReferrerContext {
|
|
901
|
+
export function is(context: any): context is WithReferrerContext {
|
|
902
|
+
return context
|
|
903
|
+
&& 'referrer' in context;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
871
907
|
export interface WithEnvvarsContext extends WorkspaceContext {
|
|
872
|
-
envvars:
|
|
908
|
+
envvars: EnvVarWithValue[];
|
|
873
909
|
}
|
|
874
910
|
|
|
875
911
|
export namespace WithEnvvarsContext {
|
|
@@ -1167,39 +1203,6 @@ export namespace AuthProviderEntry {
|
|
|
1167
1203
|
}
|
|
1168
1204
|
}
|
|
1169
1205
|
|
|
1170
|
-
export interface Branding {
|
|
1171
|
-
readonly name: string;
|
|
1172
|
-
readonly favicon?: string;
|
|
1173
|
-
/** Either including domain OR absolute path (interpreted relative to host URL) */
|
|
1174
|
-
readonly logo: string;
|
|
1175
|
-
readonly startupLogo: string;
|
|
1176
|
-
readonly showProductivityTips: boolean;
|
|
1177
|
-
readonly redirectUrlIfNotAuthenticated?: string;
|
|
1178
|
-
readonly redirectUrlAfterLogout?: string;
|
|
1179
|
-
readonly homepage: string;
|
|
1180
|
-
readonly ide?: {
|
|
1181
|
-
readonly logo: string;
|
|
1182
|
-
readonly showReleaseNotes: boolean;
|
|
1183
|
-
readonly helpMenu: Branding.Link[];
|
|
1184
|
-
}
|
|
1185
|
-
readonly links: {
|
|
1186
|
-
readonly header: Branding.Link[];
|
|
1187
|
-
readonly footer: Branding.Link[];
|
|
1188
|
-
readonly social: Branding.SocialLink[];
|
|
1189
|
-
readonly legal: Branding.Link[];
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
export namespace Branding {
|
|
1193
|
-
export interface Link {
|
|
1194
|
-
readonly name: string;
|
|
1195
|
-
readonly url: string;
|
|
1196
|
-
}
|
|
1197
|
-
export interface SocialLink {
|
|
1198
|
-
readonly type: string;
|
|
1199
|
-
readonly url: string;
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
1206
|
export interface Configuration {
|
|
1204
1207
|
readonly daysBeforeGarbageCollection: number;
|
|
1205
1208
|
readonly garbageCollectionStartDate: number;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { SnapshotUrl } from ".";
|
|
10
|
+
|
|
11
|
+
const expect = chai.expect
|
|
12
|
+
|
|
13
|
+
@suite class TestSnapshotUrlParser {
|
|
14
|
+
|
|
15
|
+
@test public testPositive() {
|
|
16
|
+
const actual = SnapshotUrl.parse("workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar@gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd");
|
|
17
|
+
|
|
18
|
+
expect(actual).to.deep.equal(<SnapshotUrl>{
|
|
19
|
+
bucketId: "gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd",
|
|
20
|
+
filename: "3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
|
|
21
|
+
fullPath: "workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
module.exports = new TestSnapshotUrlParser() // Only to circumvent no usage warning :-/
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021 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
|
+
export interface SnapshotUrl {
|
|
8
|
+
bucketId: string;
|
|
9
|
+
fullPath: string;
|
|
10
|
+
filename: string;
|
|
11
|
+
}
|
|
12
|
+
export namespace SnapshotUrl {
|
|
13
|
+
export function parse(url: string): SnapshotUrl {
|
|
14
|
+
const parts = url.split("@");
|
|
15
|
+
if (parts.length !== 2) {
|
|
16
|
+
throw new Error(`cannot parse snapshot URL: ${url}`);
|
|
17
|
+
}
|
|
18
|
+
const [fullPath, bucketId] = parts;
|
|
19
|
+
|
|
20
|
+
const pathParts = fullPath.split("/");
|
|
21
|
+
if (pathParts.length < 1) {
|
|
22
|
+
throw new Error(`cannot parse snapshot URL: ${url}`);
|
|
23
|
+
}
|
|
24
|
+
const filename = pathParts[pathParts.length - 1];
|
|
25
|
+
return { bucketId, fullPath, filename };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -5,20 +5,27 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { PrebuiltWorkspaceState } from "./protocol";
|
|
8
|
-
import uuidv4
|
|
8
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
9
|
+
import { DeepPartial } from "./util/deep-partial";
|
|
9
10
|
|
|
10
11
|
export interface ProjectConfig {
|
|
11
12
|
'.gitpod.yml': string;
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
export interface ProjectSettings {
|
|
16
|
+
useIncrementalPrebuilds?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
export interface Project {
|
|
15
20
|
id: string;
|
|
16
21
|
name: string;
|
|
22
|
+
slug?: string;
|
|
17
23
|
cloneUrl: string;
|
|
18
24
|
teamId?: string;
|
|
19
25
|
userId?: string;
|
|
20
26
|
appInstallationId: string;
|
|
21
27
|
config?: ProjectConfig;
|
|
28
|
+
settings?: ProjectSettings;
|
|
22
29
|
creationTime: string;
|
|
23
30
|
/** This is a flag that triggers the HARD DELETION of this entity */
|
|
24
31
|
deleted?: boolean;
|
|
@@ -54,6 +61,8 @@ export namespace Project {
|
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
|
|
64
|
+
export type PartialProject = DeepPartial<Project> & Pick<Project, 'id'>;
|
|
65
|
+
|
|
57
66
|
export interface PrebuildWithStatus {
|
|
58
67
|
info: PrebuildInfo;
|
|
59
68
|
status: PrebuiltWorkspaceState;
|
|
@@ -63,6 +72,7 @@ export interface PrebuildWithStatus {
|
|
|
63
72
|
export interface PrebuildInfo {
|
|
64
73
|
id: string;
|
|
65
74
|
buildWorkspaceId: string;
|
|
75
|
+
basedOnPrebuildId?: string;
|
|
66
76
|
|
|
67
77
|
teamId?: string;
|
|
68
78
|
userId?: string;
|
|
@@ -92,6 +102,7 @@ export namespace PrebuildInfo {
|
|
|
92
102
|
}
|
|
93
103
|
|
|
94
104
|
export interface StartPrebuildResult {
|
|
105
|
+
prebuildId: string;
|
|
95
106
|
wsid: string;
|
|
96
107
|
done: boolean;
|
|
97
108
|
}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { repeat } from "./repeat";
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
interface CacheEntry<T> {
|
|
9
11
|
key: string;
|
|
@@ -41,8 +43,12 @@ export class GarbageCollectedCache<T> {
|
|
|
41
43
|
return entry.value;
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
public delete(key: string) {
|
|
47
|
+
this.store.delete(key);
|
|
48
|
+
}
|
|
49
|
+
|
|
44
50
|
protected regularlyCollectGarbage() {
|
|
45
|
-
|
|
51
|
+
repeat(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
protected collectGarbage() {
|
|
@@ -27,5 +27,22 @@ const expect = chai.expect
|
|
|
27
27
|
expect(longestName.length <= 36, `"${longestName}" is longer than 36 chars (${longestName.length})`).to.be.true;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
@test public async testCustomName() {
|
|
31
|
+
const data = [
|
|
32
|
+
['foo','bar','foo-bar-'],
|
|
33
|
+
['f','bar','.{2,16}-bar-'],
|
|
34
|
+
['gitpod-io','gitpod','gitpodio-gitpod-'],
|
|
35
|
+
['this is rather long and has some "§$"% special chars','also here pretty long and needs abbreviation','thisisratherlon-alsohere-'],
|
|
36
|
+
['breatheco-de', 'python-flask-api-tutorial', 'breathecode-pythonflaska-'],
|
|
37
|
+
['UPPER', "CaSe", "upper-case-"]
|
|
38
|
+
]
|
|
39
|
+
for (const d of data) {
|
|
40
|
+
const id = await generateWorkspaceID(d[0], d[1]);
|
|
41
|
+
expect(id).match(new RegExp("^"+d[2]));
|
|
42
|
+
expect(new GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
|
|
43
|
+
expect(id.length <= 36, `"${id}" is longer than 36 chars (${id.length})`).to.be.true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
30
47
|
}
|
|
31
48
|
module.exports = new TestGenerateWorkspaceId()
|
|
@@ -5,8 +5,26 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import randomNumber = require("random-number-csprng");
|
|
7
7
|
|
|
8
|
-
export async function generateWorkspaceID(): Promise<string> {
|
|
9
|
-
|
|
8
|
+
export async function generateWorkspaceID(firstSegment?: string, secondSegment?: string): Promise<string> {
|
|
9
|
+
const firstSeg = clean(firstSegment) || await random(colors);
|
|
10
|
+
const secSeg = clean(secondSegment, Math.min(15, 23 - firstSeg.length)) || await random(animals);
|
|
11
|
+
return firstSeg+'-'+secSeg+'-'+(await random(characters, 11));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function clean(segment: string | undefined, maxChars: number = 15) {
|
|
15
|
+
if (!segment) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
segment = segment.toLowerCase();
|
|
19
|
+
let result = '';
|
|
20
|
+
for (let i =0; i < segment.length; i++) {
|
|
21
|
+
if (characters.indexOf(segment[i]) !== -1) {
|
|
22
|
+
result += segment[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (result.length >= 2) {
|
|
26
|
+
return result.substring(0, maxChars);
|
|
27
|
+
}
|
|
10
28
|
}
|
|
11
29
|
|
|
12
30
|
async function random(array: string[], length: number = 1): Promise<string> {
|