-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmypatch.patch
170 lines (150 loc) · 5.3 KB
/
mypatch.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
From f5b8c40f0e6db9f38ddbe9a264cb6ddf3aeb0f45 Mon Sep 17 00:00:00 2001
From: Kjell Kvinge <[email protected]>
Date: Mon, 29 Jun 2020 20:48:31 +0200
Subject: [PATCH 1/3] show version
---
src/components/LayerUI.tsx | 1 +
src/css/styles.scss | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx
index 9f52b91..a986680 100644
--- a/src/components/LayerUI.tsx
+++ b/src/components/LayerUI.tsx
@@ -239,6 +239,7 @@ const LayerUI = ({
/>
</Island>
{renderEncryptedIcon()}
+ <div id="version">v:<span>{process.env.REACT_APP_VERSION}</span></div>
</Section>
</Stack.Col>
</div>
diff --git a/src/css/styles.scss b/src/css/styles.scss
index 7d76f6d..fa87d56 100644
--- a/src/css/styles.scss
+++ b/src/css/styles.scss
@@ -188,6 +188,14 @@ button,
}
}
+#version {
+ color: darkgray;
+ padding-top: 2em;
+ padding-left: 1em;
+ font-size: small;
+ font-family: monospace;
+}
+
.App-bottom-bar {
position: absolute;
top: 0;
--
2.17.1
From ec4a608dcc3b322e1e697f2ccda0f63891af4678 Mon Sep 17 00:00:00 2001
From: Kjell Kvinge <[email protected]>
Date: Tue, 30 Jun 2020 09:40:54 +0200
Subject: [PATCH 2/3] Configurable api endpoints
---
src/data/index.ts | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/data/index.ts b/src/data/index.ts
index f9c3bec..793d28e 100644
--- a/src/data/index.ts
+++ b/src/data/index.ts
@@ -24,12 +24,18 @@ export { loadFromBlob } from "./blob";
export { saveAsJSON, loadFromJSON } from "./json";
export { saveToLocalStorage } from "./localStorage";
-const BACKEND_GET = "https://json.excalidraw.com/api/v1/";
-
-const BACKEND_V2_POST = "https://json.excalidraw.com/api/v2/post/";
-const BACKEND_V2_GET = "https://json.excalidraw.com/api/v2/";
-
-export const SOCKET_SERVER = "https://excalidraw-socket.herokuapp.com";
+// get backend host from env. default excalidraw
+const HOST = process.env.REACT_APP_HOST
+ ? process.env.REACT_APP_HOST
+ : "https://json.excalidraw.com/";
+const BACKEND_GET = `${HOST}api/v1/`;
+
+const BACKEND_V2_POST = `${HOST}api/v2/post/`;
+const BACKEND_V2_GET = `${HOST}api/v2/`;
+
+export const SOCKET_SERVER = process.env.REACT_APP_SOCKET_SERVER
+ ? process.env.REACT_APP_SOCKET_SERVER
+ : "https://excalidraw-socket.herokuapp.com";
export type EncryptedData = {
data: ArrayBuffer;
--
2.17.1
From 512c071f5f323a3ab52511f93cda1207d74b61a5 Mon Sep 17 00:00:00 2001
From: Kjell Kvinge <[email protected]>
Date: Tue, 30 Jun 2020 09:42:30 +0200
Subject: [PATCH 3/3] Disable crypto
---
src/data/index.ts | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/data/index.ts b/src/data/index.ts
index 793d28e..4515393 100644
--- a/src/data/index.ts
+++ b/src/data/index.ts
@@ -86,7 +86,7 @@ const generateRandomID = async () => {
return Array.from(arr, byteToHex).join("");
};
-const generateEncryptionKey = async () => {
+/*const generateEncryptionKey = async () => {
const key = await window.crypto.subtle.generateKey(
{
name: "AES-GCM",
@@ -96,7 +96,7 @@ const generateEncryptionKey = async () => {
["encrypt", "decrypt"],
);
return (await window.crypto.subtle.exportKey("jwk", key)).k;
-};
+};*/
const createIV = () => {
const arr = new Uint8Array(12);
@@ -113,7 +113,7 @@ export const getCollaborationLinkData = (link: string) => {
export const generateCollaborationLink = async () => {
const id = await generateRandomID();
- const key = await generateEncryptionKey();
+ const key = "none"; //await generateEncryptionKey();
return `${window.location.origin}${window.location.pathname}#room=${id},${key}`;
};
@@ -190,7 +190,7 @@ export const exportToBackend = async (
const json = serializeAsJSON(elements, appState);
const encoded = new TextEncoder().encode(json);
- const key = await window.crypto.subtle.generateKey(
+ /* const key = await window.crypto.subtle.generateKey(
{
name: "AES-GCM",
length: 128,
@@ -214,18 +214,18 @@ export const exportToBackend = async (
// We use jwk encoding to be able to extract just the base64 encoded key.
// We will hardcode the rest of the attributes when importing back the key.
const exportedKey = await window.crypto.subtle.exportKey("jwk", key);
-
+*/
try {
const response = await fetch(BACKEND_V2_POST, {
method: "POST",
- body: encrypted,
+ body: encoded,
});
const json = await response.json();
if (json.id) {
const url = new URL(window.location.href);
// We need to store the key (and less importantly the id) as hash instead
// of queryParam in order to never send it to the server
- url.hash = `json=${json.id},${exportedKey.k!}`;
+ url.hash = `json=${json.id},none`;
const urlString = url.toString();
window.prompt(`🔒${t("alerts.uploadedSecurly")}`, urlString);
@@ -254,7 +254,7 @@ export const importFromBackend = async (
return restore(elements, appState, { scrollToContent: true });
}
let data;
- if (privateKey) {
+ if (privateKey && privateKey !== "none") {
const buffer = await response.arrayBuffer();
const key = await getImportedKey(privateKey, "decrypt");
const iv = new Uint8Array(12);
--
2.17.1