@gitpod/gitpod-protocol 0.1.5-sje-cert-manager.0 → 0.1.5-sje-server-installation-admin.8

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.
Files changed (214) hide show
  1. package/data/gitpod-schema.json +21 -2
  2. package/lib/accounting-protocol.d.ts +0 -1
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +10 -11
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +8 -2
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +2 -13
  9. package/lib/admin-protocol.js.map +1 -1
  10. package/lib/analytics.d.ts +1 -0
  11. package/lib/analytics.d.ts.map +1 -1
  12. package/lib/context-url.js +4 -4
  13. package/lib/context-url.js.map +1 -1
  14. package/lib/context-url.spec.js +45 -48
  15. package/lib/context-url.spec.js.map +1 -1
  16. package/lib/email-protocol.js +4 -4
  17. package/lib/email-protocol.js.map +1 -1
  18. package/lib/encryption/container-module.js +4 -4
  19. package/lib/encryption/container-module.js.map +1 -1
  20. package/lib/encryption/encryption-engine.js +19 -20
  21. package/lib/encryption/encryption-engine.js.map +1 -1
  22. package/lib/encryption/encryption-engine.spec.js +29 -36
  23. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  24. package/lib/encryption/encryption-service.js +29 -43
  25. package/lib/encryption/encryption-service.js.map +1 -1
  26. package/lib/encryption/key-provider.js +25 -30
  27. package/lib/encryption/key-provider.js.map +1 -1
  28. package/lib/env.js +12 -13
  29. package/lib/env.js.map +1 -1
  30. package/lib/gitpod-file-parser.js +25 -41
  31. package/lib/gitpod-file-parser.js.map +1 -1
  32. package/lib/gitpod-file-parser.spec.js +116 -116
  33. package/lib/gitpod-file-parser.spec.js.map +1 -1
  34. package/lib/gitpod-service.d.ts +24 -11
  35. package/lib/gitpod-service.d.ts.map +1 -1
  36. package/lib/gitpod-service.js +149 -295
  37. package/lib/gitpod-service.js.map +1 -1
  38. package/lib/ide-protocol.d.ts +81 -0
  39. package/lib/ide-protocol.d.ts.map +1 -0
  40. package/lib/ide-protocol.js +8 -0
  41. package/lib/ide-protocol.js.map +1 -0
  42. package/lib/index.d.ts +2 -0
  43. package/lib/index.d.ts.map +1 -1
  44. package/lib/index.js +2 -0
  45. package/lib/index.js.map +1 -1
  46. package/lib/messaging/browser/connection.js +91 -156
  47. package/lib/messaging/browser/connection.js.map +1 -1
  48. package/lib/messaging/browser/window-connection.js +35 -55
  49. package/lib/messaging/browser/window-connection.js.map +1 -1
  50. package/lib/messaging/client-call-metrics.js +17 -18
  51. package/lib/messaging/client-call-metrics.js.map +1 -1
  52. package/lib/messaging/connection-error-handler.js +11 -23
  53. package/lib/messaging/connection-error-handler.js.map +1 -1
  54. package/lib/messaging/error.d.ts +1 -1
  55. package/lib/messaging/error.d.ts.map +1 -1
  56. package/lib/messaging/error.js +2 -2
  57. package/lib/messaging/error.js.map +1 -1
  58. package/lib/messaging/node/connection.d.ts +0 -10
  59. package/lib/messaging/node/connection.d.ts.map +1 -1
  60. package/lib/messaging/node/connection.js +11 -49
  61. package/lib/messaging/node/connection.js.map +1 -1
  62. package/lib/messaging/proxy-factory.js +71 -162
  63. package/lib/messaging/proxy-factory.js.map +1 -1
  64. package/lib/oss-allowlist.d.ts +14 -0
  65. package/lib/oss-allowlist.d.ts.map +1 -0
  66. package/lib/oss-allowlist.js +8 -0
  67. package/lib/oss-allowlist.js.map +1 -0
  68. package/lib/permission.js +12 -12
  69. package/lib/permission.js.map +1 -1
  70. package/lib/plans.d.ts +1 -1
  71. package/lib/plans.d.ts.map +1 -1
  72. package/lib/plans.js +38 -57
  73. package/lib/plans.js.map +1 -1
  74. package/lib/protocol.d.ts +13 -40
  75. package/lib/protocol.d.ts.map +1 -1
  76. package/lib/protocol.js +44 -114
  77. package/lib/protocol.js.map +1 -1
  78. package/lib/snapshot-url.d.ts +14 -0
  79. package/lib/snapshot-url.d.ts.map +1 -0
  80. package/lib/snapshot-url.js +26 -0
  81. package/lib/snapshot-url.js.map +1 -0
  82. package/lib/snapshot-url.spec.d.ts +7 -0
  83. package/lib/snapshot-url.spec.d.ts.map +1 -0
  84. package/lib/snapshot-url.spec.js +41 -0
  85. package/lib/snapshot-url.spec.js.map +1 -0
  86. package/lib/team-subscription-protocol.js +13 -13
  87. package/lib/team-subscription-protocol.js.map +1 -1
  88. package/lib/teams-projects-protocol.d.ts +15 -0
  89. package/lib/teams-projects-protocol.d.ts.map +1 -1
  90. package/lib/teams-projects-protocol.js +4 -15
  91. package/lib/teams-projects-protocol.js.map +1 -1
  92. package/lib/util/analytics.js +25 -32
  93. package/lib/util/analytics.js.map +1 -1
  94. package/lib/util/async-iterator.js +55 -133
  95. package/lib/util/async-iterator.js.map +1 -1
  96. package/lib/util/cancelable.js +17 -59
  97. package/lib/util/cancelable.js.map +1 -1
  98. package/lib/util/date-time.js +8 -8
  99. package/lib/util/date-time.js.map +1 -1
  100. package/lib/util/deferred.js +10 -12
  101. package/lib/util/deferred.js.map +1 -1
  102. package/lib/util/disposable.js +26 -39
  103. package/lib/util/disposable.js.map +1 -1
  104. package/lib/util/event.js +58 -74
  105. package/lib/util/event.js.map +1 -1
  106. package/lib/util/garbage-collected-cache.d.ts +1 -0
  107. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  108. package/lib/util/garbage-collected-cache.js +26 -46
  109. package/lib/util/garbage-collected-cache.js.map +1 -1
  110. package/lib/util/generate-workspace-id.d.ts +1 -1
  111. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  112. package/lib/util/generate-workspace-id.js +28 -68
  113. package/lib/util/generate-workspace-id.js.map +1 -1
  114. package/lib/util/generate-workspace-id.spec.js +56 -78
  115. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  116. package/lib/util/gitpod-cookie.d.ts +20 -0
  117. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  118. package/lib/util/gitpod-cookie.js +44 -0
  119. package/lib/util/gitpod-cookie.js.map +1 -0
  120. package/lib/util/gitpod-host-url.d.ts +1 -1
  121. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  122. package/lib/util/gitpod-host-url.js +93 -103
  123. package/lib/util/gitpod-host-url.js.map +1 -1
  124. package/lib/util/gitpod-host-url.spec.js +87 -135
  125. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  126. package/lib/util/jaeger-client-types.d.ts +68 -0
  127. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  128. package/lib/util/jaeger-client-types.js +8 -0
  129. package/lib/util/jaeger-client-types.js.map +1 -0
  130. package/lib/util/logging.d.ts +32 -32
  131. package/lib/util/logging.d.ts.map +1 -1
  132. package/lib/util/logging.js +50 -113
  133. package/lib/util/logging.js.map +1 -1
  134. package/lib/util/make-link.js +2 -2
  135. package/lib/util/make-link.js.map +1 -1
  136. package/lib/util/parse-workspace-id.d.ts +10 -0
  137. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  138. package/lib/util/parse-workspace-id.js +31 -7
  139. package/lib/util/parse-workspace-id.js.map +1 -1
  140. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  141. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  142. package/lib/util/parse-workspace-id.spec.js +123 -84
  143. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  144. package/lib/util/queue.js +16 -55
  145. package/lib/util/queue.js.map +1 -1
  146. package/lib/util/queue.spec.js +144 -288
  147. package/lib/util/queue.spec.js.map +1 -1
  148. package/lib/util/repeat.d.ts +15 -0
  149. package/lib/util/repeat.d.ts.map +1 -0
  150. package/lib/util/repeat.js +55 -0
  151. package/lib/util/repeat.js.map +1 -0
  152. package/lib/util/safe-promise.js +9 -12
  153. package/lib/util/safe-promise.js.map +1 -1
  154. package/lib/util/semaphore.js +15 -46
  155. package/lib/util/semaphore.js.map +1 -1
  156. package/lib/util/skip-if.js +6 -6
  157. package/lib/util/skip-if.js.map +1 -1
  158. package/lib/util/timeutil.js +16 -16
  159. package/lib/util/timeutil.js.map +1 -1
  160. package/lib/util/timeutil.spec.js +21 -24
  161. package/lib/util/timeutil.spec.js.map +1 -1
  162. package/lib/util/tracing.d.ts +51 -5
  163. package/lib/util/tracing.d.ts.map +1 -1
  164. package/lib/util/tracing.js +193 -62
  165. package/lib/util/tracing.js.map +1 -1
  166. package/lib/util/tracing.spec.d.ts +7 -0
  167. package/lib/util/tracing.spec.d.ts.map +1 -0
  168. package/lib/util/tracing.spec.js +121 -0
  169. package/lib/util/tracing.spec.js.map +1 -0
  170. package/lib/util/workspace-port-authentication.js +2 -2
  171. package/lib/util/workspace-port-authentication.js.map +1 -1
  172. package/lib/workspace-cluster.js +3 -3
  173. package/lib/workspace-cluster.js.map +1 -1
  174. package/lib/workspace-instance.d.ts +3 -2
  175. package/lib/workspace-instance.d.ts.map +1 -1
  176. package/lib/wsready.js +1 -1
  177. package/package.json +22 -13
  178. package/pkg-yarn.lock +12 -7
  179. package/provenance-bundle.jsonl +2 -0
  180. package/src/accounting-protocol.ts +1 -3
  181. package/src/admin-protocol.ts +9 -3
  182. package/src/analytics.ts +2 -0
  183. package/src/email-protocol.ts +1 -1
  184. package/src/gitpod-service.ts +27 -16
  185. package/src/ide-protocol.ts +92 -0
  186. package/src/index.ts +2 -0
  187. package/src/messaging/error.ts +2 -2
  188. package/src/messaging/node/connection.ts +1 -45
  189. package/src/oss-allowlist.ts +15 -0
  190. package/src/protocol.ts +17 -42
  191. package/src/snapshot-url.spec.ts +25 -0
  192. package/src/snapshot-url.ts +27 -0
  193. package/src/team-subscription-protocol.ts +1 -1
  194. package/src/teams-projects-protocol.ts +19 -1
  195. package/src/util/garbage-collected-cache.ts +7 -1
  196. package/src/util/generate-workspace-id.spec.ts +16 -0
  197. package/src/util/generate-workspace-id.ts +19 -2
  198. package/src/util/gitpod-cookie.ts +39 -0
  199. package/src/util/gitpod-host-url.ts +10 -10
  200. package/src/util/jaeger-client-types.ts +102 -0
  201. package/src/util/logging.ts +32 -32
  202. package/src/util/parse-workspace-id.spec.ts +21 -1
  203. package/src/util/parse-workspace-id.ts +32 -6
  204. package/src/util/repeat.ts +45 -0
  205. package/src/util/tracing.spec.ts +83 -0
  206. package/src/util/tracing.ts +180 -18
  207. package/src/workspace-instance.ts +9 -6
  208. package/src/wsready.ts +1 -1
  209. package/lib/util/repeater.d.ts +0 -22
  210. package/lib/util/repeater.d.ts.map +0 -1
  211. package/lib/util/repeater.js +0 -118
  212. package/lib/util/repeater.js.map +0 -1
  213. package/src/util/jaeger-client.d.ts +0 -105
  214. package/src/util/repeater.ts +0 -49
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,8 @@ export interface EmailNotificationSettings {
114
117
 
115
118
  export type IDESettings = {
116
119
  defaultIde?: string
120
+ useDesktopIde?: boolean
121
+ defaultDesktopIde?: string
117
122
  }
118
123
 
119
124
  export interface UserPlatform {
@@ -135,14 +140,6 @@ export interface UserPlatform {
135
140
  }
136
141
 
137
142
  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
143
  /**
147
144
  * Permanent feature flags are added to each and every workspace instance
148
145
  * this user starts.
@@ -378,11 +375,16 @@ export interface PendingGithubEvent {
378
375
  export interface Snapshot {
379
376
  id: string;
380
377
  creationTime: string;
378
+ availableTime?: string;
381
379
  originalWorkspaceId: string;
382
380
  bucketId: string;
383
381
  layoutData?: string;
382
+ state: SnapshotState;
383
+ message?: string;
384
384
  }
385
385
 
386
+ export type SnapshotState = 'pending' | 'available' | 'error';
387
+
386
388
  export interface LayoutData {
387
389
  workspaceId: string;
388
390
  lastUpdatedTime: string;
@@ -559,6 +561,9 @@ export interface WorkspaceConfig {
559
561
  github?: GithubAppConfig;
560
562
  vscode?: VSCodeConfig;
561
563
 
564
+ /** deprecated. Enabled by default **/
565
+ experimentalNetwork?: boolean;
566
+
562
567
  /**
563
568
  * Where the config object originates from.
564
569
  *
@@ -586,7 +591,7 @@ export interface GithubAppPrebuildConfig {
586
591
  branches?: boolean
587
592
  pullRequests?: boolean
588
593
  pullRequestsFromForks?: boolean
589
- addCheck?: boolean
594
+ addCheck?: boolean | 'prevent-merge-on-error'
590
595
  addBadge?: boolean
591
596
  addLabel?: boolean | string
592
597
  addComment?: boolean
@@ -682,6 +687,8 @@ export interface PortConfig {
682
687
  port: number;
683
688
  onOpen?: PortOnOpen;
684
689
  visibility?: PortVisibility;
690
+ description?: string;
691
+ name?: string;
685
692
  }
686
693
  export namespace PortConfig {
687
694
  export function is(config: any): config is PortConfig {
@@ -769,6 +776,7 @@ export namespace ExternalImageConfigFile {
769
776
 
770
777
  export interface WorkspaceContext {
771
778
  title: string;
779
+ /** 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
780
  normalizedContextURL?: string;
773
781
  forceCreateNewWorkspace?: boolean;
774
782
  forceImageBuild?: boolean;
@@ -1167,39 +1175,6 @@ export namespace AuthProviderEntry {
1167
1175
  }
1168
1176
  }
1169
1177
 
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
1178
  export interface Configuration {
1204
1179
  readonly daysBeforeGarbageCollection: number;
1205
1180
  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
+ }
@@ -4,7 +4,7 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import uuidv4 = require("uuid/v4");
7
+ import { v4 as uuidv4 } from 'uuid';
8
8
  import { Subscription } from "./accounting-protocol";
9
9
 
10
10
  export interface TeamSubscription {
@@ -5,20 +5,27 @@
5
5
  */
6
6
 
7
7
  import { PrebuiltWorkspaceState } from "./protocol";
8
- import uuidv4 = require("uuid/v4");
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
  }
@@ -106,6 +117,13 @@ export interface Team {
106
117
  deleted?: boolean;
107
118
  }
108
119
 
120
+ export interface InstallationAdmin {
121
+ id: string;
122
+ sendTelemetry: boolean;
123
+ createdAt: Date;
124
+ updatedAt: Date;
125
+ }
126
+
109
127
  export type TeamMemberRole = "owner" | "member";
110
128
 
111
129
  export interface TeamMemberInfo {
@@ -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
- setInterval(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
51
+ repeat(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
46
52
  }
47
53
 
48
54
  protected collectGarbage() {
@@ -27,5 +27,21 @@ 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
+ ]
38
+ for (const d of data) {
39
+ const id = await generateWorkspaceID(d[0], d[1]);
40
+ expect(id).match(new RegExp("^"+d[2]));
41
+ expect(new GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
42
+ expect(id.length <= 36, `"${id}" is longer than 36 chars (${id.length})`).to.be.true;
43
+ }
44
+ }
45
+
30
46
  }
31
47
  module.exports = new TestGenerateWorkspaceId()
@@ -5,8 +5,25 @@
5
5
  */
6
6
  import randomNumber = require("random-number-csprng");
7
7
 
8
- export async function generateWorkspaceID(): Promise<string> {
9
- return (await random(colors))+'-'+(await random(animals))+'-'+(await random(characters, 8));
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
+ let result = '';
19
+ for (let i =0; i < segment.length; i++) {
20
+ if (characters.indexOf(segment[i]) !== -1) {
21
+ result += segment[i];
22
+ }
23
+ }
24
+ if (result.length >= 2) {
25
+ return result.substring(0, maxChars);
26
+ }
10
27
  }
11
28
 
12
29
  async function random(array: string[], length: number = 1): Promise<string> {
@@ -0,0 +1,39 @@
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
+
9
+ /**
10
+ * This cookie indicates whether the connected client is a Gitpod user (= "has logged in within the last year") or not.
11
+ * This is used by "gitpod.io" and "www.gitpod.io" to display different content/buttons.
12
+ */
13
+ export const NAME = "gitpod-user";
14
+ export const VALUE = "true";
15
+
16
+ /**
17
+ * @param domain The domain the Gitpod installation is installed onto
18
+ * @returns
19
+ */
20
+ export function options(domain: string): cookie.CookieSerializeOptions {
21
+ // Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
22
+ return {
23
+ path: "/", // make sure we send the cookie to all sub-pages
24
+ httpOnly: false,
25
+ secure: false,
26
+ maxAge: 60 * 60 * 24 * 365, // 1 year
27
+ sameSite: "lax", // default: true. "Lax" needed to ensure we see cookies from users that neavigate to gitpod.io from external sites
28
+ domain: `.${domain}`, // explicilty include subdomains to not only cover "gitpod.io", but also "www.gitpod.io" or workspaces
29
+ };
30
+ };
31
+
32
+ export function generateCookie(domain: string): string {
33
+ return cookie.serialize(NAME, VALUE, options(domain));
34
+ };
35
+
36
+ export function isPresent(cookies: string): boolean {
37
+ // needs to match the old (gitpod-user=loggedIn) and new (gitpod-user=true) values to ensure a smooth transition during rollout.
38
+ return !!cookies.match(`${NAME}=`);
39
+ };
@@ -12,13 +12,13 @@ export interface UrlChange {
12
12
  }
13
13
  export type UrlUpdate = UrlChange | Partial<URL>;
14
14
 
15
- 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}))";
15
+ const baseWorkspaceIDRegex = "(([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,11}))";
16
16
 
17
17
  // this pattern matches v4 UUIDs as well as the new generated workspace ids (e.g. pink-panda-ns35kd21)
18
- const workspaceIDRegex = RegExp(`^${basewoWkspaceIDRegex}$`);
18
+ const workspaceIDRegex = RegExp(`^${baseWorkspaceIDRegex}$`);
19
19
 
20
20
  // this pattern matches URL prefixes of workspaces
21
- const workspaceUrlPrefixRegex = RegExp(`^([0-9]{4,6}-)?${basewoWkspaceIDRegex}\\.`);
21
+ const workspaceUrlPrefixRegex = RegExp(`^([0-9]{4,6}-)?${baseWorkspaceIDRegex}\\.`);
22
22
 
23
23
  export class GitpodHostUrl {
24
24
  readonly url: URL;
@@ -85,27 +85,27 @@ export class GitpodHostUrl {
85
85
  }
86
86
 
87
87
  asDashboard(): GitpodHostUrl {
88
- return this.with(url => ({ pathname: '/workspaces/' }));
88
+ return this.with(url => ({ pathname: '/' }));
89
89
  }
90
90
 
91
91
  asLogin(): GitpodHostUrl {
92
- return this.with(url => ({ pathname: '/login/' }));
92
+ return this.with(url => ({ pathname: '/login' }));
93
93
  }
94
94
 
95
95
  asUpgradeSubscription(): GitpodHostUrl {
96
- return this.with(url => ({ pathname: '/plans/' }));
96
+ return this.with(url => ({ pathname: '/plans' }));
97
97
  }
98
98
 
99
99
  asAccessControl(): GitpodHostUrl {
100
- return this.with(url => ({ pathname: '/access-control/' }));
100
+ return this.with(url => ({ pathname: '/integrations' }));
101
101
  }
102
102
 
103
103
  asSettings(): GitpodHostUrl {
104
- return this.with(url => ({ pathname: '/settings/' }));
104
+ return this.with(url => ({ pathname: '/settings' }));
105
105
  }
106
106
 
107
- asGraphQLApi(): GitpodHostUrl {
108
- return this.with(url => ({ pathname: '/graphql/' }));
107
+ asPreferences(): GitpodHostUrl {
108
+ return this.with(url => ({ pathname: '/preferences' }));
109
109
  }
110
110
 
111
111
  asStart(workspaceId = this.workspaceId): GitpodHostUrl {
@@ -0,0 +1,102 @@
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 { opentracing } from "jaeger-client";
8
+
9
+ // Type definitions for jaeger-client which are not exported by @types/jaeger-client
10
+ // Project: https://github.com/uber/jaeger-client-node
11
+ // Definitions by: Julian Steger <https://github.com/julianste>
12
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
13
+
14
+ export interface TracingConfig {
15
+ serviceName?: string;
16
+ disable?: boolean;
17
+ sampler?: SamplerConfig;
18
+ reporter?: ReporterConfig;
19
+ }
20
+
21
+ export interface TracingOptions {
22
+ reporter?: Reporter;
23
+ metrics?: MetricsFactory;
24
+ logger?: Logger;
25
+ tags?: any;
26
+ }
27
+
28
+ export interface ReporterConfig {
29
+ logSpans?: boolean;
30
+ agentHost?: string;
31
+ agentPort?: number;
32
+ flushIntervalMs?: number;
33
+ }
34
+
35
+ export interface SamplerConfig {
36
+ type: string;
37
+ param: number;
38
+ host?: string;
39
+ port?: number;
40
+ refreshIntervalMs?: number;
41
+ }
42
+
43
+ export interface Logger {
44
+ info(msg: string): void;
45
+ error(msg: string): void;
46
+ }
47
+
48
+ export interface Reporter {
49
+ report(span: opentracing.Span): void;
50
+ close(callback?: () => void): void;
51
+ setProcess(serviceName: string, tags: any): void;
52
+ }
53
+
54
+ export interface MetricsFactory {
55
+ createCounter(name: string, tags: any): Counter;
56
+ createTimer(name: string, tags: any): Timer;
57
+ createGauge(name: string, tags: any): Gauge;
58
+ }
59
+
60
+ // Counter tracks the number of times an event has occurred
61
+ export interface Counter {
62
+ // Adds the given value to the counter.
63
+ increment(delta: number): void;
64
+ }
65
+
66
+ // Timer tracks how long an operation took and also computes percentiles.
67
+ export interface Timer {
68
+ // Records the time passed in.
69
+ record(value: number): void;
70
+ }
71
+
72
+ // Gauge returns instantaneous measurements of something as an int64 value
73
+ export interface Gauge {
74
+ // Update the gauge to the value passed in.
75
+ update(value: number): void;
76
+ }
77
+
78
+ // export function initTracer(
79
+ // tracingConfig: TracingConfig,
80
+ // tracingOptions: TracingOptions,
81
+ // ): opentracing.Tracer;
82
+
83
+ // export function initTracerFromEnv(
84
+ // tracingConfig: TracingConfig,
85
+ // tracingOptions: TracingOptions,
86
+ // ): opentracing.Tracer;
87
+
88
+ export interface SamplingDecision {
89
+ sample: boolean;
90
+ retryable: boolean;
91
+ tags: any;
92
+ }
93
+
94
+ // added by TypeFox
95
+ export interface Sampler {
96
+ name(): string
97
+ isSampled(operation: string, tags: any): boolean;
98
+ onCreateSpan(span: opentracing.Span): SamplingDecision;
99
+ onSetOperationName(span: opentracing.Span, operationName: string): SamplingDecision;
100
+ onSetTag(span: opentracing.Span, key: string, value: any): SamplingDecision;
101
+ close(callback: () => void): void
102
+ }
@@ -30,66 +30,66 @@ export interface LogPayload {
30
30
  };
31
31
 
32
32
  export namespace log {
33
- export function error(context: LogContext, message: string, error: Error, payload: LogPayload): void;
34
- export function error(context: LogContext, message: string, error: Error): void;
33
+ export function error(context: LogContext, message: string, error: any, payload: LogPayload): void;
34
+ export function error(context: LogContext, message: string, error: any): void;
35
35
  export function error(context: LogContext, message: string, payload: LogPayload): void;
36
36
  export function error(context: LogContext, message: string): void;
37
- export function error(context: LogContext, error: Error, payload: LogPayload): void;
38
- export function error(context: LogContext, error: Error): void;
39
- export function error(message: string, error: Error, payload: LogPayload): void;
40
- export function error(message: string, error: Error): void;
37
+ export function error(context: LogContext, error: any, payload: LogPayload): void;
38
+ export function error(context: LogContext, error: any): void;
39
+ export function error(message: string, error: any, payload: LogPayload): void;
40
+ export function error(message: string, error: any): void;
41
41
  export function error(message: string, payload: LogPayload): void;
42
42
  export function error(message: string): void;
43
- export function error(error: Error, payload: LogPayload): void;
44
- export function error(error: Error): void;
43
+ export function error(error: any, payload: LogPayload): void;
44
+ export function error(error: any): void;
45
45
  export function error(...args: any[]): void {
46
46
  errorLog(false, args);
47
47
  }
48
48
 
49
- export function warn(context: LogContext, message: string, error: Error, payload: LogPayload): void;
50
- export function warn(context: LogContext, message: string, error: Error): void;
49
+ export function warn(context: LogContext, message: string, error: any, payload: LogPayload): void;
50
+ export function warn(context: LogContext, message: string, error: any): void;
51
51
  export function warn(context: LogContext, message: string, payload: LogPayload): void;
52
52
  export function warn(context: LogContext, message: string): void;
53
- export function warn(context: LogContext, error: Error, payload: LogPayload): void;
54
- export function warn(context: LogContext, error: Error): void;
55
- export function warn(message: string, error: Error, payload: LogPayload): void;
56
- export function warn(message: string, error: Error): void;
53
+ export function warn(context: LogContext, error: any, payload: LogPayload): void;
54
+ export function warn(context: LogContext, error: any): void;
55
+ export function warn(message: string, error: any, payload: LogPayload): void;
56
+ export function warn(message: string, error: any): void;
57
57
  export function warn(message: string, payload: LogPayload): void;
58
58
  export function warn(message: string): void;
59
- export function warn(error: Error, payload: LogPayload): void;
60
- export function warn(error: Error): void;
59
+ export function warn(error: any, payload: LogPayload): void;
60
+ export function warn(error: any): void;
61
61
  export function warn(...args: any[]): void {
62
62
  warnLog(false, args);
63
63
  }
64
64
 
65
- export function info(context: LogContext, message: string, error: Error, payload: LogPayload): void;
66
- export function info(context: LogContext, message: string, error: Error): void;
65
+ export function info(context: LogContext, message: string, error: any, payload: LogPayload): void;
66
+ export function info(context: LogContext, message: string, error: any): void;
67
67
  export function info(context: LogContext, message: string, payload: LogPayload): void;
68
68
  export function info(context: LogContext, message: string): void;
69
- export function info(context: LogContext, error: Error, payload: LogPayload): void;
70
- export function info(context: LogContext, error: Error): void;
71
- export function info(message: string, error: Error, payload: LogPayload): void;
72
- export function info(message: string, error: Error): void;
69
+ export function info(context: LogContext, error: any, payload: LogPayload): void;
70
+ export function info(context: LogContext, error: any): void;
71
+ export function info(message: string, error: any, payload: LogPayload): void;
72
+ export function info(message: string, error: any): void;
73
73
  export function info(message: string, payload: LogPayload): void;
74
74
  export function info(message: string): void;
75
- export function info(error: Error, payload: LogPayload): void;
76
- export function info(error: Error): void;
75
+ export function info(error: any, payload: LogPayload): void;
76
+ export function info(error: any): void;
77
77
  export function info(...args: any[]): void {
78
78
  infoLog(false, args);
79
79
  }
80
80
 
81
- export function debug(context: LogContext, message: string, error: Error, payload: LogPayload): void;
82
- export function debug(context: LogContext, message: string, error: Error): void;
81
+ export function debug(context: LogContext, message: string, error: any, payload: LogPayload): void;
82
+ export function debug(context: LogContext, message: string, error: any): void;
83
83
  export function debug(context: LogContext, message: string, payload: LogPayload): void;
84
84
  export function debug(context: LogContext, message: string): void;
85
- export function debug(context: LogContext, error: Error, payload: LogPayload): void;
86
- export function debug(context: LogContext, error: Error): void;
87
- export function debug(message: string, error: Error, payload: LogPayload): void;
88
- export function debug(message: string, error: Error): void;
85
+ export function debug(context: LogContext, error: any, payload: LogPayload): void;
86
+ export function debug(context: LogContext, error: any): void;
87
+ export function debug(message: string, error: any, payload: LogPayload): void;
88
+ export function debug(message: string, error: any): void;
89
89
  export function debug(message: string, payload: LogPayload): void;
90
90
  export function debug(message: string): void;
91
- export function debug(error: Error, payload: LogPayload): void;
92
- export function debug(error: Error): void;
91
+ export function debug(error: any, payload: LogPayload): void;
92
+ export function debug(error: any): void;
93
93
  export function debug(...args: any[]): void {
94
94
  debugLog(false, args);
95
95
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  import * as chai from 'chai';
8
8
  import { suite, test } from 'mocha-typescript';
9
- import { parseWorkspaceIdFromHostname } from './parse-workspace-id';
9
+ import { matchesInstanceIdOrLegacyWorkspaceIdExactly, matchesNewWorkspaceIdExactly, parseWorkspaceIdFromHostname } from './parse-workspace-id';
10
10
  const expect = chai.expect;
11
11
 
12
12
  @suite
@@ -52,5 +52,25 @@ export class ParseWorkspaceIdTest {
52
52
  const actual = parseWorkspaceIdFromHostname("webview-3000-ca81a50f-09d7-465c-acd9-264a747d5351.ws-eu01.some.subdomain.somehost.com");
53
53
  expect(actual).to.equal("ca81a50f-09d7-465c-acd9-264a747d5351");
54
54
  }
55
+
56
+ // match - instance ID
57
+ @test public matchesInstanceIdOrLegacyWorkspaceIdExactly_positive() {
58
+ const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81ea-04859263b656");
59
+ expect(actual).to.be.true;
60
+ }
61
+ @test public matchesInstanceIdOrLegacyWorkspaceIdExactly_negative() {
62
+ const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81a-04859263b656");
63
+ expect(actual).to.be.false;
64
+ }
65
+
66
+ // match - new workspace ID
67
+ @test public matchesWorkspaceIdExactly_new_positive() {
68
+ const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-155799b3");
69
+ expect(actual).to.be.true;
70
+ }
71
+ @test public matchesWorkspaceIdExactly_new_negative() {
72
+ const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-15599b3");
73
+ expect(actual).to.be.false;
74
+ }
55
75
  }
56
76
  module.exports = new ParseWorkspaceIdTest()