@gitpod/gitpod-protocol 0.1.5-wth-test.41 → 0.1.5-yh-vmoptions-fork.3

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 (311) hide show
  1. package/data/gitpod-schema.json +199 -7
  2. package/lib/accounting-protocol.d.ts +17 -10
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +30 -32
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +12 -0
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js.map +1 -1
  9. package/lib/analytics.d.ts +4 -5
  10. package/lib/analytics.d.ts.map +1 -1
  11. package/lib/analytics.js.map +1 -1
  12. package/lib/auth.d.ts.map +1 -1
  13. package/lib/context-url.d.ts +18 -5
  14. package/lib/context-url.d.ts.map +1 -1
  15. package/lib/context-url.js +59 -6
  16. package/lib/context-url.js.map +1 -1
  17. package/lib/context-url.spec.d.ts +2 -0
  18. package/lib/context-url.spec.d.ts.map +1 -1
  19. package/lib/context-url.spec.js +40 -4
  20. package/lib/context-url.spec.js.map +1 -1
  21. package/lib/email-protocol.d.ts +1 -1
  22. package/lib/email-protocol.d.ts.map +1 -1
  23. package/lib/email-protocol.js.map +1 -1
  24. package/lib/encryption/container-module.d.ts.map +1 -1
  25. package/lib/encryption/container-module.js +1 -1
  26. package/lib/encryption/container-module.js.map +1 -1
  27. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  28. package/lib/encryption/encryption-engine.js +7 -7
  29. package/lib/encryption/encryption-engine.js.map +1 -1
  30. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  31. package/lib/encryption/encryption-engine.spec.js +2 -3
  32. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  33. package/lib/encryption/encryption-service.d.ts.map +1 -1
  34. package/lib/encryption/encryption-service.js +1 -1
  35. package/lib/encryption/encryption-service.js.map +1 -1
  36. package/lib/encryption/key-provider.d.ts.map +1 -1
  37. package/lib/encryption/key-provider.js +7 -9
  38. package/lib/encryption/key-provider.js.map +1 -1
  39. package/lib/env.d.ts +0 -5
  40. package/lib/env.d.ts.map +1 -1
  41. package/lib/env.js +1 -20
  42. package/lib/env.js.map +1 -1
  43. package/lib/gitpod-file-parser.d.ts.map +1 -1
  44. package/lib/gitpod-file-parser.js +6 -6
  45. package/lib/gitpod-file-parser.js.map +1 -1
  46. package/lib/gitpod-file-parser.spec.js +42 -39
  47. package/lib/gitpod-file-parser.spec.js.map +1 -1
  48. package/lib/gitpod-service.d.ts +61 -28
  49. package/lib/gitpod-service.d.ts.map +1 -1
  50. package/lib/gitpod-service.js +43 -34
  51. package/lib/gitpod-service.js.map +1 -1
  52. package/lib/headless-workspace-log.d.ts +1 -0
  53. package/lib/headless-workspace-log.d.ts.map +1 -1
  54. package/lib/headless-workspace-log.js +2 -1
  55. package/lib/headless-workspace-log.js.map +1 -1
  56. package/lib/ide-frontend-service.d.ts +1 -1
  57. package/lib/ide-protocol.d.ts +105 -0
  58. package/lib/ide-protocol.d.ts.map +1 -0
  59. package/lib/ide-protocol.js +8 -0
  60. package/lib/ide-protocol.js.map +1 -0
  61. package/lib/index.d.ts +16 -14
  62. package/lib/index.d.ts.map +1 -1
  63. package/lib/index.js +2 -0
  64. package/lib/index.js.map +1 -1
  65. package/lib/installation-admin-protocol.d.ts +27 -0
  66. package/lib/installation-admin-protocol.d.ts.map +1 -0
  67. package/lib/installation-admin-protocol.js +30 -0
  68. package/lib/installation-admin-protocol.js.map +1 -0
  69. package/lib/license-protocol.d.ts +7 -0
  70. package/lib/license-protocol.d.ts.map +1 -1
  71. package/lib/license-protocol.js.map +1 -1
  72. package/lib/messaging/browser/connection.d.ts +1 -1
  73. package/lib/messaging/browser/connection.d.ts.map +1 -1
  74. package/lib/messaging/browser/connection.js +19 -19
  75. package/lib/messaging/browser/connection.js.map +1 -1
  76. package/lib/messaging/browser/window-connection.d.ts +4 -4
  77. package/lib/messaging/browser/window-connection.d.ts.map +1 -1
  78. package/lib/messaging/browser/window-connection.js +9 -6
  79. package/lib/messaging/browser/window-connection.js.map +1 -1
  80. package/lib/messaging/client-call-metrics.d.ts +2 -2
  81. package/lib/messaging/client-call-metrics.d.ts.map +1 -1
  82. package/lib/messaging/client-call-metrics.js +20 -20
  83. package/lib/messaging/client-call-metrics.js.map +1 -1
  84. package/lib/messaging/error.d.ts +3 -0
  85. package/lib/messaging/error.d.ts.map +1 -1
  86. package/lib/messaging/error.js +6 -0
  87. package/lib/messaging/error.js.map +1 -1
  88. package/lib/messaging/handler.d.ts.map +1 -1
  89. package/lib/messaging/handler.js +1 -1
  90. package/lib/messaging/node/connection.d.ts +1 -17
  91. package/lib/messaging/node/connection.d.ts.map +1 -1
  92. package/lib/messaging/node/connection.js +23 -59
  93. package/lib/messaging/node/connection.js.map +1 -1
  94. package/lib/messaging/proxy-factory.d.ts +1 -1
  95. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  96. package/lib/messaging/proxy-factory.js +7 -9
  97. package/lib/messaging/proxy-factory.js.map +1 -1
  98. package/lib/oss-allowlist.d.ts +14 -0
  99. package/lib/oss-allowlist.d.ts.map +1 -0
  100. package/lib/oss-allowlist.js +8 -0
  101. package/lib/oss-allowlist.js.map +1 -0
  102. package/lib/payment-protocol.d.ts.map +1 -1
  103. package/lib/payment-protocol.js +1 -1
  104. package/lib/payment-protocol.js.map +1 -1
  105. package/lib/permission.d.ts +9 -3
  106. package/lib/permission.d.ts.map +1 -1
  107. package/lib/permission.js +34 -25
  108. package/lib/permission.js.map +1 -1
  109. package/lib/plans.d.ts +3 -3
  110. package/lib/plans.d.ts.map +1 -1
  111. package/lib/plans.js +206 -171
  112. package/lib/plans.js.map +1 -1
  113. package/lib/protocol.d.ts +109 -74
  114. package/lib/protocol.d.ts.map +1 -1
  115. package/lib/protocol.js +177 -87
  116. package/lib/protocol.js.map +1 -1
  117. package/lib/snapshot-url.spec.js.map +1 -1
  118. package/lib/team-subscription-protocol.d.ts +21 -3
  119. package/lib/team-subscription-protocol.d.ts.map +1 -1
  120. package/lib/team-subscription-protocol.js +16 -5
  121. package/lib/team-subscription-protocol.js.map +1 -1
  122. package/lib/teams-projects-protocol.d.ts +17 -2
  123. package/lib/teams-projects-protocol.d.ts.map +1 -1
  124. package/lib/teams-projects-protocol.js +8 -1
  125. package/lib/teams-projects-protocol.js.map +1 -1
  126. package/lib/typings/globals.d.ts +2 -2
  127. package/lib/typings/globals.d.ts.map +1 -1
  128. package/lib/util/analytics.d.ts.map +1 -1
  129. package/lib/util/analytics.js +12 -3
  130. package/lib/util/analytics.js.map +1 -1
  131. package/lib/util/async-iterator.d.ts.map +1 -1
  132. package/lib/util/async-iterator.js +3 -3
  133. package/lib/util/async-iterator.js.map +1 -1
  134. package/lib/util/cancelable.js.map +1 -1
  135. package/lib/util/date-time.js +6 -6
  136. package/lib/util/date-time.js.map +1 -1
  137. package/lib/util/deferred.js.map +1 -1
  138. package/lib/util/disposable.d.ts.map +1 -1
  139. package/lib/util/disposable.js +2 -2
  140. package/lib/util/disposable.js.map +1 -1
  141. package/lib/util/event.d.ts.map +1 -1
  142. package/lib/util/event.js +5 -3
  143. package/lib/util/event.js.map +1 -1
  144. package/lib/util/garbage-collected-cache.d.ts +1 -0
  145. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  146. package/lib/util/garbage-collected-cache.js +6 -2
  147. package/lib/util/garbage-collected-cache.js.map +1 -1
  148. package/lib/util/generate-workspace-id.d.ts +6 -1
  149. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  150. package/lib/util/generate-workspace-id.js +461 -440
  151. package/lib/util/generate-workspace-id.js.map +1 -1
  152. package/lib/util/generate-workspace-id.spec.js +36 -1
  153. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  154. package/lib/util/gitpod-cookie.d.ts +1 -1
  155. package/lib/util/gitpod-cookie.d.ts.map +1 -1
  156. package/lib/util/gitpod-cookie.js +0 -3
  157. package/lib/util/gitpod-cookie.js.map +1 -1
  158. package/lib/util/gitpod-host-url.d.ts +0 -1
  159. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  160. package/lib/util/gitpod-host-url.js +34 -35
  161. package/lib/util/gitpod-host-url.js.map +1 -1
  162. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  163. package/lib/util/gitpod-host-url.spec.js +15 -5
  164. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  165. package/lib/util/grpc.d.ts.map +1 -1
  166. package/lib/util/grpc.js.map +1 -1
  167. package/lib/util/jaeger-client-types.d.ts +68 -0
  168. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  169. package/lib/{theia-plugins.js → util/jaeger-client-types.js} +1 -1
  170. package/lib/util/jaeger-client-types.js.map +1 -0
  171. package/lib/util/logging.d.ts +1 -1
  172. package/lib/util/logging.d.ts.map +1 -1
  173. package/lib/util/logging.js +23 -24
  174. package/lib/util/logging.js.map +1 -1
  175. package/lib/util/make-link.js +5 -5
  176. package/lib/util/make-link.js.map +1 -1
  177. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  178. package/lib/util/parse-workspace-id.js +2 -3
  179. package/lib/util/parse-workspace-id.js.map +1 -1
  180. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  181. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  182. package/lib/util/queue.spec.js +9 -6
  183. package/lib/util/queue.spec.js.map +1 -1
  184. package/lib/util/repeat.d.ts +15 -0
  185. package/lib/util/repeat.d.ts.map +1 -0
  186. package/lib/util/repeat.js +55 -0
  187. package/lib/util/repeat.js.map +1 -0
  188. package/lib/util/semaphore.d.ts.map +1 -1
  189. package/lib/util/semaphore.js.map +1 -1
  190. package/lib/util/skip-if.d.ts.map +1 -1
  191. package/lib/util/skip-if.js.map +1 -1
  192. package/lib/util/timeutil.d.ts +1 -0
  193. package/lib/util/timeutil.d.ts.map +1 -1
  194. package/lib/util/timeutil.js +9 -3
  195. package/lib/util/timeutil.js.map +1 -1
  196. package/lib/util/timeutil.spec.d.ts.map +1 -1
  197. package/lib/util/timeutil.spec.js.map +1 -1
  198. package/lib/util/tracing.d.ts +52 -6
  199. package/lib/util/tracing.d.ts.map +1 -1
  200. package/lib/util/tracing.js +156 -19
  201. package/lib/util/tracing.js.map +1 -1
  202. package/lib/util/tracing.spec.d.ts +7 -0
  203. package/lib/util/tracing.spec.d.ts.map +1 -0
  204. package/lib/util/tracing.spec.js +121 -0
  205. package/lib/util/tracing.spec.js.map +1 -0
  206. package/lib/util/workspace-port-authentication.d.ts +7 -7
  207. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  208. package/lib/util/workspace-port-authentication.js +8 -11
  209. package/lib/util/workspace-port-authentication.js.map +1 -1
  210. package/lib/workspace-cluster.d.ts +10 -8
  211. package/lib/workspace-cluster.d.ts.map +1 -1
  212. package/lib/workspace-cluster.js +16 -1
  213. package/lib/workspace-cluster.js.map +1 -1
  214. package/lib/workspace-instance.d.ts +38 -3
  215. package/lib/workspace-instance.d.ts.map +1 -1
  216. package/lib/wsready.d.ts +1 -1
  217. package/lib/wsready.d.ts.map +1 -1
  218. package/lib/wsready.js +2 -2
  219. package/package.json +10 -8
  220. package/pkg-yarn.lock +6 -6
  221. package/provenance-bundle.jsonl +2 -0
  222. package/src/accounting-protocol.ts +63 -51
  223. package/src/admin-protocol.ts +35 -18
  224. package/src/analytics.ts +26 -28
  225. package/src/auth.ts +2 -2
  226. package/src/context-url.spec.ts +37 -9
  227. package/src/context-url.ts +94 -36
  228. package/src/email-protocol.ts +5 -6
  229. package/src/encryption/container-module.ts +2 -3
  230. package/src/encryption/encryption-engine.spec.ts +9 -8
  231. package/src/encryption/encryption-engine.ts +14 -14
  232. package/src/encryption/encryption-service.ts +4 -5
  233. package/src/encryption/key-provider.ts +16 -19
  234. package/src/env.ts +0 -22
  235. package/src/gitpod-file-parser.spec.ts +55 -61
  236. package/src/gitpod-file-parser.ts +16 -17
  237. package/src/gitpod-service.ts +185 -112
  238. package/src/headless-workspace-log.ts +6 -4
  239. package/src/ide-frontend-service.ts +2 -2
  240. package/src/ide-protocol.ts +119 -0
  241. package/src/index.ts +16 -14
  242. package/src/installation-admin-protocol.ts +42 -0
  243. package/src/license-protocol.ts +12 -6
  244. package/src/messaging/browser/connection.ts +45 -47
  245. package/src/messaging/browser/window-connection.ts +39 -29
  246. package/src/messaging/client-call-metrics.ts +70 -71
  247. package/src/messaging/error.ts +10 -3
  248. package/src/messaging/handler.ts +6 -6
  249. package/src/messaging/node/connection.ts +23 -70
  250. package/src/messaging/proxy-factory.ts +23 -30
  251. package/src/oss-allowlist.ts +15 -0
  252. package/src/payment-protocol.ts +2 -2
  253. package/src/permission.ts +40 -32
  254. package/src/plans.ts +236 -189
  255. package/src/protocol.ts +383 -275
  256. package/src/snapshot-url.spec.ts +9 -7
  257. package/src/team-subscription-protocol.ts +57 -23
  258. package/src/teams-projects-protocol.ts +29 -8
  259. package/src/typings/globals.ts +4 -4
  260. package/src/util/analytics.ts +46 -24
  261. package/src/util/async-iterator.ts +4 -5
  262. package/src/util/cancelable.ts +3 -3
  263. package/src/util/date-time.ts +8 -8
  264. package/src/util/deferred.ts +6 -6
  265. package/src/util/disposable.ts +3 -6
  266. package/src/util/event.ts +9 -11
  267. package/src/util/garbage-collected-cache.ts +9 -6
  268. package/src/util/generate-workspace-id.spec.ts +34 -7
  269. package/src/util/generate-workspace-id.ts +464 -440
  270. package/src/util/gitpod-cookie.ts +8 -9
  271. package/src/util/gitpod-host-url.spec.ts +40 -13
  272. package/src/util/gitpod-host-url.ts +40 -41
  273. package/src/util/grpc.ts +1 -1
  274. package/src/util/jaeger-client-types.ts +102 -0
  275. package/src/util/logging.ts +49 -40
  276. package/src/util/make-link.ts +6 -7
  277. package/src/util/parse-workspace-id.spec.ts +17 -8
  278. package/src/util/parse-workspace-id.ts +6 -7
  279. package/src/util/queue.spec.ts +27 -25
  280. package/src/util/repeat.ts +45 -0
  281. package/src/util/semaphore.ts +4 -6
  282. package/src/util/skip-if.ts +9 -6
  283. package/src/util/timeutil.spec.ts +14 -15
  284. package/src/util/timeutil.ts +21 -11
  285. package/src/util/tracing.spec.ts +88 -0
  286. package/src/util/tracing.ts +200 -31
  287. package/src/util/workspace-port-authentication.ts +10 -13
  288. package/src/workspace-cluster.ts +26 -15
  289. package/src/workspace-instance.ts +69 -20
  290. package/src/wsready.ts +3 -3
  291. package/data/builtin-theia-plugins.json +0 -372
  292. package/lib/messaging/connection-error-handler.d.ts +0 -27
  293. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  294. package/lib/messaging/connection-error-handler.js +0 -34
  295. package/lib/messaging/connection-error-handler.js.map +0 -1
  296. package/lib/theia-plugins.d.ts +0 -11
  297. package/lib/theia-plugins.d.ts.map +0 -1
  298. package/lib/theia-plugins.js.map +0 -1
  299. package/lib/util/repeater.d.ts +0 -22
  300. package/lib/util/repeater.d.ts.map +0 -1
  301. package/lib/util/repeater.js +0 -65
  302. package/lib/util/repeater.js.map +0 -1
  303. package/lib/util/safe-promise.d.ts +0 -11
  304. package/lib/util/safe-promise.d.ts.map +0 -1
  305. package/lib/util/safe-promise.js +0 -31
  306. package/lib/util/safe-promise.js.map +0 -1
  307. package/src/messaging/connection-error-handler.ts +0 -62
  308. package/src/theia-plugins.ts +0 -11
  309. package/src/util/jaeger-client.d.ts +0 -105
  310. package/src/util/repeater.ts +0 -49
  311. package/src/util/safe-promise.ts +0 -26
@@ -4,94 +4,93 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { injectable } from 'inversify';
8
- import * as prometheusClient from 'prom-client';
7
+ import { injectable } from "inversify";
8
+ import * as prometheusClient from "prom-client";
9
9
 
10
- type GrpcMethodType = 'unary' | 'client_stream' | 'server_stream' | 'bidi_stream';
10
+ type GrpcMethodType = "unary" | "client_stream" | "server_stream" | "bidi_stream";
11
11
  export interface IGrpcCallMetricsLabels {
12
- service: string,
13
- method: string,
14
- type: GrpcMethodType,
12
+ service: string;
13
+ method: string;
14
+ type: GrpcMethodType;
15
15
  }
16
16
 
17
17
  export interface IGrpcCallMetricsLabelsWithCode extends IGrpcCallMetricsLabels {
18
- code: string
18
+ code: string;
19
19
  }
20
20
 
21
21
  export const IClientCallMetrics = Symbol("IClientCallMetrics");
22
22
 
23
23
  export interface IClientCallMetrics {
24
- started(labels: IGrpcCallMetricsLabels) : void;
25
- sent(labels: IGrpcCallMetricsLabels) : void;
26
- received(labels: IGrpcCallMetricsLabels) : void;
27
- handled(labels: IGrpcCallMetricsLabelsWithCode) : void;
24
+ started(labels: IGrpcCallMetricsLabels): void;
25
+ sent(labels: IGrpcCallMetricsLabels): void;
26
+ received(labels: IGrpcCallMetricsLabels): void;
27
+ handled(labels: IGrpcCallMetricsLabelsWithCode): void;
28
28
  }
29
29
 
30
30
  @injectable()
31
31
  export class PrometheusClientCallMetrics implements IClientCallMetrics {
32
+ readonly startedCounter: prometheusClient.Counter<string>;
33
+ readonly sentCounter: prometheusClient.Counter<string>;
34
+ readonly receivedCounter: prometheusClient.Counter<string>;
35
+ readonly handledCounter: prometheusClient.Counter<string>;
32
36
 
33
- readonly startedCounter: prometheusClient.Counter<string>;
34
- readonly sentCounter: prometheusClient.Counter<string>;
35
- readonly receivedCounter: prometheusClient.Counter<string>;
36
- readonly handledCounter: prometheusClient.Counter<string>;
37
+ constructor() {
38
+ this.startedCounter = new prometheusClient.Counter({
39
+ name: "grpc_client_started_total",
40
+ help: "Total number of RPCs started on the client.",
41
+ labelNames: ["grpc_service", "grpc_method", "grpc_type"],
42
+ registers: [prometheusClient.register],
43
+ });
44
+ this.sentCounter = new prometheusClient.Counter({
45
+ name: "grpc_client_msg_sent_total",
46
+ help: " Total number of gRPC stream messages sent by the client.",
47
+ labelNames: ["grpc_service", "grpc_method", "grpc_type"],
48
+ registers: [prometheusClient.register],
49
+ });
50
+ this.receivedCounter = new prometheusClient.Counter({
51
+ name: "grpc_client_msg_received_total",
52
+ help: "Total number of RPC stream messages received by the client.",
53
+ labelNames: ["grpc_service", "grpc_method", "grpc_type"],
54
+ registers: [prometheusClient.register],
55
+ });
56
+ this.handledCounter = new prometheusClient.Counter({
57
+ name: "grpc_client_handled_total",
58
+ help: "Total number of RPCs completed by the client, regardless of success or failure.",
59
+ labelNames: ["grpc_service", "grpc_method", "grpc_type", "grpc_code"],
60
+ registers: [prometheusClient.register],
61
+ });
62
+ }
37
63
 
38
- constructor() {
39
- this.startedCounter = new prometheusClient.Counter({
40
- name: 'grpc_client_started_total',
41
- help: 'Total number of RPCs started on the client.',
42
- labelNames: ['grpc_service', 'grpc_method', 'grpc_type'],
43
- registers: [prometheusClient.register]
44
- });
45
- this.sentCounter = new prometheusClient.Counter({
46
- name: 'grpc_client_msg_sent_total',
47
- help: ' Total number of gRPC stream messages sent by the client.',
48
- labelNames: ['grpc_service', 'grpc_method', 'grpc_type'],
49
- registers: [prometheusClient.register]
50
- });
51
- this.receivedCounter = new prometheusClient.Counter({
52
- name: 'grpc_client_msg_received_total',
53
- help: 'Total number of RPC stream messages received by the client.',
54
- labelNames: ['grpc_service', 'grpc_method', 'grpc_type'],
55
- registers: [prometheusClient.register]
56
- });
57
- this.handledCounter = new prometheusClient.Counter({
58
- name: 'grpc_client_handled_total',
59
- help: 'Total number of RPCs completed by the client, regardless of success or failure.',
60
- labelNames: ['grpc_service', 'grpc_method', 'grpc_type', 'grpc_code'],
61
- registers: [prometheusClient.register]
62
- });
63
- }
64
+ started(labels: IGrpcCallMetricsLabels): void {
65
+ this.startedCounter.inc({
66
+ grpc_service: labels.service,
67
+ grpc_method: labels.method,
68
+ grpc_type: labels.type,
69
+ });
70
+ }
64
71
 
65
- started(labels: IGrpcCallMetricsLabels): void {
66
- this.startedCounter.inc({
67
- grpc_service: labels.service,
68
- grpc_method: labels.method,
69
- grpc_type: labels.type
70
- });
71
- }
72
+ sent(labels: IGrpcCallMetricsLabels): void {
73
+ this.sentCounter.inc({
74
+ grpc_service: labels.service,
75
+ grpc_method: labels.method,
76
+ grpc_type: labels.type,
77
+ });
78
+ }
72
79
 
73
- sent(labels: IGrpcCallMetricsLabels): void {
74
- this.sentCounter.inc({
75
- grpc_service: labels.service,
76
- grpc_method: labels.method,
77
- grpc_type: labels.type
78
- });
79
- }
80
+ received(labels: IGrpcCallMetricsLabels): void {
81
+ this.receivedCounter.inc({
82
+ grpc_service: labels.service,
83
+ grpc_method: labels.method,
84
+ grpc_type: labels.type,
85
+ });
86
+ }
80
87
 
81
- received(labels: IGrpcCallMetricsLabels): void {
82
- this.receivedCounter.inc({
83
- grpc_service: labels.service,
84
- grpc_method: labels.method,
85
- grpc_type: labels.type
86
- });
87
- }
88
-
89
- handled(labels: IGrpcCallMetricsLabelsWithCode): void {
90
- this.handledCounter.inc({
91
- grpc_service: labels.service,
92
- grpc_method: labels.method,
93
- grpc_type: labels.type,
94
- grpc_code: labels.code
95
- });
96
- }
88
+ handled(labels: IGrpcCallMetricsLabelsWithCode): void {
89
+ this.handledCounter.inc({
90
+ grpc_service: labels.service,
91
+ grpc_method: labels.method,
92
+ grpc_type: labels.type,
93
+ grpc_code: labels.code,
94
+ });
95
+ }
97
96
  }
@@ -4,9 +4,10 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
-
8
-
9
7
  export namespace ErrorCodes {
8
+ // 400 Unauthorized
9
+ export const BAD_REQUEST = 400;
10
+
10
11
  // 401 Unauthorized
11
12
  export const NOT_AUTHENTICATED = 401;
12
13
 
@@ -61,6 +62,9 @@ export namespace ErrorCodes {
61
62
  // 490 Too Many Running Workspace
62
63
  export const TOO_MANY_RUNNING_WORKSPACES = 490;
63
64
 
65
+ // 500 Internal Server Error
66
+ export const INTERNAL_SERVER_ERROR = 500;
67
+
64
68
  // 501 EE Feature
65
69
  export const EE_FEATURE = 501;
66
70
 
@@ -78,4 +82,7 @@ export namespace ErrorCodes {
78
82
 
79
83
  // 630 Snapshot Error
80
84
  export const SNAPSHOT_ERROR = 630;
81
- }
85
+
86
+ // 640 Headless logs are not available (yet)
87
+ export const HEADLESS_LOG_NOT_YET_AVAILABLE = 640;
88
+ }
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { MessageConnection } from "vscode-jsonrpc";
9
9
 
10
- export const ConnectionHandler = Symbol('ConnectionHandler');
10
+ export const ConnectionHandler = Symbol("ConnectionHandler");
11
11
 
12
12
  export interface ConnectionHandler {
13
13
  readonly path: string;
@@ -18,10 +18,10 @@ export interface ConnectionEventHandler {
18
18
  /**
19
19
  * Called when the transport underpinning the connection got closed
20
20
  */
21
- onTransportDidClose(): void;
21
+ onTransportDidClose(): void;
22
22
 
23
- /**
24
- * Called when the transport underpinning the connection is (re-)opened
25
- */
26
- onTransportDidOpen(): void;
23
+ /**
24
+ * Called when the transport underpinning the connection is (re-)opened
25
+ */
26
+ onTransportDidOpen(): void;
27
27
  }
@@ -6,82 +6,35 @@
6
6
  */
7
7
 
8
8
  import * as ws from "ws";
9
- import * as http from "http";
10
- import * as https from "https";
11
- import * as url from "url";
12
- import * as net from "net";
13
- import { MessageConnection } from "vscode-jsonrpc";
14
- import { createWebSocketConnection, IWebSocket } from "vscode-ws-jsonrpc";
15
- import { log } from '../../util/logging';
9
+ import { IWebSocket } from "vscode-ws-jsonrpc";
16
10
 
17
- export interface IServerOptions {
18
- readonly server: http.Server | https.Server;
19
- readonly path?: string;
20
- matches?(request: http.IncomingMessage): boolean;
21
- }
22
-
23
- export function createServerWebSocketConnection(options: IServerOptions, onConnect: (connection: MessageConnection) => void): void {
24
- openJsonRpcSocket(options, socket => {
25
- onConnect(createWebSocketConnection(socket, console));
26
- });
27
- }
28
-
29
- export function openJsonRpcSocket(options: IServerOptions, onOpen: (socket: IWebSocket) => void): void {
30
- openSocket(options, socket => {
31
- const webSocket = toIWebSocket(socket);
32
- onOpen(webSocket);
33
- });
34
- }
35
-
36
- export interface OnOpen {
37
- (webSocket: ws, request: http.IncomingMessage, socket: net.Socket, head: Buffer): void;
38
- }
39
-
40
- export function openSocket(options: IServerOptions, onOpen: OnOpen): void {
41
- const wss = new ws.Server({
42
- noServer: true,
43
- perMessageDeflate: {
44
- // don't compress if a message is less than 256kb
45
- threshold: 256 * 1024
46
- }
47
- });
48
- options.server.on('upgrade', (request: http.IncomingMessage, socket: net.Socket, head: Buffer) => {
49
- const pathname = request.url ? url.parse(request.url).pathname : undefined;
50
- if (options.path && pathname === options.path || options.matches && options.matches(request)) {
51
- wss.handleUpgrade(request, socket, head, webSocket => {
52
- if (webSocket.readyState === webSocket.OPEN) {
53
- onOpen(webSocket, request, socket, head);
54
- } else {
55
- webSocket.on('open', () => onOpen(webSocket, request, socket, head));
56
- }
57
- });
58
- }
59
- });
60
- }
61
-
62
- export function toIWebSocket(webSocket: ws) {
63
- let sendsAfterOpen = 0;
11
+ export function toIWebSocket(ws: ws) {
64
12
  return <IWebSocket>{
65
- send: content => {
66
- if (webSocket.readyState !== ws.OPEN) {
67
- if (sendsAfterOpen++ > 3) {
68
- //log.debug(`Repeated try to send on closed web socket (readyState was ${webSocket.readyState})`, { ws });
69
- }
13
+ send: (content) => {
14
+ if (ws.readyState >= ws.CLOSING) {
15
+ // ws is already CLOSING/CLOSED, send() would just return an error.
70
16
  return;
71
17
  }
72
- webSocket.send(content, err => {
73
- if (err) {
74
- log.error('error in ws.send()', err, { ws });
75
- }
76
- })
18
+
19
+ // in general send-errors should trigger an 'error' event already, we just make sure it actually happens.
20
+ try {
21
+ ws.send(content, (err) => {
22
+ if (!err) {
23
+ return;
24
+ }
25
+ ws.emit("error", err);
26
+ });
27
+ } catch (err) {
28
+ ws.emit("error", err);
29
+ }
77
30
  },
78
- onMessage: cb => webSocket.on('message', cb),
79
- onError: cb => webSocket.on('error', cb),
80
- onClose: cb => webSocket.on('close', cb),
31
+ onMessage: (cb) => ws.on("message", cb),
32
+ onError: (cb) => ws.on("error", cb),
33
+ onClose: (cb) => ws.on("close", cb),
81
34
  dispose: () => {
82
- if (webSocket.readyState < ws.CLOSING) {
83
- webSocket.close();
35
+ if (ws.readyState < ws.CLOSING) {
36
+ ws.close();
84
37
  }
85
- }
38
+ },
86
39
  };
87
40
  }
@@ -8,8 +8,8 @@
8
8
  import { MessageConnection, ResponseError } from "vscode-jsonrpc";
9
9
  import { Event, Emitter } from "../util/event";
10
10
  import { Disposable } from "../util/disposable";
11
- import { ConnectionHandler } from './handler';
12
- import { log } from '../util/logging';
11
+ import { ConnectionHandler } from "./handler";
12
+ import { log } from "../util/logging";
13
13
 
14
14
  export type JsonRpcServer<Client> = Disposable & {
15
15
  /**
@@ -27,10 +27,7 @@ export interface JsonRpcConnectionEventEmitter {
27
27
  export type JsonRpcProxy<T> = T & JsonRpcConnectionEventEmitter;
28
28
 
29
29
  export class JsonRpcConnectionHandler<T extends object> implements ConnectionHandler {
30
- constructor(
31
- readonly path: string,
32
- readonly targetFactory: (proxy: JsonRpcProxy<T>, request?: object) => any
33
- ) { }
30
+ constructor(readonly path: string, readonly targetFactory: (proxy: JsonRpcProxy<T>, request?: object) => any) {}
34
31
 
35
32
  onConnection(connection: MessageConnection, request?: object): void {
36
33
  const factory = new JsonRpcProxyFactory<T>();
@@ -83,7 +80,6 @@ export class JsonRpcConnectionHandler<T extends object> implements ConnectionHan
83
80
  * @param <T> - The type of the object to expose to JSON-RPC.
84
81
  */
85
82
  export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
86
-
87
83
  protected readonly onDidOpenConnectionEmitter = new Emitter<void>();
88
84
  protected readonly onDidCloseConnectionEmitter = new Emitter<void>();
89
85
 
@@ -101,17 +97,15 @@ export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
101
97
  }
102
98
 
103
99
  protected waitForConnection(): void {
104
- this.connectionPromise = new Promise(resolve =>
105
- this.connectionPromiseResolve = resolve
106
- );
107
- this.connectionPromise.then(connection => {
100
+ this.connectionPromise = new Promise((resolve) => (this.connectionPromiseResolve = resolve));
101
+ this.connectionPromise.then((connection) => {
108
102
  connection.onClose(() => this.fireConnectionClosed());
109
103
  this.fireConnectionOpened();
110
104
  });
111
105
  }
112
106
 
113
107
  fireConnectionClosed() {
114
- this.onDidCloseConnectionEmitter.fire(undefined)
108
+ this.onDidCloseConnectionEmitter.fire(undefined);
115
109
  }
116
110
 
117
111
  fireConnectionOpened() {
@@ -204,35 +198,34 @@ export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
204
198
  * @returns A callable that executes the JSON-RPC call.
205
199
  */
206
200
  get(target: T, p: PropertyKey, receiver: any): any {
207
- if (p === 'setClient') {
201
+ if (p === "setClient") {
208
202
  return (client: any) => {
209
203
  this.target = client;
210
204
  };
211
205
  }
212
- if (p === 'onDidOpenConnection') {
206
+ if (p === "onDidOpenConnection") {
213
207
  return this.onDidOpenConnectionEmitter.event;
214
208
  }
215
- if (p === 'onDidCloseConnection') {
209
+ if (p === "onDidCloseConnection") {
216
210
  return this.onDidCloseConnectionEmitter.event;
217
211
  }
218
212
  const isNotify = this.isNotification(p);
219
213
  return (...args: any[]) =>
220
- this.connectionPromise.then(connection =>
221
- new Promise((resolve, reject) => {
222
- try {
223
- if (isNotify) {
224
- connection.sendNotification(p.toString(), ...args);
225
- resolve(undefined);
226
- } else {
227
- const resultPromise = connection.sendRequest(p.toString(), ...args) as Promise<any>;
228
- resultPromise
229
- .catch((err: any) => reject(err))
230
- .then((result: any) => resolve(result));
214
+ this.connectionPromise.then(
215
+ (connection) =>
216
+ new Promise((resolve, reject) => {
217
+ try {
218
+ if (isNotify) {
219
+ connection.sendNotification(p.toString(), ...args);
220
+ resolve(undefined);
221
+ } else {
222
+ const resultPromise = connection.sendRequest(p.toString(), ...args) as Promise<any>;
223
+ resultPromise.catch((err: any) => reject(err)).then((result: any) => resolve(result));
224
+ }
225
+ } catch (err) {
226
+ reject(err);
231
227
  }
232
- } catch (err) {
233
- reject(err);
234
- }
235
- })
228
+ }),
236
229
  );
237
230
  }
238
231
 
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ export interface OssAllowList {
8
+ /**
9
+ * A string that identifies a GitHub/GitLab/Bitbucket identity of the form "<host>/<profilename>"
10
+ * E.g., "github.com/geropl"
11
+ */
12
+ identity: string;
13
+
14
+ deleted?: boolean;
15
+ }
@@ -4,8 +4,8 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- export namespace PaymentProtocol {
8
- export const UPDATE_GITPOD_SUBSCRIPTION_PATH = '/payment/chargebee'
7
+ export namespace PaymentProtocol {
8
+ export const UPDATE_GITPOD_SUBSCRIPTION_PATH = "/payment/chargebee";
9
9
  }
10
10
 
11
11
  export interface PlanCoupon {
package/src/permission.ts CHANGED
@@ -4,34 +4,49 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
-
8
7
  // see below for explanation
9
8
  export const Permissions = {
10
- "monitor": undefined,
11
- "enforcement": undefined,
9
+ monitor: undefined,
10
+ enforcement: undefined,
12
11
  "privileged-ws": undefined,
13
12
  "registry-access": undefined,
14
13
  "admin-users": undefined,
15
14
  "admin-workspaces": undefined,
15
+ "admin-projects": undefined,
16
16
  "admin-api": undefined,
17
17
  "ide-settings": undefined,
18
18
  "new-workspace-cluster": undefined,
19
19
  };
20
- export type PermissionName = keyof (typeof Permissions);
21
- export const Roles = {"devops": undefined, "viewer": undefined, "admin": undefined };
22
- export type RoleName = keyof (typeof Roles);
20
+ export type PermissionName = keyof typeof Permissions;
21
+ export const Roles = { devops: undefined, viewer: undefined, admin: undefined };
22
+ export type RoleName = keyof typeof Roles;
23
23
  export type RoleOrPermission = RoleName | PermissionName;
24
24
 
25
25
  export namespace RoleName {
26
26
  export const is = (o: any): o is RoleName => {
27
- return typeof(o) === 'string'
28
- && Role.all().some(r => r.name === o);
29
- }
27
+ return typeof o === "string" && Role.all().some((r) => r.name === o);
28
+ };
30
29
  }
31
30
 
32
31
  export interface Role {
33
- name: RoleName,
34
- permissions: PermissionName[],
32
+ name: RoleName;
33
+ permissions: PermissionName[];
34
+ }
35
+
36
+ export namespace RolesOrPermissions {
37
+ export function toPermissionSet(rolesOrPermissions: RoleOrPermission[] | undefined): Set<PermissionName> {
38
+ rolesOrPermissions = rolesOrPermissions || [];
39
+
40
+ const permissions = new Set<PermissionName>();
41
+ for (const rop of rolesOrPermissions) {
42
+ if (Permission.is(rop)) {
43
+ permissions.add(rop);
44
+ } else if (RoleName.is(rop)) {
45
+ Role.getByName(rop).permissions.forEach((p) => permissions.add(p));
46
+ }
47
+ }
48
+ return permissions;
49
+ }
35
50
  }
36
51
 
37
52
  export namespace Permission {
@@ -50,6 +65,9 @@ export namespace Permission {
50
65
  /** The permission for accessing all workspace data */
51
66
  export const ADMIN_WORKSPACES: PermissionName = "admin-workspaces";
52
67
 
68
+ /** The permission for accessing all projects data */
69
+ export const ADMIN_PROJECTS: PermissionName = "admin-projects";
70
+
53
71
  /** The permission to access the admin API */
54
72
  export const ADMIN_API: PermissionName = "admin-api";
55
73
 
@@ -57,14 +75,11 @@ export namespace Permission {
57
75
  export const IDE_SETTINGS: PermissionName = "ide-settings";
58
76
 
59
77
  export const is = (o: any): o is PermissionName => {
60
- return typeof(o) === 'string'
61
- && Permission.all().some(p => p === o);
62
- }
78
+ return typeof o === "string" && Permission.all().some((p) => p === o);
79
+ };
63
80
 
64
81
  export const all = (): PermissionName[] => {
65
- return Object.keys(Permission)
66
- .map(k => (Permission as any)[k])
67
- .filter(k => typeof(k) === 'string');
82
+ return Object.keys(Permissions) as PermissionName[];
68
83
  };
69
84
  }
70
85
 
@@ -72,21 +87,13 @@ export namespace Role {
72
87
  /** The default role for all Gitpod developers */
73
88
  export const DEVOPS: Role = {
74
89
  name: "devops",
75
- permissions: [
76
- Permission.MONITOR,
77
- Permission.ENFORCEMENT,
78
- Permission.REGISTRY_ACCESS,
79
- Permission.IDE_SETTINGS
80
- ]
90
+ permissions: [Permission.MONITOR, Permission.ENFORCEMENT, Permission.REGISTRY_ACCESS, Permission.IDE_SETTINGS],
81
91
  };
82
92
 
83
93
  /** A role for people that are allowed to view Gitpod internals */
84
94
  export const VIEWER: Role = {
85
95
  name: "viewer",
86
- permissions: [
87
- Permission.MONITOR,
88
- Permission.REGISTRY_ACCESS,
89
- ]
96
+ permissions: [Permission.MONITOR, Permission.REGISTRY_ACCESS],
90
97
  };
91
98
 
92
99
  export const ADMIN: Role = {
@@ -94,13 +101,14 @@ export namespace Role {
94
101
  permissions: [
95
102
  Permission.ADMIN_USERS,
96
103
  Permission.ADMIN_WORKSPACES,
104
+ Permission.ADMIN_PROJECTS,
97
105
  Permission.ADMIN_API,
98
106
  Permission.ENFORCEMENT,
99
- ]
100
- }
107
+ ],
108
+ };
101
109
 
102
110
  export const getByName = (name: RoleName): Role => {
103
- const result = Role.all().find(r => r.name === name)
111
+ const result = Role.all().find((r) => r.name === name);
104
112
  if (!result) {
105
113
  throw Error("Unknown RoleName: " + name);
106
114
  }
@@ -109,7 +117,7 @@ export namespace Role {
109
117
 
110
118
  export const all = (): Role[] => {
111
119
  return Object.keys(Role)
112
- .map(k => (Role as any)[k])
113
- .filter(k => typeof(k) === 'object');
120
+ .map((k) => (Role as any)[k])
121
+ .filter((k) => typeof k === "object");
114
122
  };
115
123
  }