@gitpod/gitpod-protocol 0.1.5-server-vscode-ouath2.18 → 0.1.5-server-vscode-oauth2.11
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/lib/accounting-protocol.js +6 -6
- 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 +12 -1
- package/lib/analytics.d.ts.map +1 -1
- package/lib/context-url.js +4 -4
- 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 +3 -3
- 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.d.ts +0 -1
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +12 -14
- 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 +12 -2
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +148 -294
- package/lib/gitpod-service.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +3 -3
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +172 -35
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.js +34 -54
- 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/handler.d.ts +10 -0
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +20 -20
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +2 -0
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +73 -160
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/permission.d.ts +1 -2
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +12 -13
- package/lib/permission.js.map +1 -1
- package/lib/plans.js +38 -57
- package/lib/plans.js.map +1 -1
- package/lib/protocol.js +44 -114
- package/lib/protocol.js.map +1 -1
- package/lib/team-subscription-protocol.js +11 -11
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +3 -1
- 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.d.ts.map +1 -1
- package/lib/util/analytics.js +35 -26
- 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.js +22 -46
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.js +11 -67
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +34 -79
- 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.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/logging.d.ts.map +1 -1
- package/lib/util/logging.js +68 -109
- 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/repeater.js +35 -88
- package/lib/util/repeater.js.map +1 -1
- 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.js +43 -47
- package/lib/util/tracing.js.map +1 -1
- 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 +2 -0
- package/lib/workspace-instance.d.ts.map +1 -1
- package/package.json +3 -1
- package/pkg-yarn.lock +2 -1
- package/src/admin-protocol.ts +9 -3
- package/src/analytics.ts +14 -1
- package/src/env.ts +0 -1
- package/src/gitpod-service.ts +13 -2
- package/src/messaging/browser/connection.ts +176 -10
- package/src/messaging/handler.ts +12 -0
- package/src/messaging/proxy-factory.ts +10 -4
- package/src/permission.ts +0 -1
- package/src/teams-projects-protocol.ts +3 -1
- package/src/util/analytics.ts +17 -1
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/grpc.ts +3 -3
- package/src/util/logging.ts +33 -20
- package/src/util/parse-workspace-id.spec.ts +21 -1
- package/src/util/parse-workspace-id.ts +32 -6
- package/src/workspace-cluster.ts +8 -1
- package/src/workspace-instance.ts +6 -0
|
@@ -22,87 +22,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
-
default:
|
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
-
if (t[2]) _.ops.pop();
|
|
45
|
-
_.trys.pop(); continue;
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const mocha_typescript_1 = require("mocha-typescript");
|
|
27
|
+
const chai = require("chai");
|
|
28
|
+
const generate_workspace_id_1 = require("./generate-workspace-id");
|
|
29
|
+
const gitpod_host_url_1 = require("./gitpod-host-url");
|
|
30
|
+
const expect = chai.expect;
|
|
31
|
+
let TestGenerateWorkspaceId = class TestGenerateWorkspaceId {
|
|
32
|
+
testGenerateWorkspaceId() {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
for (let i = 0; i < 100; i++) {
|
|
35
|
+
const id = yield generate_workspace_id_1.generateWorkspaceID();
|
|
36
|
+
expect(new gitpod_host_url_1.GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
|
|
46
37
|
}
|
|
47
|
-
|
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
38
|
+
});
|
|
50
39
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var gitpod_host_url_1 = require("./gitpod-host-url");
|
|
57
|
-
var expect = chai.expect;
|
|
58
|
-
var TestGenerateWorkspaceId = /** @class */ (function () {
|
|
59
|
-
function TestGenerateWorkspaceId() {
|
|
40
|
+
testLongestName() {
|
|
41
|
+
const longestColor = generate_workspace_id_1.colors.sort((a, b) => b.length - a.length)[0];
|
|
42
|
+
const longestAnimal = generate_workspace_id_1.animals.sort((a, b) => b.length - a.length)[0];
|
|
43
|
+
const longestName = `${longestColor}-${longestAnimal}-12345678`;
|
|
44
|
+
expect(longestName.length <= 36, `"${longestName}" is longer than 36 chars (${longestName.length})`).to.be.true;
|
|
60
45
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
i++;
|
|
78
|
-
return [3 /*break*/, 1];
|
|
79
|
-
case 4: return [2 /*return*/];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
TestGenerateWorkspaceId.prototype.testLongestName = function () {
|
|
85
|
-
var longestColor = generate_workspace_id_1.colors.sort(function (a, b) { return b.length - a.length; })[0];
|
|
86
|
-
var longestAnimal = generate_workspace_id_1.animals.sort(function (a, b) { return b.length - a.length; })[0];
|
|
87
|
-
var longestName = longestColor + "-" + longestAnimal + "-12345678";
|
|
88
|
-
expect(longestName.length <= 36, "\"" + longestName + "\" is longer than 36 chars (" + longestName.length + ")").to.be.true;
|
|
89
|
-
};
|
|
90
|
-
__decorate([
|
|
91
|
-
mocha_typescript_1.test,
|
|
92
|
-
__metadata("design:type", Function),
|
|
93
|
-
__metadata("design:paramtypes", []),
|
|
94
|
-
__metadata("design:returntype", Promise)
|
|
95
|
-
], TestGenerateWorkspaceId.prototype, "testGenerateWorkspaceId", null);
|
|
96
|
-
__decorate([
|
|
97
|
-
mocha_typescript_1.test,
|
|
98
|
-
__metadata("design:type", Function),
|
|
99
|
-
__metadata("design:paramtypes", []),
|
|
100
|
-
__metadata("design:returntype", void 0)
|
|
101
|
-
], TestGenerateWorkspaceId.prototype, "testLongestName", null);
|
|
102
|
-
TestGenerateWorkspaceId = __decorate([
|
|
103
|
-
mocha_typescript_1.suite
|
|
104
|
-
], TestGenerateWorkspaceId);
|
|
105
|
-
return TestGenerateWorkspaceId;
|
|
106
|
-
}());
|
|
46
|
+
};
|
|
47
|
+
__decorate([
|
|
48
|
+
mocha_typescript_1.test,
|
|
49
|
+
__metadata("design:type", Function),
|
|
50
|
+
__metadata("design:paramtypes", []),
|
|
51
|
+
__metadata("design:returntype", Promise)
|
|
52
|
+
], TestGenerateWorkspaceId.prototype, "testGenerateWorkspaceId", null);
|
|
53
|
+
__decorate([
|
|
54
|
+
mocha_typescript_1.test,
|
|
55
|
+
__metadata("design:type", Function),
|
|
56
|
+
__metadata("design:paramtypes", []),
|
|
57
|
+
__metadata("design:returntype", void 0)
|
|
58
|
+
], TestGenerateWorkspaceId.prototype, "testLongestName", null);
|
|
59
|
+
TestGenerateWorkspaceId = __decorate([
|
|
60
|
+
mocha_typescript_1.suite
|
|
61
|
+
], TestGenerateWorkspaceId);
|
|
107
62
|
module.exports = new TestGenerateWorkspaceId();
|
|
108
63
|
//# sourceMappingURL=generate-workspace-id.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-workspace-id.spec.js","sourceRoot":"","sources":["../../src/util/generate-workspace-id.spec.ts"],"names":[],"mappings":";AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"generate-workspace-id.spec.js","sourceRoot":"","sources":["../../src/util/generate-workspace-id.spec.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;AAEH,uDAA8C;AAC9C,6BAA4B;AAC5B,mEAA+E;AAC/E,uDAAkD;AAElD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;AAEnB,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAEb,uBAAuB;;YACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;gBAC1B,MAAM,EAAE,GAAG,MAAM,2CAAmB,EAAE,CAAC;gBACvC,MAAM,CAAC,IAAI,+BAAa,EAAE,CAAC,mBAAmB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;aACtF;QACL,CAAC;KAAA;IAEY,eAAe;QACxB,MAAM,YAAY,GAAG,8BAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,MAAM,aAAa,GAAG,+BAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACrE,MAAM,WAAW,GAAG,GAAG,YAAY,IAAI,aAAa,WAAW,CAAC;QAChE,MAAM,CAAC,WAAW,CAAC,MAAM,IAAI,EAAE,EAAE,IAAI,WAAW,8BAA8B,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IACpH,CAAC;CAEJ,CAAA;AAdS;IAAL,uBAAI;;;;sEAKJ;AAEK;IAAL,uBAAI;;;;8DAKJ;AAdQ,uBAAuB;IAAnC,wBAAK;GAAO,uBAAuB,CAgBnC;AACD,MAAM,CAAC,OAAO,GAAG,IAAI,uBAAuB,EAAE,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
import * as cookie from 'cookie';
|
|
7
|
+
/**
|
|
8
|
+
* This cookie indicates whether the connected client is a Gitpod user (= "has logged in within the last year") or not.
|
|
9
|
+
* This is used by "gitpod.io" and "www.gitpod.io" to display different content/buttons.
|
|
10
|
+
*/
|
|
11
|
+
export declare const NAME = "gitpod-user";
|
|
12
|
+
export declare const VALUE = "true";
|
|
13
|
+
/**
|
|
14
|
+
* @param domain The domain the Gitpod installation is installed onto
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export declare function options(domain: string): cookie.CookieSerializeOptions;
|
|
18
|
+
export declare function generateCookie(domain: string): string;
|
|
19
|
+
export declare function isPresent(cookies: string): boolean;
|
|
20
|
+
//# sourceMappingURL=gitpod-cookie.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitpod-cookie.d.ts","sourceRoot":"","sources":["../../src/util/gitpod-cookie.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC;;;GAGG;AACH,eAAO,MAAM,IAAI,gBAAgB,CAAC;AAClC,eAAO,MAAM,KAAK,SAAS,CAAC;AAE5B;;;GAGG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,sBAAsB,CAUrE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGlD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPresent = exports.generateCookie = exports.options = exports.VALUE = exports.NAME = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
|
|
6
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
7
|
+
* See License-AGPL.txt in the project root for license information.
|
|
8
|
+
*/
|
|
9
|
+
const cookie = require("cookie");
|
|
10
|
+
/**
|
|
11
|
+
* This cookie indicates whether the connected client is a Gitpod user (= "has logged in within the last year") or not.
|
|
12
|
+
* This is used by "gitpod.io" and "www.gitpod.io" to display different content/buttons.
|
|
13
|
+
*/
|
|
14
|
+
exports.NAME = "gitpod-user";
|
|
15
|
+
exports.VALUE = "true";
|
|
16
|
+
/**
|
|
17
|
+
* @param domain The domain the Gitpod installation is installed onto
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
function options(domain) {
|
|
21
|
+
// Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
|
|
22
|
+
return {
|
|
23
|
+
path: "/",
|
|
24
|
+
httpOnly: false,
|
|
25
|
+
secure: false,
|
|
26
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
27
|
+
sameSite: "lax",
|
|
28
|
+
domain: `.${domain}`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.options = options;
|
|
32
|
+
;
|
|
33
|
+
function generateCookie(domain) {
|
|
34
|
+
return cookie.serialize(exports.NAME, exports.VALUE, options(domain));
|
|
35
|
+
}
|
|
36
|
+
exports.generateCookie = generateCookie;
|
|
37
|
+
;
|
|
38
|
+
function isPresent(cookies) {
|
|
39
|
+
// needs to match the old (gitpod-user=loggedIn) and new (gitpod-user=true) values to ensure a smooth transition during rollout.
|
|
40
|
+
return !!cookies.match(`${exports.NAME}=`);
|
|
41
|
+
}
|
|
42
|
+
exports.isPresent = isPresent;
|
|
43
|
+
;
|
|
44
|
+
//# sourceMappingURL=gitpod-cookie.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitpod-cookie.js","sourceRoot":"","sources":["../../src/util/gitpod-cookie.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,iCAAiC;AAGjC;;;GAGG;AACU,QAAA,IAAI,GAAG,aAAa,CAAC;AACrB,QAAA,KAAK,GAAG,MAAM,CAAC;AAE5B;;;GAGG;AACH,SAAgB,OAAO,CAAC,MAAc;IAClC,uEAAuE;IACvE,OAAO;QACH,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG;QAC1B,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,IAAI,MAAM,EAAE;KACvB,CAAC;AACN,CAAC;AAVD,0BAUC;AAAA,CAAC;AAEF,SAAgB,cAAc,CAAC,MAAc;IACzC,OAAO,MAAM,CAAC,SAAS,CAAC,YAAI,EAAE,aAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAC1D,CAAC;AAFD,wCAEC;AAAA,CAAC;AAEF,SAAgB,SAAS,CAAC,OAAe;IACrC,gIAAgI;IAChI,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,YAAI,GAAG,CAAC,CAAC;AACvC,CAAC;AAHD,8BAGC;AAAA,CAAC"}
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.GitpodHostUrl = void 0;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const URL = require('url').URL || window.URL;
|
|
10
|
+
const logging_1 = require("./logging");
|
|
11
|
+
const basewoWkspaceIDRegex = "(([a-f][0-9a-f]{7}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})|([0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8}))";
|
|
12
12
|
// this pattern matches v4 UUIDs as well as the new generated workspace ids (e.g. pink-panda-ns35kd21)
|
|
13
|
-
|
|
13
|
+
const workspaceIDRegex = RegExp(`^${basewoWkspaceIDRegex}$`);
|
|
14
14
|
// this pattern matches URL prefixes of workspaces
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const workspaceUrlPrefixRegex = RegExp(`^([0-9]{4,6}-)?${basewoWkspaceIDRegex}\\.`);
|
|
16
|
+
class GitpodHostUrl {
|
|
17
|
+
constructor(urlParam) {
|
|
18
18
|
if (urlParam === undefined || typeof urlParam === 'string') {
|
|
19
19
|
this.url = new URL(urlParam || 'https://gitpod.io');
|
|
20
20
|
this.url.search = '';
|
|
@@ -25,125 +25,115 @@ var GitpodHostUrl = /** @class */ (function () {
|
|
|
25
25
|
this.url = urlParam;
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
|
-
logging_1.log.error('Unexpected urlParam', { urlParam
|
|
28
|
+
logging_1.log.error('Unexpected urlParam', { urlParam });
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
static fromWorkspaceUrl(url) {
|
|
32
32
|
return new GitpodHostUrl(new URL(url));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return this.withDomainPrefix(workspaceId
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return this.with(
|
|
33
|
+
}
|
|
34
|
+
withWorkspacePrefix(workspaceId, region) {
|
|
35
|
+
return this.withDomainPrefix(`${workspaceId}.ws-${region}.`);
|
|
36
|
+
}
|
|
37
|
+
withDomainPrefix(prefix) {
|
|
38
|
+
return this.with(url => ({ host: prefix + url.host }));
|
|
39
39
|
;
|
|
40
|
-
}
|
|
41
|
-
|
|
40
|
+
}
|
|
41
|
+
withoutWorkspacePrefix() {
|
|
42
42
|
if (!this.url.host.match(workspaceUrlPrefixRegex)) {
|
|
43
43
|
// URL has no workspace prefix
|
|
44
44
|
return this;
|
|
45
45
|
}
|
|
46
46
|
return this.withoutDomainPrefix(2);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return this.with(
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
}
|
|
48
|
+
withoutDomainPrefix(removeSegmentsCount) {
|
|
49
|
+
return this.with(url => ({ host: url.host.split('.').splice(removeSegmentsCount).join('.') }));
|
|
50
|
+
}
|
|
51
|
+
with(urlUpdate) {
|
|
52
|
+
const update = typeof urlUpdate === 'function' ? urlUpdate(this.url) : urlUpdate;
|
|
53
|
+
const addSlashToPath = update.pathname && update.pathname.length > 0 && !update.pathname.startsWith('/');
|
|
54
54
|
if (addSlashToPath) {
|
|
55
55
|
update.pathname = '/' + update.pathname;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
const result = Object.assign(new URL(this.toString()), update);
|
|
58
58
|
return new GitpodHostUrl(result);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return updated.with(
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return this.with(
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return this.with(
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return this.with(
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return this.with(
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return this.with(
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return this.with(
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return this.with(
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return this.with(
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (workspaceId === void 0) { workspaceId = this.workspaceId; }
|
|
59
|
+
}
|
|
60
|
+
withApi(urlUpdate) {
|
|
61
|
+
const updated = urlUpdate ? this.with(urlUpdate) : this;
|
|
62
|
+
return updated.with(url => ({ pathname: `/api${url.pathname}` }));
|
|
63
|
+
}
|
|
64
|
+
withContext(contextUrl) {
|
|
65
|
+
return this.with(url => ({ hash: contextUrl }));
|
|
66
|
+
}
|
|
67
|
+
asWebsocket() {
|
|
68
|
+
return this.with(url => ({ protocol: url.protocol === 'https:' ? 'wss:' : 'ws:' }));
|
|
69
|
+
}
|
|
70
|
+
asDashboard() {
|
|
71
|
+
return this.with(url => ({ pathname: '/workspaces/' }));
|
|
72
|
+
}
|
|
73
|
+
asLogin() {
|
|
74
|
+
return this.with(url => ({ pathname: '/login/' }));
|
|
75
|
+
}
|
|
76
|
+
asUpgradeSubscription() {
|
|
77
|
+
return this.with(url => ({ pathname: '/plans/' }));
|
|
78
|
+
}
|
|
79
|
+
asAccessControl() {
|
|
80
|
+
return this.with(url => ({ pathname: '/access-control/' }));
|
|
81
|
+
}
|
|
82
|
+
asSettings() {
|
|
83
|
+
return this.with(url => ({ pathname: '/settings/' }));
|
|
84
|
+
}
|
|
85
|
+
asGraphQLApi() {
|
|
86
|
+
return this.with(url => ({ pathname: '/graphql/' }));
|
|
87
|
+
}
|
|
88
|
+
asStart(workspaceId = this.workspaceId) {
|
|
90
89
|
return this.withoutWorkspacePrefix().with({
|
|
91
90
|
pathname: '/start/',
|
|
92
91
|
hash: '#' + workspaceId
|
|
93
92
|
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return this.with(
|
|
97
|
-
}
|
|
98
|
-
|
|
93
|
+
}
|
|
94
|
+
asWorkspaceAuth(instanceID, redirect) {
|
|
95
|
+
return this.with(url => ({ pathname: `/api/auth/workspace-cookie/${instanceID}`, search: redirect ? "redirect" : "" }));
|
|
96
|
+
}
|
|
97
|
+
toString() {
|
|
99
98
|
return this.url.toString();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
}
|
|
100
|
+
toStringWoRootSlash() {
|
|
101
|
+
let result = this.toString();
|
|
103
102
|
if (result.endsWith('/')) {
|
|
104
103
|
result = result.slice(0, result.length - 1);
|
|
105
104
|
}
|
|
106
105
|
return result;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return matchResults[0];
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
var pathSegs = this.url.pathname.split("/");
|
|
120
|
-
if (pathSegs.length > 3 && pathSegs[1] === "workspace") {
|
|
121
|
-
return pathSegs[2];
|
|
122
|
-
}
|
|
123
|
-
return undefined;
|
|
124
|
-
},
|
|
125
|
-
enumerable: false,
|
|
126
|
-
configurable: true
|
|
127
|
-
});
|
|
128
|
-
Object.defineProperty(GitpodHostUrl.prototype, "blobServe", {
|
|
129
|
-
get: function () {
|
|
130
|
-
var hostSegments = this.url.host.split(".");
|
|
131
|
-
if (hostSegments[0] === 'blobserve') {
|
|
132
|
-
return true;
|
|
106
|
+
}
|
|
107
|
+
get workspaceId() {
|
|
108
|
+
const hostSegs = this.url.host.split(".");
|
|
109
|
+
if (hostSegs.length > 1) {
|
|
110
|
+
const matchResults = hostSegs[0].match(workspaceIDRegex);
|
|
111
|
+
if (matchResults) {
|
|
112
|
+
// URL has a workspace prefix
|
|
113
|
+
// port prefixes are excluded
|
|
114
|
+
return matchResults[0];
|
|
133
115
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
116
|
+
}
|
|
117
|
+
const pathSegs = this.url.pathname.split("/");
|
|
118
|
+
if (pathSegs.length > 3 && pathSegs[1] === "workspace") {
|
|
119
|
+
return pathSegs[2];
|
|
120
|
+
}
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
get blobServe() {
|
|
124
|
+
const hostSegments = this.url.host.split(".");
|
|
125
|
+
if (hostSegments[0] === 'blobserve') {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
const pathSegments = this.url.pathname.split("/");
|
|
129
|
+
return pathSegments[0] === "blobserve";
|
|
130
|
+
}
|
|
131
|
+
asSorry(message) {
|
|
141
132
|
return this.with({ pathname: '/sorry', hash: message });
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return this.withApi(
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
}());
|
|
133
|
+
}
|
|
134
|
+
asApiLogout() {
|
|
135
|
+
return this.withApi(url => ({ pathname: '/logout/' }));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
148
138
|
exports.GitpodHostUrl = GitpodHostUrl;
|
|
149
139
|
//# sourceMappingURL=gitpod-host-url.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitpod-host-url.js","sourceRoot":"","sources":["../../src/util/gitpod-host-url.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"gitpod-host-url.js","sourceRoot":"","sources":["../../src/util/gitpod-host-url.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC;AAC7C,uCAAgC;AAOhC,MAAM,oBAAoB,GAAG,mHAAmH,CAAC;AAEjJ,sGAAsG;AACtG,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,oBAAoB,GAAG,CAAC,CAAC;AAE7D,kDAAkD;AAClD,MAAM,uBAAuB,GAAG,MAAM,CAAC,kBAAkB,oBAAoB,KAAK,CAAC,CAAC;AAEpF,MAAa,aAAa;IAGtB,YAAY,QAAuB;QAC/B,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YACxD,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,IAAI,mBAAmB,CAAC,CAAC;YACpD,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC;YACrB,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC;SAC1B;aAAM,IAAI,QAAQ,YAAY,GAAG,EAAE;YAChC,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC;SACvB;aAAM;YACH,aAAG,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;SAClD;IACL,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,GAAW;QAC/B,OAAO,IAAI,aAAa,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,mBAAmB,CAAC,WAAmB,EAAE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