-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfinal-id-analysis.ts
More file actions
213 lines (177 loc) · 6.86 KB
/
final-id-analysis.ts
File metadata and controls
213 lines (177 loc) · 6.86 KB
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/**
* Final Analysis of Superhuman Event ID Format
*
* Based on team ID pattern: team_11STeHt1wOE5UlznX9
* Event IDs should follow: event_ + similar base62 encoding
*/
import { connectToSuperhuman, disconnect } from "./src/superhuman-api";
const TEAM_ID = "team_11STeHt1wOE5UlznX9";
async function main() {
console.log("=== Superhuman Event ID Analysis ===\n");
// Analyze team ID pattern
const teamSuffix = TEAM_ID.replace("team_", "");
console.log("Team ID Analysis:");
console.log(` Full ID: ${TEAM_ID}`);
console.log(` Prefix: team_`);
console.log(` Suffix: ${teamSuffix}`);
console.log(` Suffix length: ${teamSuffix.length} characters`);
// Character analysis
const base62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const isBase62 = [...teamSuffix].every(c => base62.includes(c));
console.log(` Is base62: ${isBase62}`);
// Pattern: starts with "11" which could be a version or timestamp component
console.log(` First 2 chars: ${teamSuffix.substring(0, 2)}`);
console.log(` Remaining: ${teamSuffix.substring(2)} (${teamSuffix.substring(2).length} chars)\n`);
// Now connect to Superhuman and capture real IDs
console.log("Connecting to Superhuman for live ID capture...\n");
const conn = await connectToSuperhuman(9333);
if (!conn) {
console.error("Failed to connect to Superhuman");
console.log("\nBased on analysis, event IDs likely follow format:");
console.log(" event_ + 17-18 base62 characters");
console.log(" Example: event_11VNPdc4sKP2pEaKSz");
process.exit(1);
}
const { client, Runtime } = conn;
// Enable network monitoring
await conn.Network.enable();
console.log("Network monitoring enabled.");
console.log("Watching for ai.askAIProxy requests...\n");
const capturedRequests: any[] = [];
// Use Network.requestWillBeSent which gives us postData
conn.Network.requestWillBeSent((params: any) => {
const url = params.request.url;
const postData = params.request.postData;
if (url.includes("askAI") || url.includes("ai.")) {
console.log(`\n>>> Captured request to: ${url}`);
if (postData) {
try {
const body = JSON.parse(postData);
const captured: any = {
timestamp: new Date().toISOString(),
url
};
if (body.question_event_id) {
captured.question_event_id = body.question_event_id;
console.log(` question_event_id: ${body.question_event_id}`);
}
if (body.session_id) {
captured.session_id = body.session_id;
console.log(` session_id: ${body.session_id}`);
}
if (body.agent_session_id) {
captured.agent_session_id = body.agent_session_id;
console.log(` agent_session_id: ${body.agent_session_id}`);
}
capturedRequests.push(captured);
} catch (e) {
console.log(` Body (raw): ${postData?.slice(0, 200)}`);
}
}
}
});
// Also inject a fetch interceptor for redundancy
await Runtime.evaluate({
expression: `
(function() {
if (window.__fetchIntercepted) return;
window.__fetchIntercepted = true;
window.__capturedAIIds = [];
const originalFetch = window.fetch;
window.fetch = async function(...args) {
const [url, options] = args;
if (url && url.toString().includes('askAI')) {
try {
const body = options?.body ? JSON.parse(options.body) : null;
if (body?.question_event_id) {
window.__capturedAIIds.push({
timestamp: Date.now(),
question_event_id: body.question_event_id,
session_id: body.session_id
});
console.log('[CAPTURED] question_event_id:', body.question_event_id);
}
} catch {}
}
return originalFetch.apply(this, args);
};
})()
`
});
console.log("Fetch interceptor installed.");
console.log("\n=== NOW USE ASK AI IN SUPERHUMAN ===");
console.log("Press J to open Ask AI, then ask a question.");
console.log("Waiting 60 seconds for activity...\n");
// Poll for captured IDs
for (let i = 0; i < 12; i++) {
await new Promise(r => setTimeout(r, 5000));
const result = await Runtime.evaluate({
expression: `JSON.stringify(window.__capturedAIIds || [])`,
returnByValue: true
});
const ids = JSON.parse(result.result.value || "[]");
if (ids.length > 0) {
console.log(`\n*** CAPTURED ${ids.length} IDs ***\n`);
for (const id of ids) {
analyzeEventId(id.question_event_id);
}
break;
}
if (capturedRequests.length > 0) {
console.log(`\n*** CAPTURED ${capturedRequests.length} REQUESTS ***\n`);
for (const req of capturedRequests) {
if (req.question_event_id) {
analyzeEventId(req.question_event_id);
}
}
break;
}
process.stdout.write(".");
}
// Final summary
console.log("\n\n=== FINAL ANALYSIS ===\n");
if (capturedRequests.length === 0) {
console.log("No live requests captured.\n");
console.log("Based on team ID analysis and code inspection:\n");
} else {
console.log(`Captured ${capturedRequests.length} requests.\n`);
}
console.log("Event ID Format:");
console.log(" Prefix: 'event_'");
console.log(" Suffix: 17-18 base62 characters");
console.log(" Character set: 0-9, A-Z, a-z (62 characters)");
console.log(" Total length: 23-24 characters");
console.log("");
console.log("Session ID Format:");
console.log(" UUID v4 (standard 36-character hyphenated format)");
console.log(" Example: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx");
console.log("");
console.log("Team ID correlation:");
console.log(` Team ID: ${TEAM_ID}`);
console.log(` Team suffix: ${teamSuffix}`);
console.log(" Event IDs appear to use same base62 encoding");
console.log(" Possible shared timestamp or sequence component");
await disconnect(conn);
}
function analyzeEventId(eventId: string) {
if (!eventId) return;
console.log(`Event ID: ${eventId}`);
console.log(` Total length: ${eventId.length}`);
if (eventId.startsWith("event_")) {
const suffix = eventId.replace("event_", "");
console.log(` Prefix: event_`);
console.log(` Suffix: ${suffix}`);
console.log(` Suffix length: ${suffix.length}`);
// Character analysis
const base62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const isBase62 = [...suffix].every(c => base62.includes(c));
console.log(` Is base62: ${isBase62}`);
// Compare with team ID
const teamSuffix = TEAM_ID.replace("team_", "");
if (suffix.startsWith(teamSuffix.substring(0, 2))) {
console.log(` Shares prefix '${teamSuffix.substring(0, 2)}' with team ID`);
}
}
console.log("");
}
main().catch(console.error);