@melaya/runner 1.1.63 → 1.1.64
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/dist/localVaultMirror.py +15 -1
- package/localVaultMirror.py +15 -1
- package/package.json +1 -1
package/dist/localVaultMirror.py
CHANGED
|
@@ -45,6 +45,20 @@ import urllib.request
|
|
|
45
45
|
from pathlib import Path
|
|
46
46
|
from typing import Any, Callable, Iterable
|
|
47
47
|
|
|
48
|
+
|
|
49
|
+
def _runner_user_agent() -> str:
|
|
50
|
+
# Cloudflare's browser integrity check refuses urllib's default
|
|
51
|
+
# "Python-urllib/x.y" agent (403, error 1010) before the request reaches
|
|
52
|
+
# Melaya, so every upload must name the runner.
|
|
53
|
+
try:
|
|
54
|
+
pkg = json.loads((Path(__file__).resolve().parent / "package.json").read_text(encoding="utf-8"))
|
|
55
|
+
return f"melaya-runner/{pkg.get('version') or 'dev'} (vault-mirror)"
|
|
56
|
+
except Exception:
|
|
57
|
+
return "melaya-runner (vault-mirror)"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
_USER_AGENT = _runner_user_agent()
|
|
61
|
+
|
|
48
62
|
CONFIG_FILES = (
|
|
49
63
|
"app.json", "daily-notes.json", "templates.json", "zk-prefixer.json", "bookmarks.json",
|
|
50
64
|
"types.json", "workspace.json", "workspaces.json", "core-plugins.json",
|
|
@@ -95,7 +109,7 @@ class HttpTransport:
|
|
|
95
109
|
url = f"{self.base}/{rel}"
|
|
96
110
|
if params:
|
|
97
111
|
url += "?" + urllib.parse.urlencode(params)
|
|
98
|
-
h = {"Authorization": f"Mirror {self._token}", **(headers or {})}
|
|
112
|
+
h = {"Authorization": f"Mirror {self._token}", "User-Agent": _USER_AGENT, **(headers or {})}
|
|
99
113
|
body = data
|
|
100
114
|
if json_body is not None:
|
|
101
115
|
body = json.dumps(json_body).encode("utf-8")
|
package/localVaultMirror.py
CHANGED
|
@@ -45,6 +45,20 @@ import urllib.request
|
|
|
45
45
|
from pathlib import Path
|
|
46
46
|
from typing import Any, Callable, Iterable
|
|
47
47
|
|
|
48
|
+
|
|
49
|
+
def _runner_user_agent() -> str:
|
|
50
|
+
# Cloudflare's browser integrity check refuses urllib's default
|
|
51
|
+
# "Python-urllib/x.y" agent (403, error 1010) before the request reaches
|
|
52
|
+
# Melaya, so every upload must name the runner.
|
|
53
|
+
try:
|
|
54
|
+
pkg = json.loads((Path(__file__).resolve().parent / "package.json").read_text(encoding="utf-8"))
|
|
55
|
+
return f"melaya-runner/{pkg.get('version') or 'dev'} (vault-mirror)"
|
|
56
|
+
except Exception:
|
|
57
|
+
return "melaya-runner (vault-mirror)"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
_USER_AGENT = _runner_user_agent()
|
|
61
|
+
|
|
48
62
|
CONFIG_FILES = (
|
|
49
63
|
"app.json", "daily-notes.json", "templates.json", "zk-prefixer.json", "bookmarks.json",
|
|
50
64
|
"types.json", "workspace.json", "workspaces.json", "core-plugins.json",
|
|
@@ -95,7 +109,7 @@ class HttpTransport:
|
|
|
95
109
|
url = f"{self.base}/{rel}"
|
|
96
110
|
if params:
|
|
97
111
|
url += "?" + urllib.parse.urlencode(params)
|
|
98
|
-
h = {"Authorization": f"Mirror {self._token}", **(headers or {})}
|
|
112
|
+
h = {"Authorization": f"Mirror {self._token}", "User-Agent": _USER_AGENT, **(headers or {})}
|
|
99
113
|
body = data
|
|
100
114
|
if json_body is not None:
|
|
101
115
|
body = json.dumps(json_body).encode("utf-8")
|