@gitpod/gitpod-protocol 0.1.5-svenefftinge-patch-1.0 → 0.1.5-tar-telemetry-settings-data.2
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 +25 -24
- package/lib/accounting-protocol.d.ts +155 -0
- package/lib/accounting-protocol.d.ts.map +1 -0
- package/lib/accounting-protocol.js +109 -0
- package/lib/accounting-protocol.js.map +1 -0
- package/lib/admin-protocol.d.ts +30 -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 +31 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +102 -0
- package/lib/context-url.js.map +1 -0
- package/lib/context-url.spec.d.ts +14 -0
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +94 -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 +5 -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 +161 -20
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +170 -256
- 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 +105 -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 +6 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -1
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +27 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -0
- package/lib/installation-admin-protocol.js +30 -0
- package/lib/installation-admin-protocol.js.map +1 -0
- package/lib/messaging/browser/connection.d.ts +5 -3
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +183 -33
- 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/error.d.ts +4 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +8 -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 +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 +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/payment-protocol.d.ts +18 -0
- package/lib/payment-protocol.d.ts.map +1 -0
- package/lib/payment-protocol.js +13 -0
- package/lib/payment-protocol.js.map +1 -0
- package/lib/permission.d.ts +8 -1
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +36 -15
- 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 +118 -52
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +116 -130
- 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 +73 -0
- package/lib/team-subscription-protocol.d.ts.map +1 -0
- package/lib/team-subscription-protocol.js +63 -0
- package/lib/team-subscription-protocol.js.map +1 -0
- package/lib/teams-projects-protocol.d.ts +113 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +30 -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 +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +31 -68
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +57 -78
- 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 -2
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +95 -98
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts +7 -1
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +103 -31
- 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 +32 -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/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 +28 -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 +51 -5
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +197 -62
- 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 +3 -2
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +76 -0
- package/lib/workspace-cluster.d.ts.map +1 -0
- package/lib/workspace-cluster.js +33 -0
- package/lib/workspace-cluster.js.map +1 -0
- package/lib/workspace-instance.d.ts +24 -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 +31 -17
- package/pkg-yarn.lock +17 -9
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +229 -0
- package/src/admin-protocol.ts +52 -5
- package/src/analytics.ts +54 -0
- package/src/context-url.spec.ts +53 -0
- package/src/context-url.ts +107 -0
- package/src/email-protocol.ts +2 -3
- package/src/env.ts +10 -10
- package/src/gitpod-service.ts +234 -38
- package/src/headless-workspace-log.ts +7 -11
- package/src/ide-frontend-service.ts +1 -1
- package/src/ide-protocol.ts +119 -0
- package/src/index.ts +7 -1
- package/src/installation-admin-protocol.ts +42 -0
- package/src/messaging/browser/connection.ts +195 -14
- package/src/messaging/client-call-metrics.ts +97 -0
- package/src/messaging/error.ts +11 -2
- package/src/messaging/handler.ts +12 -0
- package/src/messaging/node/connection.ts +21 -68
- package/src/messaging/proxy-factory.ts +14 -6
- package/src/oss-allowlist.ts +15 -0
- package/src/payment-protocol.ts +20 -0
- package/src/permission.ts +24 -4
- package/src/plans.ts +632 -0
- package/src/protocol.ts +192 -82
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +113 -0
- package/src/teams-projects-protocol.ts +147 -0
- package/src/util/analytics.ts +87 -0
- package/src/util/deferred.ts +1 -1
- package/src/util/garbage-collected-cache.ts +9 -3
- package/src/util/generate-workspace-id.spec.ts +20 -3
- package/src/util/generate-workspace-id.ts +22 -2
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/gitpod-host-url.spec.ts +25 -1
- package/src/util/gitpod-host-url.ts +22 -13
- 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/queue.spec.ts +1 -1
- 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 +183 -17
- package/src/workspace-cluster.ts +104 -0
- package/src/workspace-instance.ts +45 -13
- package/src/wsready.ts +2 -2
- 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 -46
- package/lib/messaging/connection-error-handler.js.map +0 -1
- 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 +0 -10
- 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/safe-promise.d.ts +0 -11
- package/lib/util/safe-promise.d.ts.map +0 -1
- package/lib/util/safe-promise.js +0 -34
- package/lib/util/safe-promise.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/messaging/connection-error-handler.ts +0 -62
- 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/util/safe-promise.ts +0 -26
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
4
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
5
|
+
* See License-AGPL.txt in the project root for license information.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ContextURL = void 0;
|
|
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
|
+
*/
|
|
17
|
+
var ContextURL;
|
|
18
|
+
(function (ContextURL) {
|
|
19
|
+
ContextURL.INCREMENTAL_PREBUILD_PREFIX = "incremental-prebuild";
|
|
20
|
+
ContextURL.PREBUILD_PREFIX = "prebuild";
|
|
21
|
+
ContextURL.IMAGEBUILD_PREFIX = "imagebuild";
|
|
22
|
+
ContextURL.SNAPSHOT_PREFIX = "snapshot";
|
|
23
|
+
ContextURL.REFERRER_PREFIX = 'referrer:';
|
|
24
|
+
/**
|
|
25
|
+
* This function will (try to) return the HTTP(S) URL of the context the user originally created this workspace on.
|
|
26
|
+
* Especially it will not contain any modifiers or be of different scheme than HTTP(S).
|
|
27
|
+
*
|
|
28
|
+
* Use this function if you need to provided a _working_ URL to the original context.
|
|
29
|
+
* @param ws
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
function getNormalizedURL(ws) {
|
|
33
|
+
const normalized = normalize(ws);
|
|
34
|
+
if (!normalized) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
return new URL(normalized);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
console.error(`unable to parse URL from normalized contextURL: '${normalized}'`, err);
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
ContextURL.getNormalizedURL = getNormalizedURL;
|
|
46
|
+
function normalize(ws) {
|
|
47
|
+
if (!ws) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
if (ws.context.normalizedContextURL) {
|
|
51
|
+
return ws.context.normalizedContextURL;
|
|
52
|
+
}
|
|
53
|
+
// fallback: we do not yet set normalizedContextURL on all workspaces, yet, let alone older existing workspaces
|
|
54
|
+
let fallback = undefined;
|
|
55
|
+
try {
|
|
56
|
+
fallback = removePrefixes(ws.contextURL);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
console.error(`unable to remove prefixes from contextURL: '${ws.contextURL}'`, err);
|
|
60
|
+
}
|
|
61
|
+
return fallback;
|
|
62
|
+
}
|
|
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) {
|
|
70
|
+
if (contextUrl === undefined) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
const segments = contextUrl.split("/");
|
|
74
|
+
if (segments.length === 1) {
|
|
75
|
+
return segments[0]; // this might be something, we just try
|
|
76
|
+
}
|
|
77
|
+
const segmentsToURL = (offset) => {
|
|
78
|
+
let rest = segments.slice(offset).join("/");
|
|
79
|
+
if (/^git@[^:\/]+:/.test(rest)) {
|
|
80
|
+
rest = rest.replace(/^git@([^:\/]+):/, 'https://$1/');
|
|
81
|
+
}
|
|
82
|
+
if (!rest.startsWith("http")) {
|
|
83
|
+
rest = 'https://' + rest;
|
|
84
|
+
}
|
|
85
|
+
return rest;
|
|
86
|
+
};
|
|
87
|
+
const firstSegment = segments[0];
|
|
88
|
+
if (firstSegment === ContextURL.PREBUILD_PREFIX ||
|
|
89
|
+
firstSegment === ContextURL.INCREMENTAL_PREBUILD_PREFIX ||
|
|
90
|
+
firstSegment === ContextURL.IMAGEBUILD_PREFIX ||
|
|
91
|
+
firstSegment === ContextURL.SNAPSHOT_PREFIX ||
|
|
92
|
+
firstSegment.startsWith(ContextURL.REFERRER_PREFIX)) {
|
|
93
|
+
return segmentsToURL(1);
|
|
94
|
+
}
|
|
95
|
+
// check for env vars
|
|
96
|
+
if (firstSegment.indexOf("=") !== -1) {
|
|
97
|
+
return segmentsToURL(1);
|
|
98
|
+
}
|
|
99
|
+
return segmentsToURL(0);
|
|
100
|
+
}
|
|
101
|
+
})(ContextURL = exports.ContextURL || (exports.ContextURL = {}));
|
|
102
|
+
//# sourceMappingURL=context-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-url.js","sourceRoot":"","sources":["../src/context-url.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH;;;;;;;GAOG;AACH,IAAiB,UAAU,CA0F1B;AA1FD,WAAiB,UAAU;IACZ,sCAA2B,GAAG,sBAAsB,CAAC;IACrD,0BAAe,GAAG,UAAU,CAAC;IAC7B,4BAAiB,GAAG,YAAY,CAAC;IACjC,0BAAe,GAAG,UAAU,CAAC;IAC7B,0BAAe,GAAG,WAAW,CAAC;IAE3C;;;;;;;OAOG;IACH,SAAgB,gBAAgB,CAAC,EAAyD;QACxF,MAAM,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,EAAE;YACf,OAAO,SAAS,CAAC;SAClB;QAED,IAAI;YACF,OAAO,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;SAC5B;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,oDAAoD,UAAU,GAAG,EAAE,GAAG,CAAC,CAAC;SACvF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAZe,2BAAgB,mBAY/B,CAAA;IAED,SAAS,SAAS,CAAC,EAAyD;QAC1E,IAAI,CAAC,EAAE,EAAE;YACP,OAAO,SAAS,CAAC;SAClB;QACD,IAAI,EAAE,CAAC,OAAO,CAAC,oBAAoB,EAAE;YACnC,OAAO,EAAE,CAAC,OAAO,CAAC,oBAAoB,CAAC;SACxC;QAED,+GAA+G;QAC/G,IAAI,QAAQ,GAAuB,S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,CAAC,CAAC,CAAC,CAAC;SACzB;QAED,qBAAqB;QACrB,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;YACpC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;SACzB;QAED,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC,EA1FgB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QA0F1B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
export declare class ContextUrlTest {
|
|
7
|
+
parseContextUrl_withEnvVar(): void;
|
|
8
|
+
parseContextUrl_withEnvVar_withoutSchema(): void;
|
|
9
|
+
parseContextUrl_withEnvVar_sshUrl(): void;
|
|
10
|
+
parseContextUrl_withPrebuild(): void;
|
|
11
|
+
parseContextUrl_withPrebuild_withoutSchema(): void;
|
|
12
|
+
parseContextUrl_badUrl(): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=context-url.spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-url.spec.d.ts","sourceRoot":"","sources":["../src/context-url.spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,qBACa,cAAc;IAEV,0BAA0B;IAM1B,wCAAwC;IAMxC,iCAAiC;IAMjC,4BAA4B;IAM5B,0CAA0C;IAM1C,sBAAsB;CAItC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
4
|
+
* Licensed under the GNU Affero General Public License (AGPL).
|
|
5
|
+
* See License-AGPL.txt in the project root for license information.
|
|
6
|
+
*/
|
|
7
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
8
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
11
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12
|
+
};
|
|
13
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
14
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ContextUrlTest = void 0;
|
|
18
|
+
const chai = require("chai");
|
|
19
|
+
const mocha_typescript_1 = require("mocha-typescript");
|
|
20
|
+
const context_url_1 = require("./context-url");
|
|
21
|
+
const expect = chai.expect;
|
|
22
|
+
let ContextUrlTest = class ContextUrlTest {
|
|
23
|
+
parseContextUrl_withEnvVar() {
|
|
24
|
+
const actual = context_url_1.ContextURL.getNormalizedURL({ contextURL: "passedin=test%20value/https://github.com/gitpod-io/gitpod-test-repo", context: {} });
|
|
25
|
+
expect(actual === null || actual === void 0 ? void 0 : actual.host).to.equal("github.com");
|
|
26
|
+
expect(actual === null || actual === void 0 ? void 0 : actual.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
27
|
+
}
|
|
28
|
+
parseContextUrl_withEnvVar_withoutSchema() {
|
|
29
|
+
const actual = context_url_1.ContextURL.getNormalizedURL({ contextURL: "passedin=test%20value/github.com/gitpod-io/gitpod-test-repo", context: {} });
|
|
30
|
+
expect(actual === null || actual === void 0 ? void 0 : actual.host).to.equal("github.com");
|
|
31
|
+
expect(actual === null || actual === void 0 ? void 0 : actual.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
32
|
+
}
|
|
33
|
+
parseContextUrl_withEnvVar_sshUrl() {
|
|
34
|
+
const actual = context_url_1.ContextURL.getNormalizedURL({ contextURL: "passedin=test%20value/git@github.com:gitpod-io/gitpod-test-repo.git", context: {} });
|
|
35
|
+
expect(actual === null || actual === void 0 ? void 0 : actual.host).to.equal("github.com");
|
|
36
|
+
expect(actual === null || actual === void 0 ? void 0 : actual.pathname).to.equal("/gitpod-io/gitpod-test-repo.git");
|
|
37
|
+
}
|
|
38
|
+
parseContextUrl_withPrebuild() {
|
|
39
|
+
const actual = context_url_1.ContextURL.getNormalizedURL({ contextURL: "prebuild/https://github.com/gitpod-io/gitpod-test-repo", context: {} });
|
|
40
|
+
expect(actual === null || actual === void 0 ? void 0 : actual.host).to.equal("github.com");
|
|
41
|
+
expect(actual === null || actual === void 0 ? void 0 : actual.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
42
|
+
}
|
|
43
|
+
parseContextUrl_withPrebuild_withoutSchema() {
|
|
44
|
+
const actual = context_url_1.ContextURL.getNormalizedURL({ contextURL: "prebuild/github.com/gitpod-io/gitpod-test-repo", context: {} });
|
|
45
|
+
expect(actual === null || actual === void 0 ? void 0 : actual.host).to.equal("github.com");
|
|
46
|
+
expect(actual === null || actual === void 0 ? void 0 : actual.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
47
|
+
}
|
|
48
|
+
parseContextUrl_badUrl() {
|
|
49
|
+
const actual = context_url_1.ContextURL.getNormalizedURL({ contextURL: "[Object object]", context: {} });
|
|
50
|
+
expect(actual).to.be.undefined;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
__decorate([
|
|
54
|
+
mocha_typescript_1.test,
|
|
55
|
+
__metadata("design:type", Function),
|
|
56
|
+
__metadata("design:paramtypes", []),
|
|
57
|
+
__metadata("design:returntype", void 0)
|
|
58
|
+
], ContextUrlTest.prototype, "parseContextUrl_withEnvVar", null);
|
|
59
|
+
__decorate([
|
|
60
|
+
mocha_typescript_1.test,
|
|
61
|
+
__metadata("design:type", Function),
|
|
62
|
+
__metadata("design:paramtypes", []),
|
|
63
|
+
__metadata("design:returntype", void 0)
|
|
64
|
+
], ContextUrlTest.prototype, "parseContextUrl_withEnvVar_withoutSchema", null);
|
|
65
|
+
__decorate([
|
|
66
|
+
mocha_typescript_1.test,
|
|
67
|
+
__metadata("design:type", Function),
|
|
68
|
+
__metadata("design:paramtypes", []),
|
|
69
|
+
__metadata("design:returntype", void 0)
|
|
70
|
+
], ContextUrlTest.prototype, "parseContextUrl_withEnvVar_sshUrl", null);
|
|
71
|
+
__decorate([
|
|
72
|
+
mocha_typescript_1.test,
|
|
73
|
+
__metadata("design:type", Function),
|
|
74
|
+
__metadata("design:paramtypes", []),
|
|
75
|
+
__metadata("design:returntype", void 0)
|
|
76
|
+
], ContextUrlTest.prototype, "parseContextUrl_withPrebuild", null);
|
|
77
|
+
__decorate([
|
|
78
|
+
mocha_typescript_1.test,
|
|
79
|
+
__metadata("design:type", Function),
|
|
80
|
+
__metadata("design:paramtypes", []),
|
|
81
|
+
__metadata("design:returntype", void 0)
|
|
82
|
+
], ContextUrlTest.prototype, "parseContextUrl_withPrebuild_withoutSchema", null);
|
|
83
|
+
__decorate([
|
|
84
|
+
mocha_typescript_1.test,
|
|
85
|
+
__metadata("design:type", Function),
|
|
86
|
+
__metadata("design:paramtypes", []),
|
|
87
|
+
__metadata("design:returntype", void 0)
|
|
88
|
+
], ContextUrlTest.prototype, "parseContextUrl_badUrl", null);
|
|
89
|
+
ContextUrlTest = __decorate([
|
|
90
|
+
mocha_typescript_1.suite
|
|
91
|
+
], ContextUrlTest);
|
|
92
|
+
exports.ContextUrlTest = ContextUrlTest;
|
|
93
|
+
module.exports = new ContextUrlTest();
|
|
94
|
+
//# sourceMappingURL=context-url.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-url.spec.js","sourceRoot":"","sources":["../src/context-url.spec.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;AAEK;IAAL,uBAAI;;;;gFAIJ;AAEK;IAAL,uBAAI;;;;4DAGJ;AAnCQ,cAAc;IAD1B,wBAAK;GACO,cAAc,CAoC1B;AApCY,wCAAc;AAqC3B,MAAM,CAAC,OAAO,GAAG,IAAI,cAAc,EAAE,CAAA"}
|
package/lib/email-protocol.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
|
-
import { Without } from "./util/without";
|
|
7
6
|
export declare type EMailState = "scheduledInternal" | "scheduledSendgrid";
|
|
8
7
|
export interface EMailStatus {
|
|
9
8
|
/** The time the email entry was inserted into the DB */
|
|
@@ -45,6 +44,6 @@ export declare type EMail = {
|
|
|
45
44
|
params: EMailParameters;
|
|
46
45
|
} & EMailStatus;
|
|
47
46
|
export declare namespace EMail {
|
|
48
|
-
const create: (ts:
|
|
47
|
+
const create: (ts: Omit<EMail, 'uid'>) => EMail;
|
|
49
48
|
}
|
|
50
49
|
//# sourceMappingURL=email-protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-protocol.d.ts","sourceRoot":"","sources":["../src/email-protocol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"email-protocol.d.ts","sourceRoot":"","sources":["../src/email-protocol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,oBAAY,UAAU,GAAG,mBAAmB,GACtC,mBAAmB,CAAC;AAE1B,MAAM,WAAW,WAAW;IACxB,wDAAwD;IACxD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mEAAmE;IACnE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AACD,yBAAiB,WAAW,CAAC;IACzB,SAAgB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAKxD;CACJ;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC5B,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,aAAa,EAAE,MAAM,GAAG,YAAY,CAAC;IACrC,0BAA0B;IAC1B,cAAc,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IACvC,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,cAAc,EAAE,EAAE,CAAC;CACtB;AAED,oBAAY,KAAK,GAAG;IAChB,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,gBAAgB,EAAE,MAAM,CAAC;IACzB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,MAAM,EAAE,eAAe,CAAC;CAC3B,GAAG,WAAW,CAAC;AAEhB,yBAAiB,KAAK,CAAC;IACZ,MAAM,MAAM,OAAQ,KAAK,KAAK,EAAE,KAAK,CAAC,KAAG,KAI/C,CAAA;CACJ"}
|
package/lib/email-protocol.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.EMail = exports.EMailStatus = void 0;
|
|
9
|
-
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
10
10
|
var EMailStatus;
|
|
11
11
|
(function (EMailStatus) {
|
|
12
12
|
function getState(status) {
|
|
@@ -19,9 +19,9 @@ var EMailStatus;
|
|
|
19
19
|
})(EMailStatus = exports.EMailStatus || (exports.EMailStatus = {}));
|
|
20
20
|
var EMail;
|
|
21
21
|
(function (EMail) {
|
|
22
|
-
EMail.create =
|
|
23
|
-
|
|
24
|
-
withId.uid =
|
|
22
|
+
EMail.create = (ts) => {
|
|
23
|
+
const withId = ts;
|
|
24
|
+
withId.uid = (0, uuid_1.v4)();
|
|
25
25
|
return withId;
|
|
26
26
|
};
|
|
27
27
|
})(EMail = exports.EMail || (exports.EMail = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-protocol.js","sourceRoot":"","sources":["../src/email-protocol.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;
|
|
1
|
+
{"version":3,"file":"email-protocol.js","sourceRoot":"","sources":["../src/email-protocol.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,+BAAoC;AAapC,IAAiB,WAAW,CAO3B;AAPD,WAAiB,WAAW;IACxB,SAAgB,QAAQ,CAAC,MAAmB;QACxC,IAAI,MAAM,CAAC,qBAAqB,EAAE;YAC9B,OAAO,mBAAmB,CAAC;SAC9B;QACD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IALe,oBAAQ,WAKvB,CAAA;AACL,CAAC,EAPgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAO3B;AAiCD,IAAiB,KAAK,CAMrB;AAND,WAAiB,KAAK;IACL,YAAM,GAAG,CAAC,EAAsB,EAAS,EAAE;QACpD,MAAM,MAAM,GAAG,EAAW,CAAC;QAC3B,MAAM,CAAC,GAAG,GAAG,IAAA,SAAM,GAAE,CAAC;QACtB,OAAO,MAAM,CAAC;IAClB,CAAC,CAAA;AACL,CAAC,EANgB,KAAK,GAAL,aAAK,KAAL,aAAK,QAMrB"}
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.encryptionModule = void 0;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const key_provider_1 = require("./key-provider");
|
|
10
|
+
const encryption_engine_1 = require("./encryption-engine");
|
|
11
|
+
const encryption_service_1 = require("./encryption-service");
|
|
12
12
|
/**
|
|
13
13
|
* User have to provide a binding for KeyProviderConfig!!!
|
|
14
14
|
* Example:
|
|
@@ -19,9 +19,10 @@ var encryption_service_1 = require("./encryption-service");
|
|
|
19
19
|
* };
|
|
20
20
|
* }).inSingletonScope();
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
const encryptionModule = bind => {
|
|
23
23
|
bind(key_provider_1.KeyProvider).to(key_provider_1.KeyProviderImpl).inSingletonScope();
|
|
24
24
|
bind(encryption_engine_1.EncryptionEngine).to(encryption_engine_1.EncryptionEngineImpl).inSingletonScope();
|
|
25
25
|
bind(encryption_service_1.EncryptionService).to(encryption_service_1.EncryptionServiceImpl).inSingletonScope();
|
|
26
26
|
};
|
|
27
|
+
exports.encryptionModule = encryptionModule;
|
|
27
28
|
//# sourceMappingURL=container-module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-module.js","sourceRoot":"","sources":["../../src/encryption/container-module.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH
|
|
1
|
+
{"version":3,"file":"container-module.js","sourceRoot":"","sources":["../../src/encryption/container-module.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,iDAA8D;AAC9D,2DAA6E;AAC7E,6DAAgF;AAEhF;;;;;;;;;GASG;AACI,MAAM,gBAAgB,GAAuC,IAAI,CAAC,EAAE;IAEvE,IAAI,CAAC,0BAAW,CAAC,CAAC,EAAE,CAAC,8BAAe,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAEzD,IAAI,CAAC,oCAAgB,CAAC,CAAC,EAAE,CAAC,wCAAoB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACnE,IAAI,CAAC,sCAAiB,CAAC,CAAC,EAAE,CAAC,0CAAqB,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACzE,CAAC,CAAC;AANW,QAAA,gBAAgB,oBAM3B"}
|
|
@@ -12,8 +12,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.EncryptionEngineImpl = exports.EncryptionEngine = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const crypto = require("crypto");
|
|
16
|
+
const inversify_1 = require("inversify");
|
|
17
17
|
exports.EncryptionEngine = Symbol('EncryptionEngine');
|
|
18
18
|
/**
|
|
19
19
|
* For starters, let's use aes-cbc-256 with:
|
|
@@ -21,33 +21,32 @@ exports.EncryptionEngine = Symbol('EncryptionEngine');
|
|
|
21
21
|
* - no salt, as we pass in a real key (no salting needed to turn a password into a key)
|
|
22
22
|
* The implementation closely follows the exampes in https://nodejs.org/api/crypto.html.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
let EncryptionEngineImpl = class EncryptionEngineImpl {
|
|
25
|
+
constructor() {
|
|
26
26
|
this.algorithm = 'aes-256-cbc';
|
|
27
27
|
this.enc = 'base64';
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
encrypt(data, key) {
|
|
30
|
+
const iv = crypto.randomBytes(16);
|
|
31
|
+
const cipher = crypto.createCipheriv(this.algorithm, key, iv);
|
|
32
|
+
const encrypted = cipher.update(new Buffer(data, 'utf8'));
|
|
33
|
+
const finalEncrypted = Buffer.concat([encrypted, cipher.final()]);
|
|
34
34
|
return {
|
|
35
35
|
data: finalEncrypted.toString(this.enc),
|
|
36
36
|
keyParams: {
|
|
37
37
|
iv: iv.toString(this.enc)
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
}
|
|
41
|
+
decrypt(encryptedData, key) {
|
|
42
|
+
const decipher = crypto.createDecipheriv(this.algorithm, key, new Buffer(encryptedData.keyParams.iv, this.enc));
|
|
43
|
+
let decrypted = decipher.update(new Buffer(encryptedData.data, this.enc));
|
|
44
|
+
const finalDecrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
45
45
|
return finalDecrypted.toString('utf8');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}());
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
EncryptionEngineImpl = __decorate([
|
|
49
|
+
(0, inversify_1.injectable)()
|
|
50
|
+
], EncryptionEngineImpl);
|
|
52
51
|
exports.EncryptionEngineImpl = EncryptionEngineImpl;
|
|
53
52
|
//# sourceMappingURL=encryption-engine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption-engine.js","sourceRoot":"","sources":["../../src/encryption/encryption-engine.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;AAEH
|
|
1
|
+
{"version":3,"file":"encryption-engine.js","sourceRoot":"","sources":["../../src/encryption/encryption-engine.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;AAEH,iCAAiC;AACjC,yCAAuC;AAY1B,QAAA,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAS3D;;;;;GAKG;AAEH,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAAjC;QACa,cAAS,GAAG,aAAa,CAAC;QAC1B,QAAG,GAAG,QAAQ,CAAC;IAqB5B,CAAC;IAnBG,OAAO,CAAC,IAAY,EAAE,GAAW;QAC7B,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QAC9D,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAC1D,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAClE,OAAO;YACH,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;YACvC,SAAS,EAAE;gBACP,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;aAC5B;SACJ,CAAC;IACN,CAAC;IAED,OAAO,CAAC,aAA4B,EAAE,GAAW;QAC7C,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAChH,IAAI,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1E,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACpE,OAAO,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;CACJ,CAAA;AAvBY,oBAAoB;IAD/B,IAAA,sBAAU,GAAE;GACD,oBAAoB,CAuBhC;AAvBY,oDAAoB"}
|
|
@@ -15,45 +15,38 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.t = void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
const mocha_typescript_1 = require("mocha-typescript");
|
|
19
|
+
const chai = require("chai");
|
|
20
|
+
const path = require("path");
|
|
21
|
+
const fs = require("fs");
|
|
22
|
+
const encryption_engine_1 = require("./encryption-engine");
|
|
23
|
+
const expect = chai.expect;
|
|
24
|
+
let TestEncryptionEngineImpl = class TestEncryptionEngineImpl {
|
|
25
|
+
// Created with openssl rand -rand /dev/urandom -out key -base64 32
|
|
26
|
+
get testkey() {
|
|
27
|
+
const keyFilePath = path.resolve(__dirname, '../../test/fixtures/encryption/testkey');
|
|
28
|
+
const keyBuffer = fs.readFileSync(keyFilePath);
|
|
29
|
+
return keyBuffer.toString().trim();
|
|
26
30
|
}
|
|
27
|
-
Object.defineProperty(TestEncryptionEngineImpl.prototype, "testkey", {
|
|
28
|
-
// Created with openssl rand -rand /dev/urandom -out key -base64 32
|
|
29
|
-
get: function () {
|
|
30
|
-
var keyFilePath = path.resolve(__dirname, '../../test/fixtures/encryption/testkey');
|
|
31
|
-
var keyBuffer = fs.readFileSync(keyFilePath);
|
|
32
|
-
return keyBuffer.toString().trim();
|
|
33
|
-
},
|
|
34
|
-
enumerable: false,
|
|
35
|
-
configurable: true
|
|
36
|
-
});
|
|
37
31
|
;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
basicSymmetry() {
|
|
33
|
+
const plaintext = "12345678901234567890";
|
|
34
|
+
const key = new Buffer(this.testkey, 'base64');
|
|
35
|
+
const cut = new encryption_engine_1.EncryptionEngineImpl();
|
|
36
|
+
const encryptedData = cut.encrypt(plaintext, key);
|
|
43
37
|
expect(encryptedData).to.be.not.undefined;
|
|
44
|
-
|
|
38
|
+
const decryptedPlaintext = cut.decrypt(encryptedData, key);
|
|
45
39
|
expect(decryptedPlaintext).equals(plaintext);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}());
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
__decorate([
|
|
43
|
+
mocha_typescript_1.test,
|
|
44
|
+
__metadata("design:type", Function),
|
|
45
|
+
__metadata("design:paramtypes", []),
|
|
46
|
+
__metadata("design:returntype", void 0)
|
|
47
|
+
], TestEncryptionEngineImpl.prototype, "basicSymmetry", null);
|
|
48
|
+
TestEncryptionEngineImpl = __decorate([
|
|
49
|
+
mocha_typescript_1.suite
|
|
50
|
+
], TestEncryptionEngineImpl);
|
|
58
51
|
exports.t = new TestEncryptionEngineImpl();
|
|
59
52
|
//# sourceMappingURL=encryption-engine.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption-engine.spec.js","sourceRoot":"","sources":["../../src/encryption/encryption-engine.spec.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;AAEH,
|
|
1
|
+
{"version":3,"file":"encryption-engine.spec.js","sourceRoot":"","sources":["../../src/encryption/encryption-engine.spec.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;AAEH,uDAA+C;AAC/C,6BAA6B;AAC7B,6BAA6B;AAC7B,yBAAyB;AAEzB,2DAA2D;AAE3D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;AAEpB,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACjC,mEAAmE;IACnE,IAAc,OAAO;QACjB,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,wCAAwC,CAAC,CAAC;QACtF,MAAM,SAAS,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QAC/C,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;IACvC,CAAC;IAAA,CAAC;IAEI,aAAa;QACf,MAAM,SAAS,GAAG,sBAAsB,CAAC;QACzC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAE/C,MAAM,GAAG,GAAG,IAAI,wCAAoB,EAAE,CAAC;QACvC,MAAM,aAAa,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QAClD,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC;QAE1C,MAAM,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;QAC3D,MAAM,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjD,CAAC;CACJ,CAAA;AAXS;IAAL,uBAAI;;;;6DAUJ;AAlBQ,wBAAwB;IAApC,wBAAK;GAAO,wBAAwB,CAmBpC;AACY,QAAA,CAAC,GAAG,IAAI,wBAAwB,EAAE,CAAC"}
|
|
@@ -4,17 +4,6 @@
|
|
|
4
4
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
5
5
|
* See License-AGPL.txt in the project root for license information.
|
|
6
6
|
*/
|
|
7
|
-
var __assign = (this && this.__assign) || function () {
|
|
8
|
-
__assign = Object.assign || function(t) {
|
|
9
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
10
|
-
s = arguments[i];
|
|
11
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
12
|
-
t[p] = s[p];
|
|
13
|
-
}
|
|
14
|
-
return t;
|
|
15
|
-
};
|
|
16
|
-
return __assign.apply(this, arguments);
|
|
17
|
-
};
|
|
18
7
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
8
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
9
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -26,42 +15,39 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
26
15
|
};
|
|
27
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
17
|
exports.EncryptionServiceImpl = exports.EncryptionService = void 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
const inversify_1 = require("inversify");
|
|
19
|
+
const encryption_engine_1 = require("./encryption-engine");
|
|
20
|
+
const key_provider_1 = require("./key-provider");
|
|
32
21
|
exports.EncryptionService = Symbol('EncryptionService');
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
let EncryptionServiceImpl = class EncryptionServiceImpl {
|
|
23
|
+
encrypt(data) {
|
|
24
|
+
const dataStr = this.serialize(data);
|
|
25
|
+
const key = this.keyProvider.getPrimaryKey();
|
|
26
|
+
const encryptedData = this.engine.encrypt(dataStr, key.material);
|
|
27
|
+
return Object.assign(Object.assign({}, encryptedData), { keyMetadata: key.metadata });
|
|
35
28
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var encryptedData = this.engine.encrypt(dataStr, key.material);
|
|
40
|
-
return __assign(__assign({}, encryptedData), { keyMetadata: key.metadata });
|
|
41
|
-
};
|
|
42
|
-
EncryptionServiceImpl.prototype.decrypt = function (encrypted) {
|
|
43
|
-
var key = this.keyProvider.getKeyFor(encrypted.keyMetadata);
|
|
44
|
-
var serializedData = this.engine.decrypt(encrypted, key.material);
|
|
29
|
+
decrypt(encrypted) {
|
|
30
|
+
const key = this.keyProvider.getKeyFor(encrypted.keyMetadata);
|
|
31
|
+
const serializedData = this.engine.decrypt(encrypted, key.material);
|
|
45
32
|
return this.deserialize(serializedData);
|
|
46
|
-
}
|
|
47
|
-
|
|
33
|
+
}
|
|
34
|
+
serialize(data) {
|
|
48
35
|
return JSON.stringify(data);
|
|
49
|
-
}
|
|
50
|
-
|
|
36
|
+
}
|
|
37
|
+
deserialize(data) {
|
|
51
38
|
return JSON.parse(data);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}());
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, inversify_1.inject)(encryption_engine_1.EncryptionEngine),
|
|
43
|
+
__metadata("design:type", Object)
|
|
44
|
+
], EncryptionServiceImpl.prototype, "engine", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, inversify_1.inject)(key_provider_1.KeyProvider),
|
|
47
|
+
__metadata("design:type", Object)
|
|
48
|
+
], EncryptionServiceImpl.prototype, "keyProvider", void 0);
|
|
49
|
+
EncryptionServiceImpl = __decorate([
|
|
50
|
+
(0, inversify_1.injectable)()
|
|
51
|
+
], EncryptionServiceImpl);
|
|
66
52
|
exports.EncryptionServiceImpl = EncryptionServiceImpl;
|
|
67
53
|
//# sourceMappingURL=encryption-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption-service.js","sourceRoot":"","sources":["../../src/encryption/encryption-service.ts"],"names":[],"mappings":";AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"encryption-service.js","sourceRoot":"","sources":["../../src/encryption/encryption-service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;AAEH,yCAA+C;AAE/C,2DAAsE;AACtE,iDAA0D;AAO7C,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAO7D,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;IAI9B,OAAO,CAAI,IAAO;QACd,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC;QAE7C,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjE,uCACO,aAAa,KAChB,WAAW,EAAE,GAAG,CAAC,QAAQ,IAC3B;IACN,CAAC;IAED,OAAO,CAAI,SAAuB;QAC9B,MAAM,GAAG,GAAG,IAAI,CAAC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