@kamilio/wire 0.1.55 → 0.1.56
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/adapters/codesignal.d.ts +10 -0
- package/dist/adapters/codesignal.d.ts.map +1 -0
- package/dist/adapters/codesignal.js +165 -0
- package/dist/adapters/codesignal.js.map +1 -0
- package/dist/adapters/root.d.ts.map +1 -1
- package/dist/adapters/root.js +5 -4
- package/dist/adapters/root.js.map +1 -1
- package/dist/auth.d.ts +2 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +4 -2
- package/dist/auth.js.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/executable.d.ts.map +1 -1
- package/dist/executable.js +2 -1
- package/dist/executable.js.map +1 -1
- package/node_modules/wire-core/dist/runtime/cookies.js +1 -1
- package/node_modules/wire-core/dist/runtime/cookies.js.map +1 -1
- package/node_modules/wire-core/src/runtime/cookies.ts +1 -1
- package/package.json +1 -1
- package/src/adapters/codesignal.ts +244 -0
- package/src/adapters/root.ts +5 -4
- package/src/auth.ts +6 -3
- package/src/cli.ts +2 -2
- package/src/executable.ts +2 -1
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { stripVTControlCharacters } from "node:util";
|
|
2
|
+
import type { FetchedDocument, RuntimeCapabilities } from "wire-core";
|
|
3
|
+
|
|
4
|
+
const loginRequired =
|
|
5
|
+
"codesignal cookie authentication is missing or expired. Run `wire codesignal login` once; other commands reuse saved cookies.";
|
|
6
|
+
|
|
7
|
+
type Frame = {
|
|
8
|
+
msg: string;
|
|
9
|
+
id?: string;
|
|
10
|
+
subs?: string[];
|
|
11
|
+
collection?: string;
|
|
12
|
+
fields?: { candidateId?: string };
|
|
13
|
+
error?: { reason: string };
|
|
14
|
+
result?: unknown;
|
|
15
|
+
};
|
|
16
|
+
type State = {
|
|
17
|
+
sources?: {
|
|
18
|
+
path: string;
|
|
19
|
+
source: string;
|
|
20
|
+
isHidden?: boolean;
|
|
21
|
+
excluded?: boolean;
|
|
22
|
+
}[];
|
|
23
|
+
executionEnvironment?: string;
|
|
24
|
+
};
|
|
25
|
+
type Solution = {
|
|
26
|
+
taskDoc: { _id: string; name: string };
|
|
27
|
+
solutions: { finalState?: State; submission?: State };
|
|
28
|
+
levelId?: string;
|
|
29
|
+
};
|
|
30
|
+
type RecordingEvent = {
|
|
31
|
+
action: string;
|
|
32
|
+
id: string;
|
|
33
|
+
command: string;
|
|
34
|
+
terminal?: { terminalContents: Record<string, string> };
|
|
35
|
+
testResults: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
async function session<T>(
|
|
39
|
+
token: string,
|
|
40
|
+
read: (
|
|
41
|
+
user: string,
|
|
42
|
+
method: <R>(name: string, ...params: unknown[]) => Promise<R>,
|
|
43
|
+
interview: (id: string) => Promise<string | undefined>,
|
|
44
|
+
) => Promise<T>,
|
|
45
|
+
): Promise<T | null> {
|
|
46
|
+
const socket = new WebSocket("wss://app.codesignal.com/websocket");
|
|
47
|
+
let sequence = 0;
|
|
48
|
+
const send = (value: object) => socket.send(JSON.stringify(value));
|
|
49
|
+
const exchange = <R>(
|
|
50
|
+
start: object,
|
|
51
|
+
accept: (frame: Frame) => { value: R } | undefined,
|
|
52
|
+
) =>
|
|
53
|
+
new Promise<R>((resolve, reject) => {
|
|
54
|
+
const listeners = new AbortController();
|
|
55
|
+
const finish = () => {
|
|
56
|
+
clearTimeout(timer);
|
|
57
|
+
listeners.abort();
|
|
58
|
+
};
|
|
59
|
+
const fail = () => {
|
|
60
|
+
finish();
|
|
61
|
+
reject(new Error("CodeSignal connection interrupted."));
|
|
62
|
+
};
|
|
63
|
+
const timer = setTimeout(fail, 30000);
|
|
64
|
+
const options = { signal: listeners.signal };
|
|
65
|
+
socket.addEventListener("error", fail, options);
|
|
66
|
+
socket.addEventListener("close", fail, options);
|
|
67
|
+
socket.addEventListener(
|
|
68
|
+
"message",
|
|
69
|
+
(event) => {
|
|
70
|
+
try {
|
|
71
|
+
const frame = JSON.parse(String(event.data)) as Frame;
|
|
72
|
+
if (frame.msg === "ping") {
|
|
73
|
+
send({ msg: "pong", id: frame.id });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const result = accept(frame);
|
|
77
|
+
if (result) {
|
|
78
|
+
finish();
|
|
79
|
+
resolve(result.value);
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
finish();
|
|
83
|
+
reject(error);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
options,
|
|
87
|
+
);
|
|
88
|
+
if (socket.readyState === WebSocket.CONNECTING)
|
|
89
|
+
socket.addEventListener("open", () => send(start), options);
|
|
90
|
+
else send(start);
|
|
91
|
+
});
|
|
92
|
+
const call = (name: string, params: unknown[]) => {
|
|
93
|
+
const id = String(++sequence);
|
|
94
|
+
return exchange({ msg: "method", method: name, params, id }, (f) =>
|
|
95
|
+
f.msg === "result" && f.id === id ? { value: f } : undefined,
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
try {
|
|
99
|
+
await exchange({ msg: "connect", version: "1", support: ["1"] }, (f) =>
|
|
100
|
+
f.msg === "connected" ? { value: true } : undefined,
|
|
101
|
+
);
|
|
102
|
+
const login = await call("login", [{ resume: token }]);
|
|
103
|
+
if (login.error) return null;
|
|
104
|
+
return await read(
|
|
105
|
+
(login.result as { id: string }).id,
|
|
106
|
+
async <R>(name: string, ...params: unknown[]) => {
|
|
107
|
+
const result = await call(name, params);
|
|
108
|
+
if (result.error) throw new Error("CodeSignal: " + result.error.reason);
|
|
109
|
+
return result.result as R;
|
|
110
|
+
},
|
|
111
|
+
async (interviewId) => {
|
|
112
|
+
let candidate: string | undefined;
|
|
113
|
+
for (const name of [
|
|
114
|
+
"liveInterviews.byId",
|
|
115
|
+
"liveInterviews.finished.byId",
|
|
116
|
+
]) {
|
|
117
|
+
const id = String(++sequence);
|
|
118
|
+
await exchange(
|
|
119
|
+
{ msg: "sub", name, params: [interviewId], id },
|
|
120
|
+
(f) => {
|
|
121
|
+
if (
|
|
122
|
+
f.msg === "added" &&
|
|
123
|
+
f.collection === "liveInterviews" &&
|
|
124
|
+
f.id === interviewId
|
|
125
|
+
)
|
|
126
|
+
candidate = f.fields?.candidateId;
|
|
127
|
+
if (f.msg === "nosub" && f.id === id)
|
|
128
|
+
throw new Error("CodeSignal: " + f.error?.reason);
|
|
129
|
+
return f.msg === "ready" && f.subs?.includes(id)
|
|
130
|
+
? { value: true }
|
|
131
|
+
: undefined;
|
|
132
|
+
},
|
|
133
|
+
);
|
|
134
|
+
if (candidate) break;
|
|
135
|
+
}
|
|
136
|
+
return candidate;
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
} finally {
|
|
140
|
+
socket.close();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export const verifyCodeSignal = (token: string) =>
|
|
145
|
+
session(token, async (user_id) => ({
|
|
146
|
+
service: "codesignal" as const,
|
|
147
|
+
identity: { user_id },
|
|
148
|
+
}));
|
|
149
|
+
|
|
150
|
+
function block(value: string) {
|
|
151
|
+
const fence = "`".repeat(
|
|
152
|
+
Math.max(3, ...Array.from(value.matchAll(/`+/g), (m) => m[0].length + 1)),
|
|
153
|
+
);
|
|
154
|
+
return fence + "\n" + value + (value.endsWith("\n") ? "" : "\n") + fence;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function output(events: RecordingEvent[]) {
|
|
158
|
+
let terminals: Record<string, string> = {};
|
|
159
|
+
const runs: string[] = [];
|
|
160
|
+
for (const e of events) {
|
|
161
|
+
if (e.action === "setState" && e.terminal)
|
|
162
|
+
terminals = { ...e.terminal.terminalContents };
|
|
163
|
+
if (e.action === "terminalCreate" || e.action === "terminalReset")
|
|
164
|
+
terminals[e.id] = "";
|
|
165
|
+
if (e.action === "terminalDelete") delete terminals[e.id];
|
|
166
|
+
if (e.action === "terminalWrite")
|
|
167
|
+
terminals[e.id] = (terminals[e.id] ?? "") + e.command;
|
|
168
|
+
if (e.action === "runResult" && e.testResults) {
|
|
169
|
+
const { compilationLog, output } = JSON.parse(e.testResults);
|
|
170
|
+
runs.push(
|
|
171
|
+
...[compilationLog, output].filter(
|
|
172
|
+
(v): v is string => typeof v === "string" && v.length > 0,
|
|
173
|
+
),
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const clean = (v: string) =>
|
|
178
|
+
stripVTControlCharacters(v)
|
|
179
|
+
.replace(/\r\n/g, "\n")
|
|
180
|
+
.replace(/[^\n]*\r/g, "")
|
|
181
|
+
.replace(/[\x00-\x08\x0b-\x1f\x7f]/g, "");
|
|
182
|
+
return [
|
|
183
|
+
...Object.entries(terminals).map(
|
|
184
|
+
([id, v]) => "### Terminal " + id + "\n\n" + block(clean(v)),
|
|
185
|
+
),
|
|
186
|
+
...runs.map((v) => "### Run output\n\n" + block(clean(v))),
|
|
187
|
+
];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function codeSignalInterviewId(url: string) {
|
|
191
|
+
return /^https:\/\/app\.codesignal\.com\/live-interview\/([a-zA-Z0-9]+)\/?(?:[?#].*)?$/.exec(
|
|
192
|
+
url,
|
|
193
|
+
)?.[1];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export async function previewCodeSignal(
|
|
197
|
+
runtime: RuntimeCapabilities,
|
|
198
|
+
id: string,
|
|
199
|
+
): Promise<FetchedDocument> {
|
|
200
|
+
const { token } = await runtime.cookies.metadata("codesignal");
|
|
201
|
+
if (!token) throw new Error(loginRequired);
|
|
202
|
+
const result = await session(token, async (user, method, interview) => {
|
|
203
|
+
const replayUser = await interview(id);
|
|
204
|
+
const questions = await method<
|
|
205
|
+
(Solution | { type: "progressive"; taskLevels: Solution[] })[]
|
|
206
|
+
>("liveInterviewService.getSolutions", id);
|
|
207
|
+
const title = "CodeSignal interview " + id;
|
|
208
|
+
const parts = ["# " + title];
|
|
209
|
+
for (const question of questions) {
|
|
210
|
+
for (const solution of "taskLevels" in question
|
|
211
|
+
? question.taskLevels
|
|
212
|
+
: [question]) {
|
|
213
|
+
const state =
|
|
214
|
+
solution.solutions.finalState ?? solution.solutions.submission;
|
|
215
|
+
parts.push("## " + solution.taskDoc.name);
|
|
216
|
+
for (const file of state?.sources ?? [])
|
|
217
|
+
if (!file.isHidden && !file.excluded)
|
|
218
|
+
parts.push("### " + file.path, block(file.source));
|
|
219
|
+
const data = await method<{
|
|
220
|
+
recording: { events: RecordingEvent[] } | null;
|
|
221
|
+
} | null>("taskRecordingService.getRecording", {
|
|
222
|
+
taskId: solution.taskDoc._id,
|
|
223
|
+
replayUserId: replayUser ?? user,
|
|
224
|
+
context: { mode: "live-interview", liveInterviewId: id, role: null },
|
|
225
|
+
taskLevelId: solution.levelId ?? null,
|
|
226
|
+
executionEnvironment: state?.executionEnvironment,
|
|
227
|
+
clientUserId: user,
|
|
228
|
+
});
|
|
229
|
+
const terminal = output(data?.recording?.events ?? []);
|
|
230
|
+
parts.push(
|
|
231
|
+
...(terminal.length ? terminal : ["No recorded terminal output."]),
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (!questions.length) parts.push("No saved solutions.");
|
|
236
|
+
return {
|
|
237
|
+
title,
|
|
238
|
+
markdown: parts.join("\n\n") + "\n",
|
|
239
|
+
data: { url: "https://app.codesignal.com/live-interview/" + id },
|
|
240
|
+
};
|
|
241
|
+
});
|
|
242
|
+
if (!result) throw new Error(loginRequired);
|
|
243
|
+
return result;
|
|
244
|
+
}
|
package/src/adapters/root.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type WireRoot = Group;
|
|
|
12
12
|
export type TextInputReader = () => Promise<string>;
|
|
13
13
|
export type WireRootOptions = Readonly<{ allowPaste: boolean; ashby?: (action: string, arg?: string) => Promise<string>; previewDrive?: (url: string) => Promise<string>; scrapeDrive?: (url?: string, deleteVerifiedPdfs?: boolean, deleteVerifiedDocx?: boolean) => Promise<string>; calendarAgenda?: (date?: string, calendarId?: string) => ReturnType<typeof readAgenda>; latticeSync?: (url: string | undefined, file?: string) => Promise<string>; latticeRequests?: (url: string) => Promise<string>; latticeTemplate?: (url: string) => Promise<string>; latticeFill?: (url: string, file: string) => Promise<string>; scrapeZoom?: () => ReturnType<typeof zoomProvider.scrape> }>;
|
|
14
14
|
|
|
15
|
-
const authServices = ["ashby", "asana", "chatgpt", "gmail", "google-docs", "notion", "slack", "zoom"] as const;
|
|
15
|
+
const authServices = ["ashby", "asana", "chatgpt", "codesignal", "gmail", "google-docs", "notion", "slack", "zoom"] as const;
|
|
16
16
|
const removedCliCommandNames = Object.freeze({
|
|
17
17
|
create: "Use `wire attach <url>` or `wire <url>`.",
|
|
18
18
|
fetch: "Use `wire download <url>`.",
|
|
@@ -207,7 +207,7 @@ function wireUserErrorMessage(message: string): boolean {
|
|
|
207
207
|
|| /^Resource (path |identifier |URL )?not found: /.test(message)
|
|
208
208
|
|| /^Ambiguous resource path /.test(message)
|
|
209
209
|
|| /^Login not saved$/.test(message)
|
|
210
|
-
|| /authentication (is missing|is missing or expired|failed|expired).*Run `wire (ashby|asana|chatgpt|gmail|google-docs|notion|slack|zoom) login`/i.test(message)
|
|
210
|
+
|| /authentication (is missing|is missing or expired|failed|expired).*Run `wire (ashby|asana|chatgpt|codesignal|gmail|google-docs|notion|slack|zoom) login`/i.test(message)
|
|
211
211
|
|| /^Asana API /.test(message)
|
|
212
212
|
|| /^(GET|POST|PUT|DELETE) \/.* failed: \d+ /.test(message)
|
|
213
213
|
|| /^(Invalid Asana project heading|Asana section appears|Asana milestone appears|Asana task appears|Asana subtask appears|Unsupported Asana Markdown|Duplicate Asana identity|Missing Asana project heading|Asana project identity changed|Unknown Asana identity|Conflicting Asana edits)/.test(message)
|
|
@@ -249,7 +249,7 @@ function wireUserErrorDisplayMessage(message: string): string {
|
|
|
249
249
|
if (unsupportedSource !== null) return `unsupported source\nurl: ${lineText(unsupportedSource[1]!)}\nsupported: Asana, ChatGPT, Gmail, Google Docs/Sheets/Slides/Forms, Notion, Slack, Zoom`;
|
|
250
250
|
const existingWorkspace = /^Wire workspace already initialized with (sqlite|files) registry at ([\s\S]+)\. Existing registries are not overwritten\.$/.exec(message);
|
|
251
251
|
if (existingWorkspace !== null) return `workspace already initialized\nbackend: ${existingWorkspace[1]!}\nregistry: ${lineText(existingWorkspace[2]!)}\nkept: existing registry`;
|
|
252
|
-
const authentication = /authentication (is missing or expired|is missing|failed|expired).*Run `wire (ashby|asana|chatgpt|gmail|google-docs|notion|slack|zoom) login`/i.exec(message);
|
|
252
|
+
const authentication = /authentication (is missing or expired|is missing|failed|expired).*Run `wire (ashby|asana|chatgpt|codesignal|gmail|google-docs|notion|slack|zoom) login`/i.exec(message);
|
|
253
253
|
if (authentication !== null) return `login required\nservice: ${serviceTitle(authentication[2] as AuthService)}\nrun: wire ${authentication[2]} login`;
|
|
254
254
|
const asanaApi = /^Asana API ([^\s]+) failed: HTTP (\d+)(?: ([\s\S]+))?$/.exec(message);
|
|
255
255
|
if (asanaApi !== null) return `api failed\nservice: Asana\nrequest: ${lineText(asanaApi[1]!)}\nstatus: HTTP ${asanaApi[2]!}${asanaApi[3] === undefined ? "" : `\ndetail: ${lineText(asanaApi[3]!)}`}`;
|
|
@@ -351,6 +351,7 @@ function serviceTitle(service: AuthService): string {
|
|
|
351
351
|
ashby: "Ashby",
|
|
352
352
|
asana: "Asana",
|
|
353
353
|
chatgpt: "ChatGPT",
|
|
354
|
+
codesignal: "CodeSignal",
|
|
354
355
|
gmail: "Gmail",
|
|
355
356
|
"google-docs": "Google Docs/Sheets/Slides",
|
|
356
357
|
notion: "Notion",
|
|
@@ -414,7 +415,7 @@ export const wirePresentation: WirePresentation = Object.freeze({
|
|
|
414
415
|
function authGroup(service: AuthService, description: string, loginDescription: string, auth: Auth, readInput: TextInputReader | undefined, options: WireRootOptions): Group {
|
|
415
416
|
const login = async (paste: boolean | undefined) => {
|
|
416
417
|
if (paste === true && !options.allowPaste) throw new UserError("Cookie paste is CLI-only.");
|
|
417
|
-
return paste === true ? auth.pasteCookies(service, await readInput!()) : service === "ashby" ? auth.extractAshby() : service === "asana" ? auth.extractAsana() : service === "chatgpt" ? auth.extractChatgpt() : service === "gmail" ? auth.extractGmail() : service === "google-docs" ? auth.extractGoogleDocs() : service === "notion" ? auth.extractNotion() : service === "slack" ? auth.extractSlack() : auth.extractZoom();
|
|
418
|
+
return paste === true ? auth.pasteCookies(service, await readInput!()) : service === "ashby" ? auth.extractAshby() : service === "asana" ? auth.extractAsana() : service === "chatgpt" ? auth.extractChatgpt() : service === "codesignal" ? auth.extractCodeSignal() : service === "gmail" ? auth.extractGmail() : service === "google-docs" ? auth.extractGoogleDocs() : service === "notion" ? auth.extractNotion() : service === "slack" ? auth.extractSlack() : auth.extractZoom();
|
|
418
419
|
};
|
|
419
420
|
const title = serviceTitle(service);
|
|
420
421
|
return defineGroup({ name: service, description, children: [
|
package/src/auth.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { parsePastedCookieMetadata, parsePastedCookies, type ChromeCookieExtraction, type ChromeCookieResult, type Cookie, type NodeEnvironment, type RuntimeCapabilities } from "wire-core";
|
|
2
2
|
|
|
3
|
+
import { verifyCodeSignal } from "./adapters/codesignal.js";
|
|
3
4
|
import { ashbySession } from "./adapters/ashby.js";
|
|
4
5
|
|
|
5
|
-
export type AuthService = "ashby" | "asana" | "chatgpt" | "gmail" | "google-docs" | "notion" | "slack" | "zoom";
|
|
6
|
+
export type AuthService = "ashby" | "asana" | "chatgpt" | "codesignal" | "gmail" | "google-docs" | "notion" | "slack" | "zoom";
|
|
6
7
|
export type CookieAuthService = AuthService;
|
|
7
8
|
|
|
8
9
|
export interface AuthResult {
|
|
@@ -232,6 +233,7 @@ export interface Auth {
|
|
|
232
233
|
readonly extractAshby: () => Promise<AuthResult>;
|
|
233
234
|
readonly extractAsana: () => Promise<AuthResult>;
|
|
234
235
|
readonly extractChatgpt: () => Promise<AuthResult>;
|
|
236
|
+
readonly extractCodeSignal: () => Promise<AuthResult>;
|
|
235
237
|
readonly extractGmail: () => Promise<AuthResult>;
|
|
236
238
|
readonly extractGoogleDocs: () => Promise<AuthResult>;
|
|
237
239
|
readonly extractNotion: () => Promise<AuthResult>;
|
|
@@ -242,8 +244,8 @@ export interface Auth {
|
|
|
242
244
|
export type CookieExtractor = (environment: NodeEnvironment, extraction: ChromeCookieExtraction) => Promise<ChromeCookieResult>;
|
|
243
245
|
|
|
244
246
|
export function composeAuth(runtime: RuntimeCapabilities, environment: NodeEnvironment, extractCookies: CookieExtractor): Auth {
|
|
245
|
-
const cookieDomains: Readonly<Record<AuthService, string>> = Object.freeze({ ashby: ".ashbyhq.com", asana: ".asana.com", chatgpt: ".chatgpt.com", gmail: ".google.com", "google-docs": ".google.com", notion: ".notion.so", slack: ".slack.com", zoom: ".zoom.us" });
|
|
246
|
-
const verifyCookies = (service: AuthService, cookies: readonly Cookie[], metadata: Readonly<Record<string, string>>) => service === "ashby" ? ashbySession(runtime,cookies).then(q=>q("query { sessionUser { id } }")).then(d=>d.sessionUser ? {service,identity:{user_id:d.sessionUser.id}} : null).catch(()=>null) : service === "asana" ? verifyAsana(runtime, cookies) : service === "chatgpt" ? verifyChatgpt(runtime, cookies) : service === "gmail" ? verifyGmailCookies(runtime, cookies) : service === "google-docs" ? verifyGoogleDocsCookies(runtime, cookies) : service === "notion" ? verifyNotion(runtime, cookies) : service === "slack" ? verifySlack(runtime, cookies, metadata) : verifyZoom(runtime, cookies);
|
|
247
|
+
const cookieDomains: Readonly<Record<AuthService, string>> = Object.freeze({ ashby: ".ashbyhq.com", asana: ".asana.com", chatgpt: ".chatgpt.com", codesignal: ".codesignal.com", gmail: ".google.com", "google-docs": ".google.com", notion: ".notion.so", slack: ".slack.com", zoom: ".zoom.us" });
|
|
248
|
+
const verifyCookies = (service: AuthService, cookies: readonly Cookie[], metadata: Readonly<Record<string, string>>) => service === "codesignal" ? (metadata.token ? verifyCodeSignal(metadata.token) : null) : service === "ashby" ? ashbySession(runtime,cookies).then(q=>q("query { sessionUser { id } }")).then(d=>d.sessionUser ? {service,identity:{user_id:d.sessionUser.id}} : null).catch(()=>null) : service === "asana" ? verifyAsana(runtime, cookies) : service === "chatgpt" ? verifyChatgpt(runtime, cookies) : service === "gmail" ? verifyGmailCookies(runtime, cookies) : service === "google-docs" ? verifyGoogleDocsCookies(runtime, cookies) : service === "notion" ? verifyNotion(runtime, cookies) : service === "slack" ? verifySlack(runtime, cookies, metadata) : verifyZoom(runtime, cookies);
|
|
247
249
|
const verifyCookieState = async (service: AuthService, cookies: readonly Cookie[], metadata: Readonly<Record<string, string>>) => {
|
|
248
250
|
if (service === "zoom") return verifyZoomCookieState(runtime, cookies, metadata);
|
|
249
251
|
return Object.freeze({ result: await verifyCookies(service, cookies, metadata), cookies, metadata, changed: false });
|
|
@@ -292,6 +294,7 @@ export function composeAuth(runtime: RuntimeCapabilities, environment: NodeEnvir
|
|
|
292
294
|
extractAshby: () => extract("ashby", "https://app.ashbyhq.com/", ["ashbyhq.com"], values => values.length > 0),
|
|
293
295
|
extractAsana: () => extract("asana", "https://app.asana.com/", ["asana.com"], (values) => values.some((cookie) => cookie.domain === ".asana.com" || cookie.domain.endsWith(".asana.com"))),
|
|
294
296
|
extractChatgpt: () => extract("chatgpt", "https://chatgpt.com/", ["chatgpt.com", "openai.com"], (values) => values.some((cookie) => cookie.name === "oai-did") && values.some((cookie) => cookie.name === "__Secure-next-auth.session-token" || cookie.name === "__Secure-next-auth.session-token.0"), undefined, true),
|
|
297
|
+
extractCodeSignal: () => extract("codesignal", "https://app.codesignal.com/", ["codesignal.com"], () => true, `(() => { const token = location.origin === "https://app.codesignal.com" && localStorage.getItem("Meteor.loginToken"); return token ? {token} : {}; })()`),
|
|
295
298
|
extractGmail: () => extract("gmail", "https://mail.google.com/mail/u/0/", ["google.com"], googleReady),
|
|
296
299
|
extractGoogleDocs: () => extract("google-docs", "https://docs.google.com/", ["google.com"], googleReady),
|
|
297
300
|
extractNotion: () => extract("notion", "https://www.notion.so/login", ["notion.so", "notion.com"], requiredReady(["token_v2", "notion_user_id", "notion_users"])),
|
package/src/cli.ts
CHANGED
|
@@ -120,7 +120,7 @@ const fixedCommandPositionals = Object.freeze({
|
|
|
120
120
|
"sync-all": Object.freeze({ expected: 0, name: "" }),
|
|
121
121
|
watch: Object.freeze({ expected: 1, name: "file" }),
|
|
122
122
|
});
|
|
123
|
-
const authServices = new Set(["ashby", "asana", "chatgpt", "gmail", "google-docs", "notion", "slack", "zoom"]);
|
|
123
|
+
const authServices = new Set(["ashby", "asana", "chatgpt", "codesignal", "gmail", "google-docs", "notion", "slack", "zoom"]);
|
|
124
124
|
const slackResourceCommands = new Set(["preview", "attach", "sync"]);
|
|
125
125
|
const authCommands = new Set(["login", "logout", "status"]);
|
|
126
126
|
const removedCommandNames = Object.freeze({
|
|
@@ -142,7 +142,7 @@ function isSourceUrl(value: string): boolean {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
function isSourceLikeWithoutScheme(value: string): boolean {
|
|
145
|
-
return /^(docs\.google\.com|mail\.google\.com|app\.asana\.com|chatgpt\.com|chat\.openai\.com|hub\.zoom\.us|www\.notion\.so|notion\.so|app\.notion\.com|[^/\s]+\.notion\.site|[^/\s]+\.slack\.com)(?:[/?:#]|$)/.test(value);
|
|
145
|
+
return /^(docs\.google\.com|mail\.google\.com|app\.asana\.com|chatgpt\.com|app\.codesignal\.com|chat\.openai\.com|hub\.zoom\.us|www\.notion\.so|notion\.so|app\.notion\.com|[^/\s]+\.notion\.site|[^/\s]+\.slack\.com)(?:[/?:#]|$)/.test(value);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
function expectedSourceMessage(prefix: string, value: string): string {
|
package/src/executable.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { zoomProvider } from "provider-zoom";
|
|
|
10
10
|
import { lookupNotionUsers } from "provider-notion";
|
|
11
11
|
|
|
12
12
|
import { previewDrive, scrapeDrive } from "./adapters/gdrive.js";
|
|
13
|
+
import { codeSignalInterviewId, previewCodeSignal } from "./adapters/codesignal.js";
|
|
13
14
|
import { ashby } from "./adapters/ashby.js";
|
|
14
15
|
import { readAgenda } from "./adapters/calendar.js";
|
|
15
16
|
import { createRoot } from "./adapters/root.js";
|
|
@@ -126,7 +127,7 @@ export function createExecutableRoot(environment: NodeEnvironment, currentDirect
|
|
|
126
127
|
...baseWire,
|
|
127
128
|
attach: async (url: string, path: string) => { activeConfigurationPath = path; return baseWire.attach(url, path); },
|
|
128
129
|
create: async (url: string, path: string) => { activeConfigurationPath = path; return baseWire.create(url, path); },
|
|
129
|
-
view: async (url: string) => { activeConfigurationPath = currentDirectory; return baseWire.view(url); },
|
|
130
|
+
view: async (url: string) => { activeConfigurationPath = currentDirectory; const id = codeSignalInterviewId(url); return id ? previewCodeSignal(runtime, id) : baseWire.view(url); },
|
|
130
131
|
downloadSource: async (url: string, path: string) => { activeConfigurationPath = path; return baseWire.downloadSource(url, path); },
|
|
131
132
|
sync: async (value: string, path: string) => { activeConfigurationPath = operationPath(value, path); return baseWire.sync(value, path); },
|
|
132
133
|
download: async (value: string, path: string) => { activeConfigurationPath = operationPath(value, path); return baseWire.download(value, path); },
|