@gitpod/gitpod-protocol 0.1.5-pluggable-workspace-cluster.21 → 0.1.5-port-description-3059-fork.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/gitpod-schema.json +13 -24
- package/lib/accounting-protocol.d.ts +3 -6
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +10 -16
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +15 -4
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +15 -0
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +45 -0
- package/lib/analytics.d.ts.map +1 -0
- package/lib/analytics.js +10 -0
- package/lib/analytics.js.map +1 -0
- package/lib/context-url.d.ts +18 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +49 -0
- package/lib/context-url.js.map +1 -0
- package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +2 -0
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +73 -0
- package/lib/context-url.spec.js.map +1 -0
- package/lib/email-protocol.d.ts +1 -2
- package/lib/email-protocol.d.ts.map +1 -1
- package/lib/email-protocol.js +4 -4
- package/lib/email-protocol.js.map +1 -1
- package/lib/encryption/container-module.js +4 -4
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.js +19 -20
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +29 -36
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.js +29 -43
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.js +25 -30
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -2
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +20 -21
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.js +25 -41
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +116 -116
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +97 -19
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +155 -278
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +8 -11
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +4 -7
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-protocol.d.ts +81 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/ide-protocol.js +8 -0
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +4 -6
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +175 -44
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.js +35 -55
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +35 -0
- package/lib/messaging/client-call-metrics.d.ts.map +1 -0
- package/lib/messaging/client-call-metrics.js +83 -0
- package/lib/messaging/client-call-metrics.js.map +1 -0
- package/lib/messaging/connection-error-handler.js +11 -23
- package/lib/messaging/connection-error-handler.js.map +1 -1
- package/lib/messaging/error.d.ts +2 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +4 -2
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts +10 -0
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/node/connection.d.ts +0 -10
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +12 -50
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +2 -0
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +74 -159
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/oss-allowlist.d.ts +14 -0
- package/lib/oss-allowlist.d.ts.map +1 -0
- package/lib/oss-allowlist.js +8 -0
- package/lib/oss-allowlist.js.map +1 -0
- package/lib/permission.d.ts +2 -1
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +14 -13
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +210 -0
- package/lib/plans.d.ts.map +1 -0
- package/lib/plans.js +570 -0
- package/lib/plans.js.map +1 -0
- package/lib/protocol.d.ts +68 -13
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +68 -115
- package/lib/protocol.js.map +1 -1
- package/lib/snapshot-url.d.ts +14 -0
- package/lib/snapshot-url.d.ts.map +1 -0
- package/lib/snapshot-url.js +26 -0
- package/lib/snapshot-url.js.map +1 -0
- package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
- package/lib/snapshot-url.spec.d.ts.map +1 -0
- package/lib/snapshot-url.spec.js +41 -0
- package/lib/snapshot-url.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +4 -4
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +15 -12
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +110 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +23 -0
- package/lib/teams-projects-protocol.js.map +1 -0
- package/lib/util/analytics.d.ts +8 -0
- package/lib/util/analytics.d.ts.map +1 -0
- package/lib/util/analytics.js +79 -0
- package/lib/util/analytics.js.map +1 -0
- package/lib/util/async-iterator.js +55 -133
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js +17 -59
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +8 -8
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deferred.js +10 -12
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.js +26 -39
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.js +58 -74
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts +1 -0
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +26 -46
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +13 -67
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +34 -79
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +20 -0
- package/lib/util/gitpod-cookie.d.ts.map +1 -0
- package/lib/util/gitpod-cookie.js +44 -0
- package/lib/util/gitpod-cookie.js.map +1 -0
- package/lib/util/gitpod-host-url.d.ts +1 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +98 -98
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts +6 -0
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +102 -30
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts +15 -0
- package/lib/util/grpc.d.ts.map +1 -0
- package/lib/util/grpc.js +18 -0
- package/lib/util/grpc.js.map +1 -0
- package/lib/util/jaeger-client-types.d.ts +68 -0
- package/lib/util/jaeger-client-types.d.ts.map +1 -0
- package/lib/util/{without.js → jaeger-client-types.js} +1 -1
- package/lib/util/jaeger-client-types.js.map +1 -0
- package/lib/util/logging.d.ts +49 -33
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +107 -110
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.js +2 -2
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/parse-workspace-id.d.ts +10 -0
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +31 -7
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +4 -0
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +123 -84
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.js +16 -55
- package/lib/util/queue.js.map +1 -1
- package/lib/util/queue.spec.js +144 -288
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/repeat.d.ts +15 -0
- package/lib/util/repeat.d.ts.map +1 -0
- package/lib/util/repeat.js +55 -0
- package/lib/util/repeat.js.map +1 -0
- package/lib/util/safe-promise.js +9 -12
- package/lib/util/safe-promise.js.map +1 -1
- package/lib/util/semaphore.js +15 -46
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.js +6 -6
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.js +16 -16
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.js +21 -24
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +50 -5
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +171 -63
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.d.ts +7 -0
- package/lib/util/tracing.spec.d.ts.map +1 -0
- package/lib/util/tracing.spec.js +121 -0
- package/lib/util/tracing.spec.js.map +1 -0
- package/lib/util/workspace-port-authentication.js +2 -2
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +22 -3
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +3 -3
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +5 -2
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.d.ts +1 -1
- package/lib/wsready.js +2 -2
- package/package.json +29 -16
- package/pkg-yarn.lock +17 -9
- package/src/accounting-protocol.ts +4 -10
- package/src/admin-protocol.ts +33 -5
- package/src/analytics.ts +54 -0
- package/src/context-url.spec.ts +39 -0
- package/src/context-url.ts +51 -0
- package/src/email-protocol.ts +2 -3
- package/src/env.ts +10 -10
- package/src/gitpod-service.ts +132 -35
- package/src/headless-workspace-log.ts +7 -11
- package/src/ide-protocol.ts +92 -0
- package/src/index.ts +6 -1
- package/src/messaging/browser/connection.ts +184 -23
- package/src/messaging/client-call-metrics.ts +97 -0
- package/src/messaging/error.ts +5 -2
- package/src/messaging/handler.ts +12 -0
- package/src/messaging/node/connection.ts +3 -47
- package/src/messaging/proxy-factory.ts +13 -5
- package/src/oss-allowlist.ts +15 -0
- package/src/permission.ts +2 -1
- package/src/plans.ts +632 -0
- package/src/protocol.ts +91 -18
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +7 -5
- package/src/teams-projects-protocol.ts +141 -0
- package/src/util/analytics.ts +87 -0
- package/src/util/garbage-collected-cache.ts +9 -3
- package/src/util/generate-workspace-id.spec.ts +3 -3
- package/src/util/generate-workspace-id.ts +2 -0
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/gitpod-host-url.spec.ts +24 -0
- package/src/util/gitpod-host-url.ts +23 -10
- package/src/util/grpc.ts +15 -0
- package/src/util/jaeger-client-types.ts +102 -0
- package/src/util/logging.ts +102 -38
- package/src/util/parse-workspace-id.spec.ts +21 -1
- package/src/util/parse-workspace-id.ts +32 -6
- package/src/util/repeat.ts +45 -0
- package/src/util/semaphore.ts +2 -2
- package/src/util/skip-if.ts +1 -1
- package/src/util/timeutil.ts +4 -4
- package/src/util/tracing.spec.ts +83 -0
- package/src/util/tracing.ts +157 -18
- package/src/workspace-cluster.ts +24 -8
- package/src/workspace-instance.ts +25 -13
- package/src/wsready.ts +2 -2
- package/lib/util/context-url.d.ts +0 -13
- package/lib/util/context-url.d.ts.map +0 -1
- package/lib/util/context-url.js +0 -26
- package/lib/util/context-url.js.map +0 -1
- package/lib/util/context-url.spec.d.ts.map +0 -1
- package/lib/util/context-url.spec.js +0 -52
- package/lib/util/context-url.spec.js.map +0 -1
- package/lib/util/repeater.d.ts +0 -22
- package/lib/util/repeater.d.ts.map +0 -1
- package/lib/util/repeater.js +0 -118
- package/lib/util/repeater.js.map +0 -1
- package/lib/util/without.d.ts +0 -7
- package/lib/util/without.d.ts.map +0 -1
- package/lib/util/without.js.map +0 -1
- package/src/util/context-url.spec.ts +0 -25
- package/src/util/context-url.ts +0 -23
- package/src/util/jaeger-client.d.ts +0 -105
- package/src/util/repeater.ts +0 -49
package/src/protocol.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { WorkspaceInstance, PortVisibility } from "./workspace-instance";
|
|
8
8
|
import { RoleOrPermission } from "./permission";
|
|
9
|
+
import { Project } from "./teams-projects-protocol";
|
|
9
10
|
|
|
10
11
|
export interface UserInfo {
|
|
11
12
|
name?: string
|
|
@@ -27,8 +28,6 @@ export interface User {
|
|
|
27
28
|
|
|
28
29
|
identities: Identity[]
|
|
29
30
|
|
|
30
|
-
allowsMarketingCommunication: boolean;
|
|
31
|
-
|
|
32
31
|
/**
|
|
33
32
|
* Whether the user has been blocked to use our service, because of TOS violation for example.
|
|
34
33
|
* Optional for backwards compatibility.
|
|
@@ -100,14 +99,23 @@ export interface AdditionalUserData {
|
|
|
100
99
|
ideSettings?: IDESettings;
|
|
101
100
|
// key is the name of the news, string the iso date when it was seen
|
|
102
101
|
whatsNewSeen?: { [key: string]: string }
|
|
102
|
+
// key is the name of the OAuth client i.e. local app, string the iso date when it was approved
|
|
103
|
+
// TODO(rl): provide a management UX to allow rescinding of approval
|
|
104
|
+
oauthClientsApproved?: { [key: string]: string }
|
|
105
|
+
// to remember GH Orgs the user installed/updated the GH App for
|
|
106
|
+
knownGitHubOrgs?: string[];
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
export interface EmailNotificationSettings {
|
|
106
|
-
|
|
110
|
+
allowsChangelogMail?: boolean;
|
|
111
|
+
allowsDevXMail?: boolean;
|
|
112
|
+
allowsOnboardingMail?: boolean;
|
|
107
113
|
}
|
|
108
114
|
|
|
109
115
|
export type IDESettings = {
|
|
110
116
|
defaultIde?: string
|
|
117
|
+
useDesktopIde?: boolean
|
|
118
|
+
defaultDesktopIde?: string
|
|
111
119
|
}
|
|
112
120
|
|
|
113
121
|
export interface UserPlatform {
|
|
@@ -129,14 +137,6 @@ export interface UserPlatform {
|
|
|
129
137
|
}
|
|
130
138
|
|
|
131
139
|
export interface UserFeatureSettings {
|
|
132
|
-
/**
|
|
133
|
-
* This field is used as marker to grant users a free trial for using private repositories,
|
|
134
|
-
* independent of any subscription or Chargebee.
|
|
135
|
-
* - it is set when the user uses their first private repo
|
|
136
|
-
* - whether the trial is expired or not is juged by the UserService
|
|
137
|
-
*/
|
|
138
|
-
privateRepoTrialStartDate?: string;
|
|
139
|
-
|
|
140
140
|
/**
|
|
141
141
|
* Permanent feature flags are added to each and every workspace instance
|
|
142
142
|
* this user starts.
|
|
@@ -372,11 +372,16 @@ export interface PendingGithubEvent {
|
|
|
372
372
|
export interface Snapshot {
|
|
373
373
|
id: string;
|
|
374
374
|
creationTime: string;
|
|
375
|
+
availableTime?: string;
|
|
375
376
|
originalWorkspaceId: string;
|
|
376
377
|
bucketId: string;
|
|
377
378
|
layoutData?: string;
|
|
379
|
+
state: SnapshotState;
|
|
380
|
+
message?: string;
|
|
378
381
|
}
|
|
379
382
|
|
|
383
|
+
export type SnapshotState = 'pending' | 'available' | 'error';
|
|
384
|
+
|
|
380
385
|
export interface LayoutData {
|
|
381
386
|
workspaceId: string;
|
|
382
387
|
lastUpdatedTime: string;
|
|
@@ -389,6 +394,7 @@ export interface Workspace {
|
|
|
389
394
|
contextURL: string;
|
|
390
395
|
description: string;
|
|
391
396
|
ownerId: string;
|
|
397
|
+
projectId?: string;
|
|
392
398
|
context: WorkspaceContext;
|
|
393
399
|
config: WorkspaceConfig;
|
|
394
400
|
|
|
@@ -552,15 +558,20 @@ export interface WorkspaceConfig {
|
|
|
552
558
|
github?: GithubAppConfig;
|
|
553
559
|
vscode?: VSCodeConfig;
|
|
554
560
|
|
|
561
|
+
/** deprecated. Enabled by default **/
|
|
562
|
+
experimentalNetwork?: boolean;
|
|
563
|
+
|
|
555
564
|
/**
|
|
556
565
|
* Where the config object originates from.
|
|
557
566
|
*
|
|
558
567
|
* repo - from the repository
|
|
568
|
+
* project-db - from the "Project" stored in the database
|
|
559
569
|
* definitly-gp - from github.com/gitpod-io/definitely-gp
|
|
560
570
|
* derived - computed based on analyzing the repository
|
|
571
|
+
* additional-content - config comes from additional content, usually provided through the project's configuration
|
|
561
572
|
* default - our static catch-all default config
|
|
562
573
|
*/
|
|
563
|
-
_origin?: 'repo' | 'definitely-gp' | 'derived' | 'default';
|
|
574
|
+
_origin?: 'repo' | 'project-db' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
|
|
564
575
|
|
|
565
576
|
/**
|
|
566
577
|
* Set of automatically infered feature flags. That's not something the user can set, but
|
|
@@ -590,16 +601,13 @@ export namespace GithubAppPrebuildConfig {
|
|
|
590
601
|
|
|
591
602
|
export type WorkspaceImageSource = WorkspaceImageSourceDocker | WorkspaceImageSourceReference;
|
|
592
603
|
export interface WorkspaceImageSourceDocker {
|
|
593
|
-
// TODO: clean this up. We should have the commit and an ImageSource in here, not duplicate the whole thing again.
|
|
594
|
-
// We have a ton of those objects in the database, thus cleaning this up means lengthy DB migrations. Yuck.
|
|
595
|
-
dockerFileHash: string
|
|
596
|
-
dockerFileSource: Commit
|
|
597
604
|
dockerFilePath: string
|
|
605
|
+
dockerFileHash: string
|
|
606
|
+
dockerFileSource?: Commit
|
|
598
607
|
}
|
|
599
608
|
export namespace WorkspaceImageSourceDocker {
|
|
600
609
|
export function is(obj: object): obj is WorkspaceImageSourceDocker {
|
|
601
610
|
return 'dockerFileHash' in obj
|
|
602
|
-
&& 'dockerFileSource' in obj
|
|
603
611
|
&& 'dockerFilePath' in obj;
|
|
604
612
|
}
|
|
605
613
|
}
|
|
@@ -628,6 +636,8 @@ export type PrebuiltWorkspaceState
|
|
|
628
636
|
export interface PrebuiltWorkspace {
|
|
629
637
|
id: string;
|
|
630
638
|
cloneURL: string;
|
|
639
|
+
branch?: string;
|
|
640
|
+
projectId?: string;
|
|
631
641
|
commit: string;
|
|
632
642
|
buildWorkspaceId: string;
|
|
633
643
|
creationTime: string;
|
|
@@ -674,6 +684,8 @@ export interface PortConfig {
|
|
|
674
684
|
port: number;
|
|
675
685
|
onOpen?: PortOnOpen;
|
|
676
686
|
visibility?: PortVisibility;
|
|
687
|
+
description?: string;
|
|
688
|
+
name?: string;
|
|
677
689
|
}
|
|
678
690
|
export namespace PortConfig {
|
|
679
691
|
export function is(config: any): config is PortConfig {
|
|
@@ -697,7 +709,7 @@ export interface TaskConfig {
|
|
|
697
709
|
init?: string;
|
|
698
710
|
prebuild?: string;
|
|
699
711
|
command?: string;
|
|
700
|
-
env?: { [env: string]:
|
|
712
|
+
env?: { [env: string]: any };
|
|
701
713
|
openIn?: 'bottom' | 'main' | 'left' | 'right';
|
|
702
714
|
openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
|
|
703
715
|
}
|
|
@@ -761,8 +773,10 @@ export namespace ExternalImageConfigFile {
|
|
|
761
773
|
|
|
762
774
|
export interface WorkspaceContext {
|
|
763
775
|
title: string;
|
|
776
|
+
/** 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. */
|
|
764
777
|
normalizedContextURL?: string;
|
|
765
778
|
forceCreateNewWorkspace?: boolean;
|
|
779
|
+
forceImageBuild?: boolean;
|
|
766
780
|
}
|
|
767
781
|
|
|
768
782
|
export namespace WorkspaceContext {
|
|
@@ -796,6 +810,29 @@ export namespace WithPrebuild {
|
|
|
796
810
|
}
|
|
797
811
|
}
|
|
798
812
|
|
|
813
|
+
/**
|
|
814
|
+
* WithDefaultConfig contexts disable the download of the gitpod.yml from the repository
|
|
815
|
+
* and fall back to the built-in configuration.
|
|
816
|
+
*/
|
|
817
|
+
export interface WithDefaultConfig {
|
|
818
|
+
withDefaultConfig: true;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
export namespace WithDefaultConfig {
|
|
822
|
+
export function is(context: any): context is WithDefaultConfig {
|
|
823
|
+
return context
|
|
824
|
+
&& 'withDefaultConfig' in context
|
|
825
|
+
&& context.withDefaultConfig;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
|
|
829
|
+
return {
|
|
830
|
+
...ctx,
|
|
831
|
+
withDefaultConfig: true
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
799
836
|
export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
|
|
800
837
|
snapshotId: string;
|
|
801
838
|
}
|
|
@@ -810,6 +847,9 @@ export namespace SnapshotContext {
|
|
|
810
847
|
|
|
811
848
|
export interface StartPrebuildContext extends WorkspaceContext {
|
|
812
849
|
actual: WorkspaceContext;
|
|
850
|
+
commitHistory?: string[];
|
|
851
|
+
project?: Project;
|
|
852
|
+
branch?: string;
|
|
813
853
|
}
|
|
814
854
|
|
|
815
855
|
export namespace StartPrebuildContext {
|
|
@@ -879,6 +919,25 @@ export interface Commit {
|
|
|
879
919
|
refType?: RefType
|
|
880
920
|
}
|
|
881
921
|
|
|
922
|
+
export interface AdditionalContentContext extends WorkspaceContext {
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* utf-8 encoded contents that will be copied on top of the workspace's filesystem
|
|
926
|
+
*/
|
|
927
|
+
additionalFiles: {[filePath: string]: string};
|
|
928
|
+
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
export namespace AdditionalContentContext {
|
|
932
|
+
export function is(ctx: any): ctx is AdditionalContentContext {
|
|
933
|
+
return 'additionalFiles' in ctx;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
export function hasDockerConfig(ctx: any, config: WorkspaceConfig): boolean {
|
|
937
|
+
return is(ctx) && ImageConfigFile.is(config.image) && !!ctx.additionalFiles[config.image.file];
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
882
941
|
export interface CommitContext extends WorkspaceContext, Commit {
|
|
883
942
|
/** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
|
|
884
943
|
cloneUrl?: string
|
|
@@ -954,6 +1013,19 @@ export interface Repository {
|
|
|
954
1013
|
parent: Repository
|
|
955
1014
|
}
|
|
956
1015
|
}
|
|
1016
|
+
export interface Branch {
|
|
1017
|
+
name: string;
|
|
1018
|
+
commit: CommitInfo;
|
|
1019
|
+
htmlUrl: string;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
export interface CommitInfo {
|
|
1023
|
+
author: string;
|
|
1024
|
+
sha: string;
|
|
1025
|
+
commitMessage: string;
|
|
1026
|
+
authorAvatarUrl?: string;
|
|
1027
|
+
authorDate?: string;
|
|
1028
|
+
}
|
|
957
1029
|
|
|
958
1030
|
export namespace Repository {
|
|
959
1031
|
export function fullRepoName(repo: Repository): string {
|
|
@@ -996,6 +1068,7 @@ export interface WorkspaceCreationResult {
|
|
|
996
1068
|
runningWorkspacePrebuild?: {
|
|
997
1069
|
prebuildID: string
|
|
998
1070
|
workspaceID: string
|
|
1071
|
+
instanceID: string
|
|
999
1072
|
starting: RunningWorkspacePrebuildStarting
|
|
1000
1073
|
sameCluster: boolean
|
|
1001
1074
|
}
|
|
@@ -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,8 +4,7 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import uuidv4 = require("uuid/v4");
|
|
7
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
9
8
|
import { Subscription } from "./accounting-protocol";
|
|
10
9
|
|
|
11
10
|
export interface TeamSubscription {
|
|
@@ -22,7 +21,7 @@ export interface TeamSubscription {
|
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export namespace TeamSubscription {
|
|
25
|
-
export const create = (ts:
|
|
24
|
+
export const create = (ts: Omit<TeamSubscription, 'id'>): TeamSubscription => {
|
|
26
25
|
const withId = ts as TeamSubscription;
|
|
27
26
|
withId.id = uuidv4();
|
|
28
27
|
return withId;
|
|
@@ -49,7 +48,7 @@ export type TeamSubscriptionSlotAssigned = TeamSubscriptionSlot & TeamSubscripti
|
|
|
49
48
|
export type TeamSubscriptionSlotState = 'unassigned' | 'assigned' | 'deactivated' | 'cancelled';
|
|
50
49
|
|
|
51
50
|
export namespace TeamSubscriptionSlot {
|
|
52
|
-
export const create = (ts:
|
|
51
|
+
export const create = (ts: Omit<TeamSubscriptionSlot, 'id'>): TeamSubscriptionSlot => {
|
|
53
52
|
const withId = ts as TeamSubscriptionSlot;
|
|
54
53
|
withId.id = uuidv4();
|
|
55
54
|
return withId;
|
|
@@ -63,7 +62,7 @@ export namespace TeamSubscriptionSlot {
|
|
|
63
62
|
slot.subscriptionId = undefined;
|
|
64
63
|
slot.cancellationDate = cancellationDate;
|
|
65
64
|
}
|
|
66
|
-
export const reactivate = (slot: TeamSubscriptionSlot, subscriptionId
|
|
65
|
+
export const reactivate = (slot: TeamSubscriptionSlot, subscriptionId?: string) => {
|
|
67
66
|
slot.subscriptionId = subscriptionId;
|
|
68
67
|
slot.cancellationDate = undefined;
|
|
69
68
|
}
|
|
@@ -83,6 +82,9 @@ export namespace TeamSubscriptionSlot {
|
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
}
|
|
85
|
+
export const isActive = (slot: TeamSubscriptionSlot): boolean => {
|
|
86
|
+
return !slot.cancellationDate;
|
|
87
|
+
}
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
/**
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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 Analytics = require("analytics-node");
|
|
8
|
+
import { IAnalyticsWriter, IdentifyMessage, TrackMessage, PageMessage } from "../analytics";
|
|
9
|
+
import { log } from './logging';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export function newAnalyticsWriterFromEnv(): IAnalyticsWriter {
|
|
13
|
+
switch (process.env.GITPOD_ANALYTICS_WRITER) {
|
|
14
|
+
case "segment":
|
|
15
|
+
return new SegmentAnalyticsWriter(process.env.GITPOD_ANALYTICS_SEGMENT_KEY || "");
|
|
16
|
+
case "log":
|
|
17
|
+
return new LogAnalyticsWriter();
|
|
18
|
+
default:
|
|
19
|
+
return new NoAnalyticsWriter();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class SegmentAnalyticsWriter implements IAnalyticsWriter {
|
|
24
|
+
|
|
25
|
+
protected readonly analytics: Analytics;
|
|
26
|
+
|
|
27
|
+
constructor(writeKey: string) {
|
|
28
|
+
this.analytics = new Analytics(writeKey);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
identify(msg: IdentifyMessage) {
|
|
32
|
+
try {
|
|
33
|
+
this.analytics.identify(msg, (err: Error) => {
|
|
34
|
+
if (err) {
|
|
35
|
+
log.warn("analytics.identify failed", err);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
} catch (err) {
|
|
39
|
+
log.warn("analytics.identify failed", err);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
track(msg: TrackMessage) {
|
|
44
|
+
try {
|
|
45
|
+
this.analytics.track(msg, (err: Error) => {
|
|
46
|
+
if (err) {
|
|
47
|
+
log.warn("analytics.track failed", err);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
} catch (err) {
|
|
51
|
+
log.warn("analytics.track failed", err);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
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
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
class LogAnalyticsWriter implements IAnalyticsWriter {
|
|
70
|
+
|
|
71
|
+
identify(msg: IdentifyMessage): void {
|
|
72
|
+
log.debug("analytics identify", msg);
|
|
73
|
+
}
|
|
74
|
+
track(msg: TrackMessage): void {
|
|
75
|
+
log.debug("analytics track", msg);
|
|
76
|
+
}
|
|
77
|
+
page(msg: PageMessage): void {
|
|
78
|
+
log.debug("analytics page", msg);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
class NoAnalyticsWriter implements IAnalyticsWriter {
|
|
84
|
+
identify(msg: IdentifyMessage): void {}
|
|
85
|
+
track(msg: TrackMessage): void {}
|
|
86
|
+
page(msg: PageMessage): void {}
|
|
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;
|
|
@@ -13,13 +15,13 @@ interface CacheEntry<T> {
|
|
|
13
15
|
|
|
14
16
|
export class GarbageCollectedCache<T> {
|
|
15
17
|
protected readonly store = new Map<string, CacheEntry<T>>();
|
|
16
|
-
|
|
18
|
+
|
|
17
19
|
constructor(
|
|
18
20
|
protected readonly defaultMaxAgeSeconds: number,
|
|
19
21
|
protected readonly gcIntervalSeconds: number) {
|
|
20
22
|
this.regularlyCollectGarbage();
|
|
21
23
|
}
|
|
22
|
-
|
|
24
|
+
|
|
23
25
|
public set(key: string, value: T) {
|
|
24
26
|
const oldValue = this.store.get(key);
|
|
25
27
|
if (oldValue) {
|
|
@@ -41,8 +43,12 @@ export class GarbageCollectedCache<T> {
|
|
|
41
43
|
return entry.value;
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
public delete(key: string) {
|
|
47
|
+
this.store.delete(key);
|
|
48
|
+
}
|
|
49
|
+
|
|
44
50
|
protected regularlyCollectGarbage() {
|
|
45
|
-
|
|
51
|
+
repeat(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
protected collectGarbage() {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { suite, test } from "mocha-typescript"
|
|
8
8
|
import * as chai from "chai"
|
|
9
9
|
import { generateWorkspaceID, colors, animals } from "./generate-workspace-id";
|
|
10
|
-
import {
|
|
10
|
+
import { GitpodHostUrl } from "./gitpod-host-url";
|
|
11
11
|
|
|
12
12
|
const expect = chai.expect
|
|
13
13
|
|
|
@@ -15,8 +15,8 @@ const expect = chai.expect
|
|
|
15
15
|
|
|
16
16
|
@test public async testGenerateWorkspaceId() {
|
|
17
17
|
for (let i = 0; i < 100; i++) {
|
|
18
|
-
const
|
|
19
|
-
expect(
|
|
18
|
+
const id = await generateWorkspaceID();
|
|
19
|
+
expect(new GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -48,6 +48,7 @@ export const colors = [
|
|
|
48
48
|
'indigo',
|
|
49
49
|
'ivory',
|
|
50
50
|
'jade',
|
|
51
|
+
'kumquat',
|
|
51
52
|
'lavender',
|
|
52
53
|
'lime',
|
|
53
54
|
'magenta',
|
|
@@ -172,6 +173,7 @@ export const colors = [
|
|
|
172
173
|
'deer',
|
|
173
174
|
'dingo',
|
|
174
175
|
'dinosaur',
|
|
176
|
+
'dodo',
|
|
175
177
|
'dog',
|
|
176
178
|
'dolphin',
|
|
177
179
|
'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
|
+
};
|