File size: 1,662 Bytes
312a238
 
f6ad66d
312a238
734f076
312a238
 
f6ad66d
 
 
 
 
 
 
734f076
312a238
734f076
 
312a238
734f076
312a238
734f076
312a238
 
 
 
 
 
 
 
 
 
 
 
 
 
734f076
f6ad66d
 
 
 
312a238
 
 
 
734f076
 
312a238
734f076
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
#!/usr/bin/env python3
import os
import re

print("🔧 [Patch] Applying safe LinkedIn Personal scopes and prompt patch...")

target_dirs = ["/app/apps", "/app/dist", "/app/libraries"]
patterns = [
    r",\s*['\"]r_basicprofile['\"]",
    r",\s*['\"]rw_organization_admin['\"]",
    r",\s*['\"]w_organization_social['\"]",
    r",\s*['\"]r_organization_social['\"]"
]

patched = 0

for target in target_dirs:
    if not os.path.exists(target):
        continue
    for root, _, files in os.walk(target):
        for f in files:
            if f.endswith((".js", ".mjs")):
                filepath = os.path.join(root, f)
                try:
                    with open(filepath, "r", encoding="utf-8", errors="ignore") as fh:
                        content = fh.read()
                except Exception:
                    continue

                modified = False

                # 1. Replace prompt=none with prompt=consent
                if "prompt=none" in content:
                    content = content.replace("prompt=none", "prompt=consent")
                    modified = True

                # 2. Trim organization scopes from LinkedIn scopes array
                if "r_organization_social" in content:
                    for p in patterns:
                        content = re.sub(p, "", content)
                    modified = True

                if modified:
                    with open(filepath, "w", encoding="utf-8") as fh:
                        fh.write(content)
                    patched += 1
                    print(f"   ✓ Patched {filepath}")

print(f"✅ [Patch] Completed successfully. Total files patched: {patched}")