@gitpod/gitpod-protocol 0.1.5-me-version.1 → 0.1.5-me-ingress.14

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 (272) hide show
  1. package/data/gitpod-schema.json +11 -4
  2. package/lib/accounting-protocol.d.ts +3 -6
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +10 -16
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +9 -4
  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 +45 -0
  11. package/lib/analytics.d.ts.map +1 -0
  12. package/lib/analytics.js +10 -0
  13. package/lib/analytics.js.map +1 -0
  14. package/lib/context-url.d.ts +18 -0
  15. package/lib/context-url.d.ts.map +1 -0
  16. package/lib/context-url.js +49 -0
  17. package/lib/context-url.js.map +1 -0
  18. package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +2 -0
  19. package/lib/context-url.spec.d.ts.map +1 -0
  20. package/lib/context-url.spec.js +73 -0
  21. package/lib/context-url.spec.js.map +1 -0
  22. package/lib/email-protocol.d.ts +1 -2
  23. package/lib/email-protocol.d.ts.map +1 -1
  24. package/lib/email-protocol.js +4 -4
  25. package/lib/email-protocol.js.map +1 -1
  26. package/lib/encryption/container-module.js +4 -4
  27. package/lib/encryption/container-module.js.map +1 -1
  28. package/lib/encryption/encryption-engine.js +19 -20
  29. package/lib/encryption/encryption-engine.js.map +1 -1
  30. package/lib/encryption/encryption-engine.spec.js +29 -36
  31. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  32. package/lib/encryption/encryption-service.js +29 -43
  33. package/lib/encryption/encryption-service.js.map +1 -1
  34. package/lib/encryption/key-provider.js +25 -30
  35. package/lib/encryption/key-provider.js.map +1 -1
  36. package/lib/env.d.ts +1 -2
  37. package/lib/env.d.ts.map +1 -1
  38. package/lib/env.js +20 -21
  39. package/lib/env.js.map +1 -1
  40. package/lib/gitpod-file-parser.js +25 -41
  41. package/lib/gitpod-file-parser.js.map +1 -1
  42. package/lib/gitpod-file-parser.spec.js +116 -116
  43. package/lib/gitpod-file-parser.spec.js.map +1 -1
  44. package/lib/gitpod-service.d.ts +86 -9
  45. package/lib/gitpod-service.d.ts.map +1 -1
  46. package/lib/gitpod-service.js +150 -295
  47. package/lib/gitpod-service.js.map +1 -1
  48. package/lib/headless-workspace-log.d.ts +8 -11
  49. package/lib/headless-workspace-log.d.ts.map +1 -1
  50. package/lib/headless-workspace-log.js +4 -7
  51. package/lib/headless-workspace-log.js.map +1 -1
  52. package/lib/ide-protocol.d.ts +81 -0
  53. package/lib/ide-protocol.d.ts.map +1 -0
  54. package/lib/ide-protocol.js +8 -0
  55. package/lib/ide-protocol.js.map +1 -0
  56. package/lib/index.d.ts +4 -0
  57. package/lib/index.d.ts.map +1 -1
  58. package/lib/index.js +4 -0
  59. package/lib/index.js.map +1 -1
  60. package/lib/messaging/browser/connection.d.ts +3 -3
  61. package/lib/messaging/browser/connection.d.ts.map +1 -1
  62. package/lib/messaging/browser/connection.js +172 -35
  63. package/lib/messaging/browser/connection.js.map +1 -1
  64. package/lib/messaging/browser/window-connection.js +35 -55
  65. package/lib/messaging/browser/window-connection.js.map +1 -1
  66. package/lib/messaging/client-call-metrics.d.ts +35 -0
  67. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  68. package/lib/messaging/client-call-metrics.js +83 -0
  69. package/lib/messaging/client-call-metrics.js.map +1 -0
  70. package/lib/messaging/connection-error-handler.js +11 -23
  71. package/lib/messaging/connection-error-handler.js.map +1 -1
  72. package/lib/messaging/error.d.ts +2 -1
  73. package/lib/messaging/error.d.ts.map +1 -1
  74. package/lib/messaging/error.js +4 -2
  75. package/lib/messaging/error.js.map +1 -1
  76. package/lib/messaging/handler.d.ts +10 -0
  77. package/lib/messaging/handler.d.ts.map +1 -1
  78. package/lib/messaging/node/connection.d.ts +0 -10
  79. package/lib/messaging/node/connection.d.ts.map +1 -1
  80. package/lib/messaging/node/connection.js +12 -50
  81. package/lib/messaging/node/connection.js.map +1 -1
  82. package/lib/messaging/proxy-factory.d.ts +2 -0
  83. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  84. package/lib/messaging/proxy-factory.js +74 -159
  85. package/lib/messaging/proxy-factory.js.map +1 -1
  86. package/lib/oss-allowlist.d.ts +14 -0
  87. package/lib/oss-allowlist.d.ts.map +1 -0
  88. package/lib/oss-allowlist.js +8 -0
  89. package/lib/oss-allowlist.js.map +1 -0
  90. package/lib/permission.d.ts +1 -2
  91. package/lib/permission.d.ts.map +1 -1
  92. package/lib/permission.js +12 -13
  93. package/lib/permission.js.map +1 -1
  94. package/lib/plans.d.ts +1 -1
  95. package/lib/plans.d.ts.map +1 -1
  96. package/lib/plans.js +38 -57
  97. package/lib/plans.js.map +1 -1
  98. package/lib/protocol.d.ts +50 -48
  99. package/lib/protocol.d.ts.map +1 -1
  100. package/lib/protocol.js +57 -114
  101. package/lib/protocol.js.map +1 -1
  102. package/lib/snapshot-url.d.ts +14 -0
  103. package/lib/snapshot-url.d.ts.map +1 -0
  104. package/lib/snapshot-url.js +26 -0
  105. package/lib/snapshot-url.js.map +1 -0
  106. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  107. package/lib/snapshot-url.spec.d.ts.map +1 -0
  108. package/lib/snapshot-url.spec.js +41 -0
  109. package/lib/snapshot-url.spec.js.map +1 -0
  110. package/lib/team-subscription-protocol.d.ts +3 -3
  111. package/lib/team-subscription-protocol.d.ts.map +1 -1
  112. package/lib/team-subscription-protocol.js +15 -12
  113. package/lib/team-subscription-protocol.js.map +1 -1
  114. package/lib/teams-projects-protocol.d.ts +110 -0
  115. package/lib/teams-projects-protocol.d.ts.map +1 -0
  116. package/lib/teams-projects-protocol.js +23 -0
  117. package/lib/teams-projects-protocol.js.map +1 -0
  118. package/lib/util/analytics.d.ts +1 -26
  119. package/lib/util/analytics.d.ts.map +1 -1
  120. package/lib/util/analytics.js +36 -28
  121. package/lib/util/analytics.js.map +1 -1
  122. package/lib/util/async-iterator.js +55 -133
  123. package/lib/util/async-iterator.js.map +1 -1
  124. package/lib/util/cancelable.js +17 -59
  125. package/lib/util/cancelable.js.map +1 -1
  126. package/lib/util/date-time.js +8 -8
  127. package/lib/util/date-time.js.map +1 -1
  128. package/lib/util/deferred.js +10 -12
  129. package/lib/util/deferred.js.map +1 -1
  130. package/lib/util/disposable.js +26 -39
  131. package/lib/util/disposable.js.map +1 -1
  132. package/lib/util/event.js +58 -74
  133. package/lib/util/event.js.map +1 -1
  134. package/lib/util/garbage-collected-cache.d.ts +1 -0
  135. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  136. package/lib/util/garbage-collected-cache.js +26 -46
  137. package/lib/util/garbage-collected-cache.js.map +1 -1
  138. package/lib/util/generate-workspace-id.d.ts +1 -1
  139. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  140. package/lib/util/generate-workspace-id.js +29 -68
  141. package/lib/util/generate-workspace-id.js.map +1 -1
  142. package/lib/util/generate-workspace-id.spec.js +56 -78
  143. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  144. package/lib/util/gitpod-cookie.d.ts +20 -0
  145. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  146. package/lib/util/gitpod-cookie.js +44 -0
  147. package/lib/util/gitpod-cookie.js.map +1 -0
  148. package/lib/util/gitpod-host-url.d.ts +1 -0
  149. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  150. package/lib/util/gitpod-host-url.js +96 -103
  151. package/lib/util/gitpod-host-url.js.map +1 -1
  152. package/lib/util/gitpod-host-url.spec.js +87 -135
  153. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  154. package/lib/util/grpc.d.ts +15 -0
  155. package/lib/util/grpc.d.ts.map +1 -0
  156. package/lib/util/grpc.js +18 -0
  157. package/lib/util/grpc.js.map +1 -0
  158. package/lib/util/jaeger-client-types.d.ts +68 -0
  159. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  160. package/lib/util/{without.js → jaeger-client-types.js} +1 -1
  161. package/lib/util/jaeger-client-types.js.map +1 -0
  162. package/lib/util/logging.d.ts +49 -33
  163. package/lib/util/logging.d.ts.map +1 -1
  164. package/lib/util/logging.js +107 -110
  165. package/lib/util/logging.js.map +1 -1
  166. package/lib/util/make-link.js +2 -2
  167. package/lib/util/make-link.js.map +1 -1
  168. package/lib/util/parse-workspace-id.d.ts +10 -0
  169. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  170. package/lib/util/parse-workspace-id.js +31 -7
  171. package/lib/util/parse-workspace-id.js.map +1 -1
  172. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  173. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  174. package/lib/util/parse-workspace-id.spec.js +123 -84
  175. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  176. package/lib/util/queue.js +16 -55
  177. package/lib/util/queue.js.map +1 -1
  178. package/lib/util/queue.spec.js +144 -288
  179. package/lib/util/queue.spec.js.map +1 -1
  180. package/lib/util/repeat.d.ts +15 -0
  181. package/lib/util/repeat.d.ts.map +1 -0
  182. package/lib/util/repeat.js +55 -0
  183. package/lib/util/repeat.js.map +1 -0
  184. package/lib/util/safe-promise.js +9 -12
  185. package/lib/util/safe-promise.js.map +1 -1
  186. package/lib/util/semaphore.js +15 -46
  187. package/lib/util/semaphore.js.map +1 -1
  188. package/lib/util/skip-if.js +6 -6
  189. package/lib/util/skip-if.js.map +1 -1
  190. package/lib/util/timeutil.js +16 -16
  191. package/lib/util/timeutil.js.map +1 -1
  192. package/lib/util/timeutil.spec.js +21 -24
  193. package/lib/util/timeutil.spec.js.map +1 -1
  194. package/lib/util/tracing.d.ts +50 -5
  195. package/lib/util/tracing.d.ts.map +1 -1
  196. package/lib/util/tracing.js +175 -63
  197. package/lib/util/tracing.js.map +1 -1
  198. package/lib/util/tracing.spec.d.ts +7 -0
  199. package/lib/util/tracing.spec.d.ts.map +1 -0
  200. package/lib/util/tracing.spec.js +121 -0
  201. package/lib/util/tracing.spec.js.map +1 -0
  202. package/lib/util/workspace-port-authentication.js +2 -2
  203. package/lib/util/workspace-port-authentication.js.map +1 -1
  204. package/lib/workspace-cluster.d.ts +12 -3
  205. package/lib/workspace-cluster.d.ts.map +1 -1
  206. package/lib/workspace-cluster.js +3 -3
  207. package/lib/workspace-cluster.js.map +1 -1
  208. package/lib/workspace-instance.d.ts +5 -2
  209. package/lib/workspace-instance.d.ts.map +1 -1
  210. package/lib/wsready.js +1 -1
  211. package/package.json +24 -13
  212. package/pkg-yarn.lock +14 -7
  213. package/provenance-bundle.jsonl +2 -0
  214. package/src/accounting-protocol.ts +4 -10
  215. package/src/admin-protocol.ts +10 -5
  216. package/src/analytics.ts +54 -0
  217. package/src/context-url.spec.ts +39 -0
  218. package/src/context-url.ts +51 -0
  219. package/src/email-protocol.ts +2 -3
  220. package/src/env.ts +10 -10
  221. package/src/gitpod-service.ts +101 -17
  222. package/src/headless-workspace-log.ts +7 -11
  223. package/src/ide-protocol.ts +92 -0
  224. package/src/index.ts +4 -0
  225. package/src/messaging/browser/connection.ts +176 -10
  226. package/src/messaging/client-call-metrics.ts +97 -0
  227. package/src/messaging/error.ts +5 -2
  228. package/src/messaging/handler.ts +12 -0
  229. package/src/messaging/node/connection.ts +3 -47
  230. package/src/messaging/proxy-factory.ts +13 -5
  231. package/src/oss-allowlist.ts +15 -0
  232. package/src/permission.ts +0 -1
  233. package/src/protocol.ts +68 -56
  234. package/src/snapshot-url.spec.ts +25 -0
  235. package/src/snapshot-url.ts +27 -0
  236. package/src/team-subscription-protocol.ts +6 -4
  237. package/src/teams-projects-protocol.ts +141 -0
  238. package/src/util/analytics.ts +17 -30
  239. package/src/util/garbage-collected-cache.ts +7 -1
  240. package/src/util/generate-workspace-id.spec.ts +16 -0
  241. package/src/util/generate-workspace-id.ts +20 -2
  242. package/src/util/gitpod-cookie.ts +39 -0
  243. package/src/util/gitpod-host-url.ts +12 -8
  244. package/src/util/grpc.ts +15 -0
  245. package/src/util/jaeger-client-types.ts +102 -0
  246. package/src/util/logging.ts +102 -38
  247. package/src/util/parse-workspace-id.spec.ts +21 -1
  248. package/src/util/parse-workspace-id.ts +32 -6
  249. package/src/util/repeat.ts +45 -0
  250. package/src/util/tracing.spec.ts +83 -0
  251. package/src/util/tracing.ts +162 -18
  252. package/src/workspace-cluster.ts +9 -3
  253. package/src/workspace-instance.ts +18 -6
  254. package/src/wsready.ts +1 -1
  255. package/lib/util/context-url.d.ts +0 -13
  256. package/lib/util/context-url.d.ts.map +0 -1
  257. package/lib/util/context-url.js +0 -26
  258. package/lib/util/context-url.js.map +0 -1
  259. package/lib/util/context-url.spec.d.ts.map +0 -1
  260. package/lib/util/context-url.spec.js +0 -52
  261. package/lib/util/context-url.spec.js.map +0 -1
  262. package/lib/util/repeater.d.ts +0 -22
  263. package/lib/util/repeater.d.ts.map +0 -1
  264. package/lib/util/repeater.js +0 -118
  265. package/lib/util/repeater.js.map +0 -1
  266. package/lib/util/without.d.ts +0 -7
  267. package/lib/util/without.d.ts.map +0 -1
  268. package/lib/util/without.js.map +0 -1
  269. package/src/util/context-url.spec.ts +0 -25
  270. package/src/util/context-url.ts +0 -23
  271. package/src/util/jaeger-client.d.ts +0 -105
  272. package/src/util/repeater.ts +0 -49
@@ -0,0 +1,141 @@
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
+ import { PrebuiltWorkspaceState } from "./protocol";
8
+ import { v4 as uuidv4 } from 'uuid';
9
+ import { DeepPartial } from "./util/deep-partial";
10
+
11
+ export interface ProjectConfig {
12
+ '.gitpod.yml': string;
13
+ }
14
+
15
+ export interface ProjectSettings {
16
+ useIncrementalPrebuilds?: boolean;
17
+ }
18
+
19
+ export interface Project {
20
+ id: string;
21
+ name: string;
22
+ slug?: string;
23
+ cloneUrl: string;
24
+ teamId?: string;
25
+ userId?: string;
26
+ appInstallationId: string;
27
+ config?: ProjectConfig;
28
+ settings?: ProjectSettings;
29
+ creationTime: string;
30
+ /** This is a flag that triggers the HARD DELETION of this entity */
31
+ deleted?: boolean;
32
+ markedDeleted?: boolean;
33
+ }
34
+
35
+ export namespace Project {
36
+ export const create = (project: Omit<Project, 'id' | 'creationTime'>): Project => {
37
+ return {
38
+ ...project,
39
+ id: uuidv4(),
40
+ creationTime: new Date().toISOString()
41
+ };
42
+ }
43
+
44
+ export interface Overview {
45
+ branches: BranchDetails[]
46
+ }
47
+
48
+ export interface BranchDetails {
49
+ name: string;
50
+ url: string;
51
+ isDefault: boolean;
52
+
53
+ // Latest commit
54
+ changeTitle: string;
55
+ changeDate?: string;
56
+ changeAuthor?: string;
57
+ changeAuthorAvatar?: string;
58
+ changePR?: string;
59
+ changeUrl?: string;
60
+ changeHash: string;
61
+ }
62
+ }
63
+
64
+ export type PartialProject = DeepPartial<Project> & Pick<Project, 'id'>;
65
+
66
+ export interface PrebuildWithStatus {
67
+ info: PrebuildInfo;
68
+ status: PrebuiltWorkspaceState;
69
+ error?: string;
70
+ }
71
+
72
+ export interface PrebuildInfo {
73
+ id: string;
74
+ buildWorkspaceId: string;
75
+ basedOnPrebuildId?: string;
76
+
77
+ teamId?: string;
78
+ userId?: string;
79
+
80
+ projectId: string;
81
+ projectName: string;
82
+
83
+ cloneUrl: string;
84
+ branch: string;
85
+
86
+ startedAt: string;
87
+ startedBy: string;
88
+ startedByAvatar?: string;
89
+
90
+ changeTitle: string;
91
+ changeDate: string;
92
+ changeAuthor: string;
93
+ changeAuthorAvatar?: string;
94
+ changePR?: string;
95
+ changeUrl?: string;
96
+ changeHash: string;
97
+ }
98
+ export namespace PrebuildInfo {
99
+ export function is(data?: any): data is PrebuildInfo {
100
+ return typeof data === "object" && ["id", "buildWorkspaceId", "projectId", "branch"].every(p => p in data);
101
+ }
102
+ }
103
+
104
+ export interface StartPrebuildResult {
105
+ prebuildId: string;
106
+ wsid: string;
107
+ done: boolean;
108
+ }
109
+
110
+ export interface Team {
111
+ id: string;
112
+ name: string;
113
+ slug: string;
114
+ creationTime: string;
115
+ markedDeleted?: boolean;
116
+ /** This is a flag that triggers the HARD DELETION of this entity */
117
+ deleted?: boolean;
118
+ }
119
+
120
+ export type TeamMemberRole = "owner" | "member";
121
+
122
+ export interface TeamMemberInfo {
123
+ userId: string;
124
+ fullName?: string;
125
+ primaryEmail?: string;
126
+ avatarUrl?: string;
127
+ role: TeamMemberRole;
128
+ memberSince: string;
129
+ }
130
+
131
+ export interface TeamMembershipInvite {
132
+ id: string;
133
+ teamId: string;
134
+ role: TeamMemberRole;
135
+ creationTime: string;
136
+ invalidationTime: string;
137
+ invitedEmail?: string;
138
+
139
+ /** This is a flag that triggers the HARD DELETION of this entity */
140
+ deleted?: boolean;
141
+ }
@@ -5,30 +5,9 @@
5
5
  */
6
6
 
7
7
  import Analytics = require("analytics-node");
8
+ import { IAnalyticsWriter, IdentifyMessage, TrackMessage, PageMessage } from "../analytics";
8
9
  import { log } from './logging';
9
10
 
10
- export const IAnalyticsWriter = Symbol("IAnalyticsWriter");
11
-
12
- type Identity =
13
- | { userId: string | number }
14
- | { userId?: string | number; anonymousId: string | number };
15
-
16
- interface Message {
17
- messageId?: string;
18
- }
19
-
20
- export type IdentifyMessage = Message & Identity & {
21
- traits?: any;
22
- timestamp?: Date;
23
- context?: any;
24
- };
25
-
26
- export type TrackMessage = Message & Identity & {
27
- event: string;
28
- properties?: any;
29
- timestamp?: Date;
30
- context?: any;
31
- };
32
11
 
33
12
  export function newAnalyticsWriterFromEnv(): IAnalyticsWriter {
34
13
  switch (process.env.GITPOD_ANALYTICS_WRITER) {
@@ -41,14 +20,6 @@ export function newAnalyticsWriterFromEnv(): IAnalyticsWriter {
41
20
  }
42
21
  }
43
22
 
44
- export interface IAnalyticsWriter {
45
-
46
- identify(msg: IdentifyMessage): void;
47
-
48
- track(msg: TrackMessage): void;
49
-
50
- }
51
-
52
23
  class SegmentAnalyticsWriter implements IAnalyticsWriter {
53
24
 
54
25
  protected readonly analytics: Analytics;
@@ -81,6 +52,18 @@ class SegmentAnalyticsWriter implements IAnalyticsWriter {
81
52
  }
82
53
  }
83
54
 
55
+ page(msg: PageMessage) {
56
+ try{
57
+ this.analytics.page(msg, (err: Error) => {
58
+ if (err) {
59
+ log.warn("analytics.page failed", err);
60
+ }
61
+ });
62
+ } catch (err) {
63
+ log.warn("analytics.page failed", err);
64
+ }
65
+ }
66
+
84
67
  }
85
68
 
86
69
  class LogAnalyticsWriter implements IAnalyticsWriter {
@@ -91,10 +74,14 @@ class LogAnalyticsWriter implements IAnalyticsWriter {
91
74
  track(msg: TrackMessage): void {
92
75
  log.debug("analytics track", msg);
93
76
  }
77
+ page(msg: PageMessage): void {
78
+ log.debug("analytics page", msg);
79
+ }
94
80
 
95
81
  }
96
82
 
97
83
  class NoAnalyticsWriter implements IAnalyticsWriter {
98
84
  identify(msg: IdentifyMessage): void {}
99
85
  track(msg: TrackMessage): void {}
86
+ page(msg: PageMessage): void {}
100
87
  }
@@ -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> {
@@ -173,6 +190,7 @@ export const colors = [
173
190
  'deer',
174
191
  'dingo',
175
192
  'dinosaur',
193
+ 'dodo',
176
194
  'dog',
177
195
  'dolphin',
178
196
  'donkey',
@@ -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,23 +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
+ }
106
+
107
+ asPreferences(): GitpodHostUrl {
108
+ return this.with(url => ({ pathname: '/preferences' }));
105
109
  }
106
110
 
107
111
  asGraphQLApi(): GitpodHostUrl {
@@ -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 const defaultGRPCOptions = {
8
+ "grpc.keepalive_timeout_ms": 10000,
9
+ "grpc.keepalive_time_ms": 60000,
10
+ "grpc.http2.min_time_between_pings_ms": 10000,
11
+ "grpc.keepalive_permit_without_calls": 1,
12
+ "grpc-node.max_session_memory": 50,
13
+ "grpc.max_reconnect_backoff_ms": 5000,
14
+ "grpc.max_receive_message_length": 1024 * 1024 * 16,
15
+ };
@@ -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
+ }