@gitpod/gitpod-protocol 0.1.5-tweak-workspaceconfig-origin-docs-fork.0 → 0.1.5-update-yarnlock.0
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 +150 -8
- package/lib/accounting-protocol.d.ts +21 -11
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +44 -33
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +29 -1
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +1 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +5 -6
- package/lib/analytics.d.ts.map +1 -1
- package/lib/analytics.js +1 -1
- package/lib/analytics.js.map +1 -1
- package/lib/attribution.d.ts +25 -0
- package/lib/attribution.d.ts.map +1 -0
- package/lib/attribution.js +58 -0
- package/lib/attribution.js.map +1 -0
- package/lib/auth.d.ts +1 -1
- package/lib/auth.d.ts.map +1 -1
- package/lib/auth.js +1 -1
- package/lib/billing-mode.d.ts +45 -0
- package/lib/billing-mode.d.ts.map +1 -0
- package/lib/billing-mode.js +44 -0
- package/lib/billing-mode.js.map +1 -0
- package/lib/blocked-repositories-protocol.d.ts +13 -0
- package/lib/blocked-repositories-protocol.d.ts.map +1 -0
- package/lib/blocked-repositories-protocol.js +8 -0
- package/lib/blocked-repositories-protocol.js.map +1 -0
- package/lib/context-url.d.ts +19 -7
- package/lib/context-url.d.ts.map +1 -1
- package/lib/context-url.js +60 -9
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.d.ts +3 -3
- package/lib/context-url.spec.d.ts.map +1 -1
- package/lib/context-url.spec.js +20 -12
- package/lib/context-url.spec.js.map +1 -1
- package/lib/encryption/container-module.d.ts +1 -1
- package/lib/encryption/container-module.d.ts.map +1 -1
- package/lib/encryption/container-module.js +2 -2
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.d.ts +1 -1
- package/lib/encryption/encryption-engine.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.js +10 -10
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.d.ts +1 -1
- package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +3 -4
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.d.ts +1 -1
- package/lib/encryption/encryption-service.d.ts.map +1 -1
- package/lib/encryption/encryption-service.js +2 -2
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.d.ts +1 -1
- package/lib/encryption/key-provider.d.ts.map +1 -1
- package/lib/encryption/key-provider.js +8 -10
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -6
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +2 -21
- package/lib/env.js.map +1 -1
- package/lib/experiments/always-default.d.ts +8 -0
- package/lib/experiments/always-default.d.ts.map +1 -0
- package/lib/experiments/always-default.js +20 -0
- package/lib/experiments/always-default.js.map +1 -0
- package/lib/experiments/configcat-server.d.ts +10 -0
- package/lib/experiments/configcat-server.d.ts.map +1 -0
- package/lib/experiments/configcat-server.js +37 -0
- package/lib/experiments/configcat-server.js.map +1 -0
- package/lib/experiments/configcat.d.ts +21 -0
- package/lib/experiments/configcat.d.ts.map +1 -0
- package/lib/experiments/configcat.js +51 -0
- package/lib/experiments/configcat.js.map +1 -0
- package/lib/experiments/types.d.ts +22 -0
- package/lib/experiments/types.d.ts.map +1 -0
- package/lib/experiments/types.js +10 -0
- package/lib/experiments/types.js.map +1 -0
- package/lib/frontend-dashboard-service.d.ts +99 -0
- package/lib/frontend-dashboard-service.d.ts.map +1 -0
- package/lib/frontend-dashboard-service.js +55 -0
- package/lib/frontend-dashboard-service.js.map +1 -0
- package/lib/gitpod-file-parser.d.ts +1 -1
- package/lib/gitpod-file-parser.d.ts.map +1 -1
- package/lib/gitpod-file-parser.js +7 -7
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.d.ts +1 -1
- package/lib/gitpod-file-parser.spec.js +43 -40
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +143 -51
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +78 -36
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +2 -1
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +3 -2
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-frontend-service.d.ts +2 -2
- package/lib/ide-frontend-service.js +1 -1
- package/lib/ide-protocol.d.ts +53 -8
- package/lib/ide-protocol.d.ts.map +1 -1
- package/lib/ide-protocol.js +11 -1
- package/lib/ide-protocol.js.map +1 -1
- package/lib/index.d.ts +17 -15
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +30 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -0
- package/lib/installation-admin-protocol.js +31 -0
- package/lib/installation-admin-protocol.js.map +1 -0
- package/lib/license-protocol.d.ts +8 -1
- package/lib/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.js +1 -1
- package/lib/license-protocol.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +1 -1
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +19 -19
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.d.ts +5 -5
- package/lib/messaging/browser/window-connection.d.ts.map +1 -1
- package/lib/messaging/browser/window-connection.js +10 -7
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +5 -19
- package/lib/messaging/client-call-metrics.d.ts.map +1 -1
- package/lib/messaging/client-call-metrics.js +35 -23
- package/lib/messaging/client-call-metrics.js.map +1 -1
- package/lib/messaging/error.d.ts +12 -2
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +26 -4
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/handler.js +1 -1
- package/lib/messaging/node/connection.d.ts +1 -17
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +23 -59
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +1 -1
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +7 -9
- 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/payment-protocol.d.ts +1 -1
- package/lib/payment-protocol.d.ts.map +1 -1
- package/lib/payment-protocol.js +2 -2
- package/lib/payment-protocol.js.map +1 -1
- package/lib/permission.d.ts +13 -4
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +38 -26
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +8 -5
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +227 -172
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +238 -104
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +322 -105
- package/lib/protocol.js.map +1 -1
- package/lib/protocol.spec.d.ts +7 -0
- package/lib/protocol.spec.d.ts.map +1 -0
- package/lib/protocol.spec.js +127 -0
- package/lib/protocol.spec.js.map +1 -0
- package/lib/snapshot-url.d.ts +1 -1
- package/lib/snapshot-url.js +1 -1
- package/lib/snapshot-url.spec.d.ts +1 -1
- package/lib/snapshot-url.spec.js +1 -1
- package/lib/snapshot-url.spec.js.map +1 -1
- package/lib/team-subscription-protocol.d.ts +24 -4
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +25 -6
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +39 -6
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js +21 -3
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/typings/globals.d.ts +7 -3
- package/lib/typings/globals.d.ts.map +1 -1
- package/lib/typings/globals.js +1 -1
- package/lib/usage.d.ts +73 -0
- package/lib/usage.d.ts.map +1 -0
- package/lib/usage.js +20 -0
- package/lib/usage.js.map +1 -0
- package/lib/util/analytics.d.ts +1 -1
- package/lib/util/analytics.d.ts.map +1 -1
- package/lib/util/analytics.js +13 -4
- package/lib/util/analytics.js.map +1 -1
- package/lib/util/async-iterator.d.ts +1 -1
- package/lib/util/async-iterator.d.ts.map +1 -1
- package/lib/util/async-iterator.js +4 -4
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.d.ts +1 -1
- package/lib/util/cancelable.js +1 -1
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.d.ts +1 -1
- package/lib/util/date-time.js +7 -7
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/debug-app.d.ts +25 -0
- package/lib/util/debug-app.d.ts.map +1 -0
- package/lib/util/debug-app.js +100 -0
- package/lib/util/debug-app.js.map +1 -0
- package/lib/util/deep-partial.d.ts +1 -1
- package/lib/util/deep-partial.js +1 -1
- package/lib/util/deferred.d.ts +1 -1
- package/lib/util/deferred.js +1 -1
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.d.ts.map +1 -1
- package/lib/util/disposable.js +2 -2
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.d.ts.map +1 -1
- package/lib/util/event.js +5 -3
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts +2 -1
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +12 -3
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +6 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +461 -440
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.d.ts +1 -1
- package/lib/util/generate-workspace-id.spec.js +37 -2
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +2 -2
- package/lib/util/gitpod-cookie.d.ts.map +1 -1
- package/lib/util/gitpod-cookie.js +1 -4
- package/lib/util/gitpod-cookie.js.map +1 -1
- package/lib/util/gitpod-host-url.d.ts +12 -5
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +69 -41
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +16 -6
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts +21 -1
- package/lib/util/grpc.d.ts.map +1 -1
- package/lib/util/grpc.js +74 -2
- package/lib/util/grpc.js.map +1 -1
- package/lib/util/jaeger-client-types.d.ts +68 -0
- package/lib/util/jaeger-client-types.d.ts.map +1 -0
- package/lib/{theia-plugins.js → util/jaeger-client-types.js} +2 -2
- package/lib/util/jaeger-client-types.js.map +1 -0
- package/lib/util/logging.d.ts +2 -2
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +32 -26
- package/lib/util/logging.js.map +1 -1
- package/lib/util/logging.spec.d.ts +7 -0
- package/lib/util/logging.spec.d.ts.map +1 -0
- package/lib/util/logging.spec.js +52 -0
- package/lib/util/logging.spec.js.map +1 -0
- package/lib/util/make-link.d.ts +1 -1
- package/lib/util/make-link.js +6 -6
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/nice-grpc.d.ts +9 -0
- package/lib/util/nice-grpc.d.ts.map +1 -0
- package/lib/util/nice-grpc.js +121 -0
- package/lib/util/nice-grpc.js.map +1 -0
- package/lib/util/parse-workspace-id.d.ts +1 -1
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +3 -4
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +1 -1
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.d.ts +1 -1
- package/lib/util/queue.js +1 -1
- package/lib/util/queue.spec.d.ts +1 -1
- package/lib/util/queue.spec.js +10 -7
- 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/semaphore.d.ts +1 -1
- package/lib/util/semaphore.d.ts.map +1 -1
- package/lib/util/semaphore.js +1 -1
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.d.ts +1 -1
- package/lib/util/skip-if.d.ts.map +1 -1
- package/lib/util/skip-if.js +1 -1
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.d.ts +3 -1
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +16 -4
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts +3 -1
- package/lib/util/timeutil.spec.d.ts.map +1 -1
- package/lib/util/timeutil.spec.js +35 -1
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +47 -13
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +141 -32
- 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.d.ts +8 -8
- package/lib/util/workspace-port-authentication.d.ts.map +1 -1
- package/lib/util/workspace-port-authentication.js +9 -12
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/webhook-event.d.ts +44 -0
- package/lib/webhook-event.d.ts.map +1 -0
- package/lib/webhook-event.js +8 -0
- package/lib/webhook-event.js.map +1 -0
- package/lib/workspace-class.d.ts +14 -0
- package/lib/workspace-class.d.ts.map +1 -0
- package/lib/workspace-class.js +8 -0
- package/lib/workspace-class.js.map +1 -0
- package/lib/workspace-cluster.d.ts +24 -18
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +22 -2
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +41 -4
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/workspace-instance.js +1 -1
- package/lib/wsready.d.ts +8 -2
- package/lib/wsready.d.ts.map +1 -1
- package/lib/wsready.js +3 -3
- package/package.json +18 -8
- package/pkg-yarn.lock +11 -6
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +76 -52
- package/src/admin-protocol.ts +59 -19
- package/src/analytics.ts +27 -29
- package/src/attribution.ts +67 -0
- package/src/auth.ts +3 -3
- package/src/billing-mode.ts +84 -0
- package/src/blocked-repositories-protocol.ts +13 -0
- package/src/context-url.spec.ts +25 -15
- package/src/context-url.ts +93 -37
- package/src/encryption/container-module.ts +3 -4
- package/src/encryption/encryption-engine.spec.ts +10 -9
- package/src/encryption/encryption-engine.ts +21 -17
- package/src/encryption/encryption-service.ts +5 -6
- package/src/encryption/key-provider.ts +17 -20
- package/src/env.ts +2 -25
- package/src/experiments/always-default.ts +24 -0
- package/src/experiments/configcat-server.ts +42 -0
- package/src/experiments/configcat.ts +56 -0
- package/src/experiments/types.ts +34 -0
- package/src/frontend-dashboard-service.ts +148 -0
- package/src/gitpod-file-parser.spec.ts +56 -62
- package/src/gitpod-file-parser.ts +17 -18
- package/src/gitpod-service.ts +315 -136
- package/src/headless-workspace-log.ts +7 -5
- package/src/ide-frontend-service.ts +3 -3
- package/src/ide-protocol.ts +63 -8
- package/src/index.ts +17 -15
- package/src/installation-admin-protocol.ts +45 -0
- package/src/license-protocol.ts +13 -7
- package/src/messaging/browser/connection.ts +45 -47
- package/src/messaging/browser/window-connection.ts +40 -30
- package/src/messaging/client-call-metrics.ts +79 -82
- package/src/messaging/error.ts +37 -8
- package/src/messaging/handler.ts +6 -6
- package/src/messaging/node/connection.ts +23 -70
- package/src/messaging/proxy-factory.ts +23 -30
- package/src/oss-allowlist.ts +15 -0
- package/src/payment-protocol.ts +3 -3
- package/src/permission.ts +45 -33
- package/src/plans.ts +257 -190
- package/src/protocol.spec.ts +97 -0
- package/src/protocol.ts +650 -305
- package/src/snapshot-url.spec.ts +10 -8
- package/src/snapshot-url.ts +1 -1
- package/src/team-subscription-protocol.ts +63 -23
- package/src/teams-projects-protocol.ts +60 -12
- package/src/typings/globals.ts +12 -5
- package/src/usage.ts +85 -0
- package/src/util/analytics.ts +47 -25
- package/src/util/async-iterator.ts +5 -6
- package/src/util/cancelable.ts +4 -4
- package/src/util/date-time.ts +9 -9
- package/src/util/debug-app.ts +81 -0
- package/src/util/deep-partial.ts +1 -1
- package/src/util/deferred.ts +7 -7
- package/src/util/disposable.ts +3 -6
- package/src/util/event.ts +9 -11
- package/src/util/garbage-collected-cache.ts +15 -7
- package/src/util/generate-workspace-id.spec.ts +35 -8
- package/src/util/generate-workspace-id.ts +465 -441
- package/src/util/gitpod-cookie.ts +9 -10
- package/src/util/gitpod-host-url.spec.ts +41 -14
- package/src/util/gitpod-host-url.ts +81 -46
- package/src/util/grpc.ts +94 -2
- package/src/util/jaeger-client-types.ts +102 -0
- package/src/util/logging.spec.ts +23 -0
- package/src/util/logging.ts +61 -43
- package/src/util/make-link.ts +7 -8
- package/src/util/nice-grpc.ts +96 -0
- package/src/util/parse-workspace-id.spec.ts +18 -9
- package/src/util/parse-workspace-id.ts +7 -8
- package/src/util/queue.spec.ts +28 -26
- package/src/util/queue.ts +1 -1
- package/src/util/repeat.ts +45 -0
- package/src/util/semaphore.ts +5 -7
- package/src/util/skip-if.ts +10 -7
- package/src/util/timeutil.spec.ts +41 -15
- package/src/util/timeutil.ts +28 -12
- package/src/util/tracing.spec.ts +88 -0
- package/src/util/tracing.ts +175 -59
- package/src/util/workspace-port-authentication.ts +11 -14
- package/src/webhook-event.ts +55 -0
- package/src/workspace-class.ts +14 -0
- package/src/workspace-cluster.ts +46 -21
- package/src/workspace-instance.ts +84 -22
- package/src/wsready.ts +11 -4
- package/data/builtin-theia-plugins.json +0 -372
- package/lib/email-protocol.d.ts +0 -49
- package/lib/email-protocol.d.ts.map +0 -1
- package/lib/email-protocol.js +0 -28
- package/lib/email-protocol.js.map +0 -1
- package/lib/messaging/connection-error-handler.d.ts +0 -27
- package/lib/messaging/connection-error-handler.d.ts.map +0 -1
- package/lib/messaging/connection-error-handler.js +0 -34
- package/lib/messaging/connection-error-handler.js.map +0 -1
- package/lib/theia-plugins.d.ts +0 -11
- package/lib/theia-plugins.d.ts.map +0 -1
- package/lib/theia-plugins.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 -65
- package/lib/util/repeater.js.map +0 -1
- package/lib/util/safe-promise.d.ts +0 -11
- package/lib/util/safe-promise.d.ts.map +0 -1
- package/lib/util/safe-promise.js +0 -31
- package/lib/util/safe-promise.js.map +0 -1
- package/src/email-protocol.ts +0 -66
- package/src/messaging/connection-error-handler.ts +0 -62
- package/src/theia-plugins.ts +0 -11
- package/src/util/jaeger-client.d.ts +0 -105
- package/src/util/repeater.ts +0 -49
- package/src/util/safe-promise.ts +0 -26
package/src/analytics.ts
CHANGED
|
@@ -1,54 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
export const IAnalyticsWriter = Symbol("IAnalyticsWriter");
|
|
9
8
|
|
|
10
9
|
type Identity =
|
|
11
|
-
| { userId: string | number }
|
|
10
|
+
| { userId: string | number; anonymousId?: string | number }
|
|
12
11
|
| { userId?: string | number; anonymousId: string | number };
|
|
13
12
|
|
|
14
13
|
interface Message {
|
|
15
14
|
messageId?: string;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
export type IdentifyMessage = Message &
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
export type IdentifyMessage = Message &
|
|
18
|
+
Identity & {
|
|
19
|
+
traits?: any;
|
|
20
|
+
timestamp?: Date;
|
|
21
|
+
context?: any;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type TrackMessage = Message &
|
|
25
|
+
Identity & {
|
|
26
|
+
event: string;
|
|
27
|
+
properties?: any;
|
|
28
|
+
timestamp?: Date;
|
|
29
|
+
context?: any;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type PageMessage = Message &
|
|
33
|
+
Identity & {
|
|
34
|
+
properties?: any;
|
|
35
|
+
timestamp?: Date;
|
|
36
|
+
context?: any;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type RemoteTrackMessage = Omit<TrackMessage, "timestamp" | "userId">;
|
|
40
40
|
export type RemotePageMessage = Omit<PageMessage, "timestamp" | "userId"> & {
|
|
41
|
-
|
|
41
|
+
includePII?: boolean;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
export type RemoteIdentifyMessage = Omit<IdentifyMessage, "timestamp" | "userId"
|
|
44
|
+
export type RemoteIdentifyMessage = Omit<IdentifyMessage, "timestamp" | "userId">;
|
|
45
45
|
|
|
46
46
|
export interface IAnalyticsWriter {
|
|
47
|
-
|
|
48
47
|
identify(msg: IdentifyMessage): void;
|
|
49
48
|
|
|
50
49
|
track(msg: TrackMessage): void;
|
|
51
50
|
|
|
52
51
|
page(msg: PageMessage): void;
|
|
53
|
-
|
|
54
52
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 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 { User } from "./protocol";
|
|
8
|
+
import { Team } from "./teams-projects-protocol";
|
|
9
|
+
|
|
10
|
+
export type AttributionId = UserAttributionId | TeamAttributionId;
|
|
11
|
+
export type AttributionTarget = "user" | "team";
|
|
12
|
+
|
|
13
|
+
export interface UserAttributionId {
|
|
14
|
+
kind: "user";
|
|
15
|
+
userId: string;
|
|
16
|
+
}
|
|
17
|
+
export interface TeamAttributionId {
|
|
18
|
+
kind: "team";
|
|
19
|
+
teamId: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export namespace AttributionId {
|
|
23
|
+
const SEPARATOR = ":";
|
|
24
|
+
|
|
25
|
+
export function createFromOrganizationId(organizationId?: string): AttributionId | undefined {
|
|
26
|
+
return organizationId ? { kind: "team", teamId: organizationId } : undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function create(userOrTeam: User | Team): AttributionId {
|
|
30
|
+
if (User.is(userOrTeam)) {
|
|
31
|
+
return { kind: "user", userId: userOrTeam.id };
|
|
32
|
+
} else {
|
|
33
|
+
return { kind: "team", teamId: userOrTeam.id };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function parse(s: string): UserAttributionId | TeamAttributionId | undefined {
|
|
38
|
+
if (!s) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const parts = s.split(":");
|
|
42
|
+
if (parts.length !== 2) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
switch (parts[0]) {
|
|
46
|
+
case "user":
|
|
47
|
+
return { kind: "user", userId: parts[1] };
|
|
48
|
+
case "team":
|
|
49
|
+
return { kind: "team", teamId: parts[1] };
|
|
50
|
+
default:
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function render(id: AttributionId): string {
|
|
56
|
+
switch (id.kind) {
|
|
57
|
+
case "user":
|
|
58
|
+
return `user${SEPARATOR}${id.userId}`;
|
|
59
|
+
case "team":
|
|
60
|
+
return `team${SEPARATOR}${id.teamId}`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function equals(a: AttributionId, b: AttributionId): boolean {
|
|
65
|
+
return render(a) === render(b);
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/auth.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
export interface SelectAccountPayload {
|
|
@@ -11,14 +11,14 @@ export interface SelectAccountPayload {
|
|
|
11
11
|
authHost: string;
|
|
12
12
|
authName: string;
|
|
13
13
|
authProviderType: string;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
otherUser: {
|
|
16
16
|
name: string;
|
|
17
17
|
avatarUrl: string;
|
|
18
18
|
authHost: string;
|
|
19
19
|
authName: string;
|
|
20
20
|
authProviderType: string;
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
22
|
}
|
|
23
23
|
export namespace SelectAccountPayload {
|
|
24
24
|
export function is(data: any): data is SelectAccountPayload {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 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
|
+
/**
|
|
8
|
+
* BillingMode is used to answer the following questions:
|
|
9
|
+
* - Should UI piece x be displayed for this user/team? (getBillingModeForUser/Team)
|
|
10
|
+
* - What model should be used to limit this workspace's capabilities (mayStartWorkspace, setTimeout, workspace class, etc...) (getBillingMode(workspaceInstance.attributionId))
|
|
11
|
+
* - How is a workspace session charged for? (getBillingMode(workspaceInstance.attributionId))
|
|
12
|
+
*/
|
|
13
|
+
export type BillingMode = None | Chargebee | UsageBased;
|
|
14
|
+
export namespace BillingMode {
|
|
15
|
+
export const NONE: None = {
|
|
16
|
+
mode: "none",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Incl. upgrade and status */
|
|
20
|
+
export function showUsageBasedBilling(billingMode?: BillingMode): boolean {
|
|
21
|
+
if (!billingMode) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return (
|
|
25
|
+
billingMode.mode === "usage-based" || (billingMode.mode === "chargebee" && !!billingMode.canUpgradeToUBB)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function showTeamSubscriptionUI(billingMode?: BillingMode): boolean {
|
|
30
|
+
if (!billingMode) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return (
|
|
34
|
+
billingMode.mode === "chargebee" ||
|
|
35
|
+
(billingMode.mode === "usage-based" && !!billingMode.hasChargebeeTeamSubscription)
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function canSetWorkspaceClass(billingMode?: BillingMode): boolean {
|
|
40
|
+
if (!billingMode) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// if has any Stripe subscription, either directly or per team, OR we're running on a license
|
|
45
|
+
return billingMode.mode === "usage-based" || billingMode.mode === "none";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function canSetCostCenter(billingMode: BillingMode): boolean {
|
|
49
|
+
// if has any Stripe Subscription, either directly or per team
|
|
50
|
+
return billingMode.mode === "usage-based";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Payment is disabled */
|
|
55
|
+
interface None {
|
|
56
|
+
mode: "none";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Sessions is handled with old subscription logic based on Chargebee */
|
|
60
|
+
interface Chargebee {
|
|
61
|
+
mode: "chargebee";
|
|
62
|
+
|
|
63
|
+
/** True iff this is a team, and is based on a paid plan. Currently only set for teams! */
|
|
64
|
+
paid?: boolean;
|
|
65
|
+
|
|
66
|
+
canUpgradeToUBB?: boolean;
|
|
67
|
+
|
|
68
|
+
/** Name of team(s) that block switching to usage-based */
|
|
69
|
+
teamNames?: string[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Session is handld with new usage-based logic */
|
|
73
|
+
interface UsageBased {
|
|
74
|
+
mode: "usage-based";
|
|
75
|
+
|
|
76
|
+
/** True iff this is a team, and is based on a paid plan. Currently only set for teams! */
|
|
77
|
+
paid?: boolean;
|
|
78
|
+
|
|
79
|
+
/** User is already converted, but is member with at least one Chargebee-based "Team Plan" */
|
|
80
|
+
hasChargebeeTeamPlan?: boolean;
|
|
81
|
+
|
|
82
|
+
/** User is already converted, but is member or owner in at least one Chargebee-based "Team Subscription" */
|
|
83
|
+
hasChargebeeTeamSubscription?: boolean;
|
|
84
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 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 BlockedRepository {
|
|
8
|
+
id: number;
|
|
9
|
+
urlRegexp: string;
|
|
10
|
+
blockUser: boolean;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
}
|
package/src/context-url.spec.ts
CHANGED
|
@@ -1,39 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import * as chai from
|
|
8
|
-
import { suite, test } from
|
|
9
|
-
import {
|
|
7
|
+
import * as chai from "chai";
|
|
8
|
+
import { suite, test } from "mocha-typescript";
|
|
9
|
+
import { Workspace } from ".";
|
|
10
|
+
import { ContextURL } from "./context-url";
|
|
10
11
|
const expect = chai.expect;
|
|
11
12
|
|
|
13
|
+
type WsContextUrl = Pick<Workspace, "context" | "contextURL">;
|
|
14
|
+
|
|
12
15
|
@suite
|
|
13
16
|
export class ContextUrlTest {
|
|
14
|
-
|
|
15
17
|
@test public parseContextUrl_withEnvVar() {
|
|
16
|
-
const actual = ContextURL.
|
|
18
|
+
const actual = ContextURL.getNormalizedURL({
|
|
19
|
+
contextURL: "passedin=test%20value/https://github.com/gitpod-io/gitpod-test-repo",
|
|
20
|
+
context: {},
|
|
21
|
+
} as WsContextUrl);
|
|
17
22
|
expect(actual?.host).to.equal("github.com");
|
|
18
23
|
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
@test public parseContextUrl_withEnvVar_withoutSchema() {
|
|
22
|
-
const actual = ContextURL.
|
|
27
|
+
const actual = ContextURL.getNormalizedURL({
|
|
28
|
+
contextURL: "passedin=test%20value/github.com/gitpod-io/gitpod-test-repo",
|
|
29
|
+
context: {},
|
|
30
|
+
} as WsContextUrl);
|
|
23
31
|
expect(actual?.host).to.equal("github.com");
|
|
24
32
|
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
25
33
|
}
|
|
26
34
|
|
|
27
|
-
@test public
|
|
28
|
-
const actual = ContextURL.
|
|
35
|
+
@test public parseContextUrl_withEnvVar_sshUrl() {
|
|
36
|
+
const actual = ContextURL.getNormalizedURL({
|
|
37
|
+
contextURL: "passedin=test%20value/git@github.com:gitpod-io/gitpod-test-repo.git",
|
|
38
|
+
context: {},
|
|
39
|
+
} as WsContextUrl);
|
|
29
40
|
expect(actual?.host).to.equal("github.com");
|
|
30
|
-
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
41
|
+
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo.git");
|
|
31
42
|
}
|
|
32
43
|
|
|
33
|
-
@test public
|
|
34
|
-
const actual = ContextURL.
|
|
35
|
-
expect(actual
|
|
36
|
-
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
44
|
+
@test public parseContextUrl_badUrl() {
|
|
45
|
+
const actual = ContextURL.getNormalizedURL({ contextURL: "[Object object]", context: {} } as WsContextUrl);
|
|
46
|
+
expect(actual).to.be.undefined;
|
|
37
47
|
}
|
|
38
48
|
}
|
|
39
|
-
module.exports = new ContextUrlTest()
|
|
49
|
+
module.exports = new ContextUrlTest();
|
package/src/context-url.ts
CHANGED
|
@@ -1,51 +1,107 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { Workspace } from ".";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The whole point of these methods is to overcome inconsistencies in our data model.
|
|
11
|
+
* Ideally we remove it at some point once we fixed our model, as it:
|
|
12
|
+
* - duplicates logic
|
|
13
|
+
* - but additional burden on clients (using this, copying this to other languages!)
|
|
14
|
+
*
|
|
15
|
+
* TODO(gpl) See if we can get this into `server` code to remove the burden from clients
|
|
16
|
+
*/
|
|
7
17
|
export namespace ContextURL {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export const PREBUILD_PREFIX = "prebuild";
|
|
19
|
+
export const IMAGEBUILD_PREFIX = "imagebuild";
|
|
20
|
+
export const SNAPSHOT_PREFIX = "snapshot";
|
|
21
|
+
export const REFERRER_PREFIX = "referrer:";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This function will (try to) return the HTTP(S) URL of the context the user originally created this workspace on.
|
|
25
|
+
* Especially it will not contain any modifiers or be of different scheme than HTTP(S).
|
|
26
|
+
*
|
|
27
|
+
* Use this function if you need to provided a _working_ URL to the original context.
|
|
28
|
+
* @param ws
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export function getNormalizedURL(ws: Pick<Workspace, "context" | "contextURL"> | undefined): URL | undefined {
|
|
32
|
+
const normalized = normalize(ws);
|
|
33
|
+
if (!normalized) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
return new URL(normalized);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.debug(`unable to parse URL from normalized contextURL: '${normalized}'`);
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
21
43
|
}
|
|
22
44
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
45
|
+
function normalize(ws: Pick<Workspace, "context" | "contextURL"> | undefined): string | undefined {
|
|
46
|
+
if (!ws) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
if (ws.context.normalizedContextURL) {
|
|
50
|
+
return ws.context.normalizedContextURL;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// fallback: we do not yet set normalizedContextURL on all workspaces, yet, let alone older existing workspaces
|
|
54
|
+
let fallback: string | undefined = undefined;
|
|
55
|
+
try {
|
|
56
|
+
fallback = removePrefixes(ws.contextURL);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error(`unable to remove prefixes from contextURL: '${ws.contextURL}'`, err);
|
|
59
|
+
}
|
|
60
|
+
return fallback;
|
|
26
61
|
}
|
|
27
62
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
63
|
+
/**
|
|
64
|
+
* The field "contextUrl" might contain prefixes like:
|
|
65
|
+
* - envvar1=value1/...
|
|
66
|
+
* - prebuild/...
|
|
67
|
+
* This is the analogon to the (Prefix)ContextParser structure in "server".
|
|
68
|
+
*/
|
|
69
|
+
function removePrefixes(contextUrl: string | undefined): string | undefined {
|
|
70
|
+
if (contextUrl === undefined) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
35
73
|
|
|
74
|
+
const segments = contextUrl.split("/");
|
|
75
|
+
if (segments.length === 1) {
|
|
76
|
+
return segments[0]; // this might be something, we just try
|
|
77
|
+
}
|
|
36
78
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
79
|
+
const segmentsToURL = (offset: number): string => {
|
|
80
|
+
let rest = segments.slice(offset).join("/");
|
|
81
|
+
if (/^git@[^:\/]+:/.test(rest)) {
|
|
82
|
+
rest = rest.replace(/^git@([^:\/]+):/, "https://$1/");
|
|
83
|
+
}
|
|
84
|
+
if (!rest.startsWith("http")) {
|
|
85
|
+
rest = "https://" + rest;
|
|
86
|
+
}
|
|
87
|
+
return rest;
|
|
88
|
+
};
|
|
43
89
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
90
|
+
const firstSegment = segments[0];
|
|
91
|
+
if (
|
|
92
|
+
firstSegment === PREBUILD_PREFIX ||
|
|
93
|
+
firstSegment === IMAGEBUILD_PREFIX ||
|
|
94
|
+
firstSegment === SNAPSHOT_PREFIX ||
|
|
95
|
+
firstSegment.startsWith(REFERRER_PREFIX)
|
|
96
|
+
) {
|
|
97
|
+
return segmentsToURL(1);
|
|
98
|
+
}
|
|
48
99
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
100
|
+
// check for env vars
|
|
101
|
+
if (firstSegment.indexOf("=") !== -1) {
|
|
102
|
+
return segmentsToURL(1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return segmentsToURL(0);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { interfaces } from "inversify";
|
|
@@ -19,10 +19,9 @@ import { EncryptionService, EncryptionServiceImpl } from "./encryption-service";
|
|
|
19
19
|
* };
|
|
20
20
|
* }).inSingletonScope();
|
|
21
21
|
*/
|
|
22
|
-
export const encryptionModule: interfaces.ContainerModuleCallBack = bind => {
|
|
23
|
-
|
|
22
|
+
export const encryptionModule: interfaces.ContainerModuleCallBack = (bind) => {
|
|
24
23
|
bind(KeyProvider).to(KeyProviderImpl).inSingletonScope();
|
|
25
24
|
|
|
26
25
|
bind(EncryptionEngine).to(EncryptionEngineImpl).inSingletonScope();
|
|
27
26
|
bind(EncryptionService).to(EncryptionServiceImpl).inSingletonScope();
|
|
28
|
-
};
|
|
27
|
+
};
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { suite, test } from "mocha-typescript";
|
|
8
|
-
import * as chai from
|
|
9
|
-
import * as path from
|
|
8
|
+
import * as chai from "chai";
|
|
9
|
+
import * as path from "path";
|
|
10
10
|
import * as fs from "fs";
|
|
11
11
|
|
|
12
12
|
import { EncryptionEngineImpl } from "./encryption-engine";
|
|
13
13
|
|
|
14
14
|
const expect = chai.expect;
|
|
15
15
|
|
|
16
|
-
@suite
|
|
16
|
+
@suite
|
|
17
|
+
class TestEncryptionEngineImpl {
|
|
17
18
|
// Created with openssl rand -rand /dev/urandom -out key -base64 32
|
|
18
|
-
protected get testkey
|
|
19
|
-
const keyFilePath = path.resolve(__dirname,
|
|
19
|
+
protected get testkey() {
|
|
20
|
+
const keyFilePath = path.resolve(__dirname, "../../test/fixtures/encryption/testkey");
|
|
20
21
|
const keyBuffer = fs.readFileSync(keyFilePath);
|
|
21
22
|
return keyBuffer.toString().trim();
|
|
22
|
-
}
|
|
23
|
+
}
|
|
23
24
|
|
|
24
25
|
@test basicSymmetry() {
|
|
25
26
|
const plaintext = "12345678901234567890";
|
|
26
|
-
const key =
|
|
27
|
+
const key = Buffer.from(this.testkey, "base64");
|
|
27
28
|
|
|
28
29
|
const cut = new EncryptionEngineImpl();
|
|
29
30
|
const encryptedData = cut.encrypt(plaintext, key);
|
|
@@ -33,4 +34,4 @@ const expect = chai.expect;
|
|
|
33
34
|
expect(decryptedPlaintext).equals(plaintext);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
export const t = new TestEncryptionEngineImpl();
|
|
37
|
+
export const t = new TestEncryptionEngineImpl();
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import * as crypto from
|
|
8
|
-
import { injectable } from
|
|
7
|
+
import * as crypto from "crypto";
|
|
8
|
+
import { injectable } from "inversify";
|
|
9
9
|
|
|
10
10
|
export interface KeyParams {
|
|
11
|
-
iv: string
|
|
11
|
+
iv: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface EncryptedData {
|
|
15
15
|
/** utf8 encoded string */
|
|
16
|
-
data: string
|
|
17
|
-
keyParams: KeyParams
|
|
16
|
+
data: string;
|
|
17
|
+
keyParams: KeyParams;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export const EncryptionEngine = Symbol(
|
|
20
|
+
export const EncryptionEngine = Symbol("EncryptionEngine");
|
|
21
21
|
export interface EncryptionEngine {
|
|
22
22
|
/**
|
|
23
23
|
* @param data utf8 encoded string
|
|
@@ -32,28 +32,32 @@ export interface EncryptionEngine {
|
|
|
32
32
|
* - no salt, as we pass in a real key (no salting needed to turn a password into a key)
|
|
33
33
|
* The implementation closely follows the exampes in https://nodejs.org/api/crypto.html.
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
@injectable()
|
|
36
36
|
export class EncryptionEngineImpl {
|
|
37
|
-
readonly algorithm =
|
|
38
|
-
readonly enc =
|
|
37
|
+
readonly algorithm = "aes-256-cbc";
|
|
38
|
+
readonly enc = "base64";
|
|
39
39
|
|
|
40
40
|
encrypt(data: string, key: Buffer): EncryptedData {
|
|
41
41
|
const iv = crypto.randomBytes(16);
|
|
42
42
|
const cipher = crypto.createCipheriv(this.algorithm, key, iv);
|
|
43
|
-
const encrypted = cipher.update(
|
|
43
|
+
const encrypted = cipher.update(Buffer.from(data, "utf8"));
|
|
44
44
|
const finalEncrypted = Buffer.concat([encrypted, cipher.final()]);
|
|
45
45
|
return {
|
|
46
46
|
data: finalEncrypted.toString(this.enc),
|
|
47
47
|
keyParams: {
|
|
48
|
-
iv: iv.toString(this.enc)
|
|
49
|
-
}
|
|
48
|
+
iv: iv.toString(this.enc),
|
|
49
|
+
},
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
decrypt(encryptedData: EncryptedData, key: Buffer): string {
|
|
54
|
-
const decipher = crypto.createDecipheriv(
|
|
55
|
-
|
|
54
|
+
const decipher = crypto.createDecipheriv(
|
|
55
|
+
this.algorithm,
|
|
56
|
+
key,
|
|
57
|
+
Buffer.from(encryptedData.keyParams.iv, this.enc),
|
|
58
|
+
);
|
|
59
|
+
let decrypted = decipher.update(Buffer.from(encryptedData.data, this.enc));
|
|
56
60
|
const finalDecrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
57
|
-
return finalDecrypted.toString(
|
|
61
|
+
return finalDecrypted.toString("utf8");
|
|
58
62
|
}
|
|
59
|
-
}
|
|
63
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
|
-
* See License
|
|
4
|
+
* See License.AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { injectable, inject } from "inversify";
|
|
@@ -9,12 +9,11 @@ import { injectable, inject } from "inversify";
|
|
|
9
9
|
import { EncryptedData, EncryptionEngine } from "./encryption-engine";
|
|
10
10
|
import { KeyProvider, KeyMetadata } from "./key-provider";
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
export interface Encrypted<_T> extends EncryptedData {
|
|
14
|
-
keyMetadata: KeyMetadata
|
|
13
|
+
keyMetadata: KeyMetadata;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
export const EncryptionService = Symbol(
|
|
16
|
+
export const EncryptionService = Symbol("EncryptionService");
|
|
18
17
|
export interface EncryptionService {
|
|
19
18
|
encrypt<T>(data: T): Encrypted<T>;
|
|
20
19
|
decrypt<T>(encrypted: Encrypted<T>): T;
|
|
@@ -32,7 +31,7 @@ export class EncryptionServiceImpl implements EncryptionService {
|
|
|
32
31
|
const encryptedData = this.engine.encrypt(dataStr, key.material);
|
|
33
32
|
return {
|
|
34
33
|
...encryptedData,
|
|
35
|
-
keyMetadata: key.metadata
|
|
34
|
+
keyMetadata: key.metadata,
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -49,4 +48,4 @@ export class EncryptionServiceImpl implements EncryptionService {
|
|
|
49
48
|
protected deserialize<T>(data: string): T {
|
|
50
49
|
return JSON.parse(data) as T;
|
|
51
50
|
}
|
|
52
|
-
}
|
|
51
|
+
}
|