@cobinar/dalus 0.1.12 → 0.1.14
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/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite +0 -0
- package/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite-shm +0 -0
- package/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite-wal +0 -0
- package/.wrangler/state/v3/kv/eb6b3b49926b49238abd4bfdecfb6a3c/blobs/6287abebe4c3b42797fdac41fd6b010a6feabcfeff932186716b8142b119e4ed000001a0bb78c906 +1 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/8b00cc606ade48492895e688fffe18692fa15d7ac364a27ad78a05aad1f9dedb.sqlite +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/8b00cc606ade48492895e688fffe18692fa15d7ac364a27ad78a05aad1f9dedb.sqlite-shm +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/8b00cc606ade48492895e688fffe18692fa15d7ac364a27ad78a05aad1f9dedb.sqlite-wal +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/metadata.sqlite +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/metadata.sqlite-shm +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/metadata.sqlite-wal +0 -0
- package/package.json +1 -1
- package/patch_cli.py +69 -0
- package/src/commands/login.mjs +1 -1
- package/src/handlers/services.mjs +45 -45
- package/wrangler.jsonc +23 -0
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
https://dalus.cobinar.com
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/patch_cli.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
# Base directory to scan (defaults to where the script is executed)
|
|
5
|
+
TARGET_DIR = Path(".")
|
|
6
|
+
|
|
7
|
+
# Direct string replacements to perform across all .mjs files
|
|
8
|
+
REPLACEMENTS = [
|
|
9
|
+
("https://8bnk.dalus.cobinar.com", "https://dalus.cobinar.com"),
|
|
10
|
+
("http://8bnk.dalus.cobinar.com", "https://dalus.cobinar.com"),
|
|
11
|
+
("8bnk.dalus.cobinar.com", "dalus.cobinar.com"),
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
# Folders to ignore during search
|
|
15
|
+
EXCLUDED_FOLDERS = {"node_modules", ".git", "dist", "build"}
|
|
16
|
+
|
|
17
|
+
def patch_mjs_files(base_path: Path):
|
|
18
|
+
modified_files_count = 0
|
|
19
|
+
scanned_files_count = 0
|
|
20
|
+
|
|
21
|
+
print(f"🔍 Scanning '.mjs' files in: {base_path.resolve()}\n")
|
|
22
|
+
|
|
23
|
+
for file_path in base_path.rglob("*.mjs"):
|
|
24
|
+
# Skip excluded directories
|
|
25
|
+
if any(part in file_path.parts for part in EXCLUDED_FOLDERS):
|
|
26
|
+
continue
|
|
27
|
+
|
|
28
|
+
scanned_files_count += 1
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
content = file_path.read_text(encoding="utf-8")
|
|
32
|
+
except Exception as err:
|
|
33
|
+
print(f"⚠️ Skipping {file_path} (could not read file): {err}")
|
|
34
|
+
continue
|
|
35
|
+
|
|
36
|
+
new_content = content
|
|
37
|
+
changes = []
|
|
38
|
+
|
|
39
|
+
# Perform replacement line by line to track changes with line numbers
|
|
40
|
+
lines = content.splitlines()
|
|
41
|
+
for idx, line in enumerate(lines, start=1):
|
|
42
|
+
updated_line = line
|
|
43
|
+
for old_str, new_str in REPLACEMENTS:
|
|
44
|
+
if old_str in updated_line:
|
|
45
|
+
updated_line = updated_line.replace(old_str, new_str)
|
|
46
|
+
|
|
47
|
+
if updated_line != line:
|
|
48
|
+
changes.append((idx, line.strip(), updated_line.strip()))
|
|
49
|
+
|
|
50
|
+
# Perform global replacements on the full content
|
|
51
|
+
for old_str, new_str in REPLACEMENTS:
|
|
52
|
+
new_content = new_content.replace(old_str, new_str)
|
|
53
|
+
|
|
54
|
+
# Write changes back if content was modified
|
|
55
|
+
if new_content != content:
|
|
56
|
+
file_path.write_text(new_content, encoding="utf-8")
|
|
57
|
+
modified_files_count += 1
|
|
58
|
+
print(f"✅ Updated: {file_path}")
|
|
59
|
+
for line_num, old_line, new_line in changes:
|
|
60
|
+
print(f" Line {line_num}:")
|
|
61
|
+
print(f" - Old: {old_line}")
|
|
62
|
+
print(f" + New: {new_line}")
|
|
63
|
+
print()
|
|
64
|
+
|
|
65
|
+
print("=" * 60)
|
|
66
|
+
print(f"Finished! Scanned {scanned_files_count} file(s). Updated {modified_files_count} file(s).")
|
|
67
|
+
|
|
68
|
+
if __name__ == "__main__":
|
|
69
|
+
patch_mjs_files(TARGET_DIR)
|
package/src/commands/login.mjs
CHANGED
|
@@ -15,7 +15,7 @@ const SERVICES_ENDPOINT = 'https://cobinar.com/api/services';
|
|
|
15
15
|
// cobinar.com briefly unreachable) -- not the source of truth, just keeps
|
|
16
16
|
// `dalus login` from being completely dead during a transient outage of
|
|
17
17
|
// that one lookup. --web-base always wins over both.
|
|
18
|
-
const FALLBACK_DALUS_BASE = 'https://
|
|
18
|
+
const FALLBACK_DALUS_BASE = 'https://dalus.cobinar.com';
|
|
19
19
|
// cobinar-developers-worker — mints the actual bearer token dashboard-worker
|
|
20
20
|
// checks (a signed "workerToken"), from the one-time code dalus's own
|
|
21
21
|
// worker hands us. Not the same thing as dalus.cobinar.com itself or as
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
-
// src/handlers/services.js — where do Cobinar's other workers live right now
|
|
3
|
-
//
|
|
4
|
-
// One JSON endpoint, backed by KV instead of source code, specifically so
|
|
5
|
-
// a worker's public URL can change WITHOUT redeploying whatever reads it —
|
|
6
|
-
// today that's the dalus CLI (an npm package, the slowest thing in this
|
|
7
|
-
// whole system to get everyone to update), so it looks this up once at the
|
|
8
|
-
// start of `dalus login` instead of shipping a fixed URL in the package.
|
|
9
|
-
//
|
|
10
|
-
// GET /api/services
|
|
11
|
-
// → 200 { "dalus": "https://
|
|
12
|
-
//
|
|
13
|
-
// Values live in SSO_KV under a `service:<name>` key (the same shared
|
|
14
|
-
// namespace this worker already uses for the SSO code hand-off — reused
|
|
15
|
-
// here for a second, unrelated-but-convenient purpose: a permanent value
|
|
16
|
-
// instead of the hand-off's short-TTL ones, so give it its own key prefix
|
|
17
|
-
// to keep the two apart). Set/update one with:
|
|
18
|
-
//
|
|
19
|
-
// wrangler kv key put --binding=SSO_KV "service:dalus" "https://
|
|
20
|
-
//
|
|
21
|
-
// No redeploy of THIS worker needed either when a URL changes — that's the
|
|
22
|
-
// whole point. FALLBACK below is only so this endpoint returns something
|
|
23
|
-
// sane before that command has ever been run once.
|
|
24
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
25
|
-
|
|
26
|
-
const FALLBACK = {
|
|
27
|
-
dalus: 'https://dalus.cobinar.com',
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export async function handleServices(request, env) {
|
|
31
|
-
const headers = { 'Content-Type': 'application/json', 'Cache-Control': 'public, max-age=300' };
|
|
32
|
-
|
|
33
|
-
const result = {};
|
|
34
|
-
for (const name of Object.keys(FALLBACK)) {
|
|
35
|
-
let value = null;
|
|
36
|
-
try {
|
|
37
|
-
value = await env.SSO_KV.get(`service:${name}`);
|
|
38
|
-
} catch (err) {
|
|
39
|
-
console.error('[services] KV read failed for', name, ':', err?.message);
|
|
40
|
-
}
|
|
41
|
-
result[name] = value || FALLBACK[name];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return new Response(JSON.stringify(result), { status: 200, headers });
|
|
45
|
-
}
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// src/handlers/services.js — where do Cobinar's other workers live right now
|
|
3
|
+
//
|
|
4
|
+
// One JSON endpoint, backed by KV instead of source code, specifically so
|
|
5
|
+
// a worker's public URL can change WITHOUT redeploying whatever reads it —
|
|
6
|
+
// today that's the dalus CLI (an npm package, the slowest thing in this
|
|
7
|
+
// whole system to get everyone to update), so it looks this up once at the
|
|
8
|
+
// start of `dalus login` instead of shipping a fixed URL in the package.
|
|
9
|
+
//
|
|
10
|
+
// GET /api/services
|
|
11
|
+
// → 200 { "dalus": "https://dalus.cobinar.com" }
|
|
12
|
+
//
|
|
13
|
+
// Values live in SSO_KV under a `service:<name>` key (the same shared
|
|
14
|
+
// namespace this worker already uses for the SSO code hand-off — reused
|
|
15
|
+
// here for a second, unrelated-but-convenient purpose: a permanent value
|
|
16
|
+
// instead of the hand-off's short-TTL ones, so give it its own key prefix
|
|
17
|
+
// to keep the two apart). Set/update one with:
|
|
18
|
+
//
|
|
19
|
+
// wrangler kv key put --binding=SSO_KV "service:dalus" "https://dalus.cobinar.com"
|
|
20
|
+
//
|
|
21
|
+
// No redeploy of THIS worker needed either when a URL changes — that's the
|
|
22
|
+
// whole point. FALLBACK below is only so this endpoint returns something
|
|
23
|
+
// sane before that command has ever been run once.
|
|
24
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
25
|
+
|
|
26
|
+
const FALLBACK = {
|
|
27
|
+
dalus: 'https://dalus.cobinar.com',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export async function handleServices(request, env) {
|
|
31
|
+
const headers = { 'Content-Type': 'application/json', 'Cache-Control': 'public, max-age=300' };
|
|
32
|
+
|
|
33
|
+
const result = {};
|
|
34
|
+
for (const name of Object.keys(FALLBACK)) {
|
|
35
|
+
let value = null;
|
|
36
|
+
try {
|
|
37
|
+
value = await env.SSO_KV.get(`service:${name}`);
|
|
38
|
+
} catch (err) {
|
|
39
|
+
console.error('[services] KV read failed for', name, ':', err?.message);
|
|
40
|
+
}
|
|
41
|
+
result[name] = value || FALLBACK[name];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return new Response(JSON.stringify(result), { status: 200, headers });
|
|
45
|
+
}
|
package/wrangler.jsonc
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "node_modules/wrangler/config-schema.json",
|
|
3
|
+
"name": "dalus",
|
|
4
|
+
"main": "src/commands/index.js",
|
|
5
|
+
"compatibility_date": "2026-09-18",
|
|
6
|
+
"workers_dev": false,
|
|
7
|
+
"routes": [
|
|
8
|
+
"8bnk.dalus.cobinar.com"
|
|
9
|
+
],
|
|
10
|
+
"vars": {
|
|
11
|
+
"DALUS_AUTH_CLIENT_ID": "cs_7956a14267a74160fdb0b6fefcd4f2678d363d5e9011990c2cc94805bf366f4f"
|
|
12
|
+
},
|
|
13
|
+
"kv_namespaces": [
|
|
14
|
+
{
|
|
15
|
+
"binding": "SSO_KV",
|
|
16
|
+
"id": "eb6b3b49926b49238abd4bfdecfb6a3c",
|
|
17
|
+
"remote": true
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"observability": {
|
|
21
|
+
"enabled": true
|
|
22
|
+
}
|
|
23
|
+
}
|