kalvium-worklog 1.4.2 → 1.4.3
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/capture-token.js +47 -27
- package/package.json +1 -1
package/dist/capture-token.js
CHANGED
|
@@ -61,8 +61,6 @@ async function captureTokenViaBrowser() {
|
|
|
61
61
|
console.log("\n ========================================");
|
|
62
62
|
console.log(" Browser-based token capture (no Playwright)");
|
|
63
63
|
console.log(" ========================================\n");
|
|
64
|
-
// The JS that runs on kalvium.community to extract and send the token
|
|
65
|
-
const bookmarkletJS = `javascript:void(function(){var t=localStorage.getItem('kc-token')||localStorage.getItem('keycloak-token');if(!t){for(var i=0;i<localStorage.length;i++){var k=localStorage.key(i),v=localStorage.getItem(k);if(v&&v.includes('refresh_token')){t=v;break}}}if(!t){for(var i=0;i<sessionStorage.length;i++){var k=sessionStorage.key(i),v=sessionStorage.getItem(k);if(v&&v.includes('refresh_token')){t=v;break}}}if(t){fetch('http://localhost:${PORT}/capture',{method:'POST',headers:{'Content-Type':'text/plain'},body:t}).then(function(r){if(r.ok)alert('Token sent! You can close this tab.');else alert('Failed: '+r.status)}).catch(function(e){alert('Error: '+e)})}else{alert('No token found in storage. Make sure you are logged in.')}})()`;
|
|
66
64
|
// Start local HTTP server
|
|
67
65
|
const tokenPromise = new Promise((resolve) => {
|
|
68
66
|
const server = createServer((req, res) => {
|
|
@@ -114,53 +112,75 @@ async function captureTokenViaBrowser() {
|
|
|
114
112
|
}
|
|
115
113
|
return;
|
|
116
114
|
}
|
|
117
|
-
// Main page — serves
|
|
115
|
+
// Main page — serves instructions + manual paste form
|
|
118
116
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
119
117
|
res.end(`<!DOCTYPE html>
|
|
120
118
|
<html>
|
|
121
119
|
<head>
|
|
122
120
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
123
|
-
<title>Kalvium Worklog —
|
|
121
|
+
<title>Kalvium Worklog — Login</title>
|
|
124
122
|
<style>
|
|
125
|
-
|
|
123
|
+
* { box-sizing: border-box; }
|
|
124
|
+
body { font-family: -apple-system, sans-serif; max-width: 600px; margin: 0 auto; padding: 16px; line-height: 1.6; color: #333; }
|
|
125
|
+
h2 { color: #1a73e8; }
|
|
126
126
|
.step { background: #f0f4ff; border-radius: 12px; padding: 16px; margin: 12px 0; }
|
|
127
|
-
.step h3 { margin-top: 0; }
|
|
128
|
-
.
|
|
129
|
-
.
|
|
127
|
+
.step h3 { margin-top: 0; color: #1a73e8; }
|
|
128
|
+
.btn { display: block; text-align: center; background: #4285f4; color: white; padding: 14px; border-radius: 8px; text-decoration: none; font-size: 18px; font-weight: bold; margin: 12px 0; }
|
|
129
|
+
.btn-green { background: #34a853; }
|
|
130
|
+
.btn:active { opacity: 0.8; }
|
|
131
|
+
.code-box { background: #1e1e1e; color: #0f0; padding: 12px; border-radius: 8px; font-family: monospace; font-size: 12px; word-break: break-all; white-space: pre-wrap; user-select: all; }
|
|
130
132
|
.note { background: #fff8e1; border-radius: 8px; padding: 12px; margin: 12px 0; font-size: 14px; }
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
.warn { background: #fce4ec; border-radius: 8px; padding: 12px; margin: 12px 0; font-size: 14px; }
|
|
134
|
+
textarea { width: 100%; height: 120px; font-family: monospace; font-size: 12px; border: 2px solid #4285f4; border-radius: 8px; padding: 8px; }
|
|
135
|
+
#result { font-weight: bold; padding: 12px; border-radius: 8px; margin: 8px 0; display: none; }
|
|
136
|
+
.success { background: #e8f5e9; color: #2e7d32; }
|
|
137
|
+
.error { background: #ffebee; color: #c62828; }
|
|
133
138
|
</style>
|
|
134
139
|
</head>
|
|
135
140
|
<body>
|
|
136
|
-
<h2>Kalvium Worklog —
|
|
141
|
+
<h2>Kalvium Worklog — Login</h2>
|
|
137
142
|
|
|
138
143
|
<div class="step">
|
|
139
|
-
<h3>Step 1:
|
|
140
|
-
<p>Tap
|
|
141
|
-
<a class="
|
|
144
|
+
<h3>Step 1: Log in to Kalvium</h3>
|
|
145
|
+
<p>Tap below, log in with Google (2FA if asked).</p>
|
|
146
|
+
<a class="btn btn-green" href="https://kalvium.community/internships" target="_blank">Open Kalvium →</a>
|
|
142
147
|
</div>
|
|
143
148
|
|
|
144
149
|
<div class="step">
|
|
145
|
-
<h3>Step 2:
|
|
146
|
-
<p
|
|
147
|
-
<
|
|
148
|
-
<
|
|
150
|
+
<h3>Step 2: Extract token</h3>
|
|
151
|
+
<p>After logging in, go to the Kalvium tab.<br>
|
|
152
|
+
<b>Type</b> this in the address bar (don't paste — type <code>javascript:</code> yourself, then paste the rest):</p>
|
|
153
|
+
<div class="code-box" id="jscode">javascript:void(function(){var t;for(var i=0;i<localStorage.length;i++){var k=localStorage.key(i),v=localStorage.getItem(i);if(v&&v.includes('refresh_token')){t=v}}if(!t){for(var i=0;i<sessionStorage.length;i++){var k=sessionStorage.key(i),v=sessionStorage.getItem(i);if(v&&v.includes('refresh_token')){t=v}}}if(t){fetch('http://localhost:${PORT}/capture',{method:'POST',body:t}).then(function(r){alert(r.ok?'Token sent! Go back to Termux':'Failed: '+r.status)}).catch(function(e){alert('Error: '+e)})}else{alert('No token found. Are you logged in?')}})()</div>
|
|
154
|
+
<p><small>👆 Long-press the code above → "Copy", then go to Kalvium tab, type <code>javascript:</code> in address bar, paste the rest after it, press Enter.</small></p>
|
|
149
155
|
</div>
|
|
150
156
|
|
|
151
|
-
<div class="
|
|
152
|
-
<
|
|
153
|
-
<p>Go back to the <b>Kalvium tab</b> (where you logged in).<br>
|
|
154
|
-
Open your <b>bookmarks menu</b> and tap <b>"📋 Capture Token"</b>.</p>
|
|
155
|
-
<p>You should see <b>"Token sent!"</b> — then come back to Termux.</p>
|
|
157
|
+
<div class="warn">
|
|
158
|
+
<b>Brave users:</b> Brave strips <code>javascript:</code> when pasting. You must <b>type</b> <code>javascript:</code> manually, then paste only the code after <code>javascript:</code>.
|
|
156
159
|
</div>
|
|
157
160
|
|
|
158
|
-
<div class="
|
|
159
|
-
<
|
|
160
|
-
<
|
|
161
|
-
<
|
|
161
|
+
<div class="step">
|
|
162
|
+
<h3>Or: Paste token manually</h3>
|
|
163
|
+
<p>If the above doesn't work, extract the token another way and paste it here:</p>
|
|
164
|
+
<textarea id="manualToken" placeholder='Paste token JSON here (starts with {"access_token"...'></textarea>
|
|
165
|
+
<button class="btn" onclick="sendManual()">Send Token</button>
|
|
166
|
+
<div id="result"></div>
|
|
162
167
|
</div>
|
|
163
168
|
|
|
169
|
+
<script>
|
|
170
|
+
function sendManual() {
|
|
171
|
+
var val = document.getElementById('manualToken').value.trim();
|
|
172
|
+
var result = document.getElementById('result');
|
|
173
|
+
result.style.display = 'block';
|
|
174
|
+
if (!val) { result.className = 'error'; result.textContent = 'Paste token JSON first'; return; }
|
|
175
|
+
fetch('http://localhost:${PORT}/capture', { method: 'POST', body: val })
|
|
176
|
+
.then(function(r) {
|
|
177
|
+
if (r.ok) { result.className = 'success'; result.textContent = '✓ Token sent! Go back to Termux.'; }
|
|
178
|
+
else { result.className = 'error'; result.textContent = 'Failed: ' + r.status; }
|
|
179
|
+
})
|
|
180
|
+
.catch(function(e) { result.className = 'error'; result.textContent = 'Error: ' + e; });
|
|
181
|
+
}
|
|
182
|
+
</script>
|
|
183
|
+
|
|
164
184
|
</body>
|
|
165
185
|
</html>`);
|
|
166
186
|
});
|