laxy-verify 1.2.0 → 1.2.2

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.
Files changed (40) hide show
  1. package/README.md +12 -17
  2. package/dist/audit/broken-links.d.ts +21 -21
  3. package/dist/audit/broken-links.js +86 -86
  4. package/dist/auth.d.ts +11 -11
  5. package/dist/auth.js +222 -222
  6. package/dist/cli.js +868 -806
  7. package/dist/comment.d.ts +21 -21
  8. package/dist/comment.js +125 -125
  9. package/dist/config.d.ts +13 -0
  10. package/dist/config.js +43 -3
  11. package/dist/crawler.d.ts +36 -36
  12. package/dist/crawler.js +357 -357
  13. package/dist/e2e.d.ts +49 -49
  14. package/dist/e2e.js +565 -565
  15. package/dist/entitlement.d.ts +11 -11
  16. package/dist/entitlement.js +90 -90
  17. package/dist/init.js +87 -87
  18. package/dist/multi-viewport.d.ts +31 -31
  19. package/dist/multi-viewport.js +298 -298
  20. package/dist/playwright-runner.d.ts +16 -16
  21. package/dist/playwright-runner.js +208 -208
  22. package/dist/report-markdown.d.ts +39 -39
  23. package/dist/report-markdown.js +386 -386
  24. package/dist/security-audit.d.ts +9 -9
  25. package/dist/security-audit.js +64 -64
  26. package/dist/serve.d.ts +13 -13
  27. package/dist/serve.js +196 -196
  28. package/dist/trend.d.ts +50 -50
  29. package/dist/trend.js +148 -148
  30. package/dist/verification-core/index.d.ts +3 -3
  31. package/dist/verification-core/index.js +19 -19
  32. package/dist/verification-core/report.d.ts +14 -14
  33. package/dist/verification-core/report.js +409 -409
  34. package/dist/verification-core/tier-policy.d.ts +13 -13
  35. package/dist/verification-core/tier-policy.js +60 -60
  36. package/dist/verification-core/types.d.ts +108 -108
  37. package/dist/verification-core/types.js +2 -2
  38. package/dist/visual-diff.d.ts +26 -26
  39. package/dist/visual-diff.js +178 -178
  40. package/package.json +1 -1
package/dist/auth.js CHANGED
@@ -1,222 +1,222 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.LAXY_API_URL = void 0;
37
- exports.loadToken = loadToken;
38
- exports.saveToken = saveToken;
39
- exports.clearToken = clearToken;
40
- exports.whoami = whoami;
41
- exports.getOrCreateRepoId = getOrCreateRepoId;
42
- exports.login = login;
43
- /**
44
- * CLI authentication helpers for laxy-verify.
45
- *
46
- * Credentials are stored at ~/.laxy/credentials.json.
47
- * The CLI exchanges email/password for a short-lived verification token
48
- * through POST /api/cli-auth on the Laxy website.
49
- */
50
- const fs = __importStar(require("node:fs"));
51
- const path = __importStar(require("node:path"));
52
- const os = __importStar(require("node:os"));
53
- const crypto = __importStar(require("node:crypto"));
54
- const CREDENTIALS_DIR = path.join(os.homedir(), ".laxy");
55
- const CREDENTIALS_PATH = path.join(CREDENTIALS_DIR, "credentials.json");
56
- const REPOS_PATH = path.join(CREDENTIALS_DIR, "repos.json");
57
- exports.LAXY_API_URL = process.env.LAXY_API_URL ?? "https://laxy-blue.vercel.app";
58
- function loadToken() {
59
- const envToken = process.env.LAXY_TOKEN;
60
- if (envToken)
61
- return envToken;
62
- try {
63
- if (!fs.existsSync(CREDENTIALS_PATH))
64
- return null;
65
- const raw = fs.readFileSync(CREDENTIALS_PATH, "utf-8");
66
- const creds = JSON.parse(raw);
67
- if (!creds.token)
68
- return null;
69
- if (creds.expires_at) {
70
- const expiresAt = new Date(creds.expires_at).getTime();
71
- if (expiresAt < Date.now()) {
72
- console.error(" Saved CLI token expired. Run `laxy-verify login` again.");
73
- return null;
74
- }
75
- }
76
- return creds.token;
77
- }
78
- catch {
79
- return null;
80
- }
81
- }
82
- function saveToken(token, email, expiresInSec) {
83
- if (!fs.existsSync(CREDENTIALS_DIR)) {
84
- fs.mkdirSync(CREDENTIALS_DIR, { recursive: true });
85
- }
86
- const creds = {
87
- token,
88
- email,
89
- saved_at: new Date().toISOString(),
90
- expires_at: new Date(Date.now() + expiresInSec * 1000).toISOString(),
91
- };
92
- fs.writeFileSync(CREDENTIALS_PATH, JSON.stringify(creds, null, 2), {
93
- encoding: "utf-8",
94
- mode: 0o600,
95
- });
96
- }
97
- function clearToken() {
98
- if (fs.existsSync(CREDENTIALS_PATH)) {
99
- fs.rmSync(CREDENTIALS_PATH);
100
- console.log(" Saved CLI credentials removed.");
101
- }
102
- else {
103
- console.log(" No saved CLI credentials were found.");
104
- }
105
- }
106
- function whoami() {
107
- const envToken = process.env.LAXY_TOKEN;
108
- if (envToken) {
109
- console.log(" Auth source: LAXY_TOKEN environment variable");
110
- return;
111
- }
112
- try {
113
- if (!fs.existsSync(CREDENTIALS_PATH)) {
114
- console.log(" Not logged in. Run `laxy-verify login` first.");
115
- return;
116
- }
117
- const raw = fs.readFileSync(CREDENTIALS_PATH, "utf-8");
118
- const creds = JSON.parse(raw);
119
- const expDate = creds.expires_at
120
- ? new Date(creds.expires_at).toLocaleDateString("ko-KR")
121
- : "unknown";
122
- console.log(` Email: ${creds.email}`);
123
- console.log(` Token expires: ${expDate}`);
124
- }
125
- catch {
126
- console.log(" Saved CLI credentials could not be read.");
127
- }
128
- }
129
- /**
130
- * Get or create a stable repo_id for the given project directory.
131
- * Stored in ~/.laxy/repos.json keyed by absolute project path.
132
- */
133
- function getOrCreateRepoId(projectDir) {
134
- const absDir = path.resolve(projectDir);
135
- let repos = {};
136
- try {
137
- if (fs.existsSync(REPOS_PATH)) {
138
- repos = JSON.parse(fs.readFileSync(REPOS_PATH, "utf-8"));
139
- }
140
- }
141
- catch {
142
- repos = {};
143
- }
144
- if (repos[absDir])
145
- return repos[absDir];
146
- // Generate new repo_id
147
- const newId = crypto.randomUUID();
148
- repos[absDir] = newId;
149
- try {
150
- if (!fs.existsSync(CREDENTIALS_DIR)) {
151
- fs.mkdirSync(CREDENTIALS_DIR, { recursive: true });
152
- }
153
- fs.writeFileSync(REPOS_PATH, JSON.stringify(repos, null, 2), { encoding: "utf-8", mode: 0o600 });
154
- }
155
- catch {
156
- // If we can't save, still return the generated id for this run
157
- }
158
- return newId;
159
- }
160
- /**
161
- * Read a line from stdin without creating a readline interface.
162
- * This avoids the Windows UV_HANDLE_CLOSING assertion that can happen
163
- * when the process exits immediately after async stdin cleanup.
164
- */
165
- function readLineSync(prompt, muted = false) {
166
- process.stdout.write(prompt);
167
- const chars = [];
168
- const oneByte = Buffer.alloc(1);
169
- try {
170
- while (true) {
171
- const n = fs.readSync(0, oneByte, 0, 1, null);
172
- if (n === 0)
173
- break;
174
- const ch = oneByte[0];
175
- if (ch === 10) {
176
- if (muted)
177
- process.stdout.write("\n");
178
- break;
179
- }
180
- if (ch !== 13)
181
- chars.push(ch);
182
- }
183
- }
184
- catch {
185
- // Ignore stdin read errors and return the current buffer.
186
- }
187
- return Buffer.from(chars).toString("utf-8");
188
- }
189
- async function login(emailArg) {
190
- const email = emailArg?.trim() ?? readLineSync(" Email: ");
191
- const password = readLineSync(" Password: ", true);
192
- console.log("\n Logging in...");
193
- let res;
194
- try {
195
- res = await fetch(`${exports.LAXY_API_URL}/api/cli-auth`, {
196
- method: "POST",
197
- headers: { "Content-Type": "application/json" },
198
- body: JSON.stringify({ email, password }),
199
- });
200
- }
201
- catch {
202
- console.error(` Could not reach ${exports.LAXY_API_URL}.`);
203
- process.exit(1);
204
- }
205
- const contentType = res.headers.get("content-type") ?? "";
206
- if (!contentType.includes("application/json")) {
207
- const body = await res.text();
208
- const preview = body.slice(0, 200).replace(/\n/g, " ");
209
- console.error(` The CLI auth endpoint returned non-JSON content. (HTTP ${res.status})`);
210
- console.error(` URL: ${exports.LAXY_API_URL}/api/cli-auth`);
211
- console.error(` Response preview: ${preview}`);
212
- console.error(" Check the deployed auth route and required server env vars.");
213
- process.exit(1);
214
- }
215
- const data = (await res.json());
216
- if (!res.ok || !data.token) {
217
- console.error(` ${data.error ?? "Login failed."}`);
218
- process.exit(1);
219
- }
220
- saveToken(data.token, email, data.expires_in ?? 30 * 24 * 60 * 60);
221
- console.log(" Login succeeded. Run `laxy-verify .` to start verification.");
222
- }
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.LAXY_API_URL = void 0;
37
+ exports.loadToken = loadToken;
38
+ exports.saveToken = saveToken;
39
+ exports.clearToken = clearToken;
40
+ exports.whoami = whoami;
41
+ exports.getOrCreateRepoId = getOrCreateRepoId;
42
+ exports.login = login;
43
+ /**
44
+ * CLI authentication helpers for laxy-verify.
45
+ *
46
+ * Credentials are stored at ~/.laxy/credentials.json.
47
+ * The CLI exchanges email/password for a short-lived verification token
48
+ * through POST /api/cli-auth on the Laxy website.
49
+ */
50
+ const fs = __importStar(require("node:fs"));
51
+ const path = __importStar(require("node:path"));
52
+ const os = __importStar(require("node:os"));
53
+ const crypto = __importStar(require("node:crypto"));
54
+ const CREDENTIALS_DIR = path.join(os.homedir(), ".laxy");
55
+ const CREDENTIALS_PATH = path.join(CREDENTIALS_DIR, "credentials.json");
56
+ const REPOS_PATH = path.join(CREDENTIALS_DIR, "repos.json");
57
+ exports.LAXY_API_URL = process.env.LAXY_API_URL ?? "https://laxy-blue.vercel.app";
58
+ function loadToken() {
59
+ const envToken = process.env.LAXY_TOKEN;
60
+ if (envToken)
61
+ return envToken;
62
+ try {
63
+ if (!fs.existsSync(CREDENTIALS_PATH))
64
+ return null;
65
+ const raw = fs.readFileSync(CREDENTIALS_PATH, "utf-8");
66
+ const creds = JSON.parse(raw);
67
+ if (!creds.token)
68
+ return null;
69
+ if (creds.expires_at) {
70
+ const expiresAt = new Date(creds.expires_at).getTime();
71
+ if (expiresAt < Date.now()) {
72
+ console.error(" Saved CLI token expired. Run `laxy-verify login` again.");
73
+ return null;
74
+ }
75
+ }
76
+ return creds.token;
77
+ }
78
+ catch {
79
+ return null;
80
+ }
81
+ }
82
+ function saveToken(token, email, expiresInSec) {
83
+ if (!fs.existsSync(CREDENTIALS_DIR)) {
84
+ fs.mkdirSync(CREDENTIALS_DIR, { recursive: true });
85
+ }
86
+ const creds = {
87
+ token,
88
+ email,
89
+ saved_at: new Date().toISOString(),
90
+ expires_at: new Date(Date.now() + expiresInSec * 1000).toISOString(),
91
+ };
92
+ fs.writeFileSync(CREDENTIALS_PATH, JSON.stringify(creds, null, 2), {
93
+ encoding: "utf-8",
94
+ mode: 0o600,
95
+ });
96
+ }
97
+ function clearToken() {
98
+ if (fs.existsSync(CREDENTIALS_PATH)) {
99
+ fs.rmSync(CREDENTIALS_PATH);
100
+ console.log(" Saved CLI credentials removed.");
101
+ }
102
+ else {
103
+ console.log(" No saved CLI credentials were found.");
104
+ }
105
+ }
106
+ function whoami() {
107
+ const envToken = process.env.LAXY_TOKEN;
108
+ if (envToken) {
109
+ console.log(" Auth source: LAXY_TOKEN environment variable");
110
+ return;
111
+ }
112
+ try {
113
+ if (!fs.existsSync(CREDENTIALS_PATH)) {
114
+ console.log(" Not logged in. Run `laxy-verify login` first.");
115
+ return;
116
+ }
117
+ const raw = fs.readFileSync(CREDENTIALS_PATH, "utf-8");
118
+ const creds = JSON.parse(raw);
119
+ const expDate = creds.expires_at
120
+ ? new Date(creds.expires_at).toLocaleDateString("ko-KR")
121
+ : "unknown";
122
+ console.log(` Email: ${creds.email}`);
123
+ console.log(` Token expires: ${expDate}`);
124
+ }
125
+ catch {
126
+ console.log(" Saved CLI credentials could not be read.");
127
+ }
128
+ }
129
+ /**
130
+ * Get or create a stable repo_id for the given project directory.
131
+ * Stored in ~/.laxy/repos.json keyed by absolute project path.
132
+ */
133
+ function getOrCreateRepoId(projectDir) {
134
+ const absDir = path.resolve(projectDir);
135
+ let repos = {};
136
+ try {
137
+ if (fs.existsSync(REPOS_PATH)) {
138
+ repos = JSON.parse(fs.readFileSync(REPOS_PATH, "utf-8"));
139
+ }
140
+ }
141
+ catch {
142
+ repos = {};
143
+ }
144
+ if (repos[absDir])
145
+ return repos[absDir];
146
+ // Generate new repo_id
147
+ const newId = crypto.randomUUID();
148
+ repos[absDir] = newId;
149
+ try {
150
+ if (!fs.existsSync(CREDENTIALS_DIR)) {
151
+ fs.mkdirSync(CREDENTIALS_DIR, { recursive: true });
152
+ }
153
+ fs.writeFileSync(REPOS_PATH, JSON.stringify(repos, null, 2), { encoding: "utf-8", mode: 0o600 });
154
+ }
155
+ catch {
156
+ // If we can't save, still return the generated id for this run
157
+ }
158
+ return newId;
159
+ }
160
+ /**
161
+ * Read a line from stdin without creating a readline interface.
162
+ * This avoids the Windows UV_HANDLE_CLOSING assertion that can happen
163
+ * when the process exits immediately after async stdin cleanup.
164
+ */
165
+ function readLineSync(prompt, muted = false) {
166
+ process.stdout.write(prompt);
167
+ const chars = [];
168
+ const oneByte = Buffer.alloc(1);
169
+ try {
170
+ while (true) {
171
+ const n = fs.readSync(0, oneByte, 0, 1, null);
172
+ if (n === 0)
173
+ break;
174
+ const ch = oneByte[0];
175
+ if (ch === 10) {
176
+ if (muted)
177
+ process.stdout.write("\n");
178
+ break;
179
+ }
180
+ if (ch !== 13)
181
+ chars.push(ch);
182
+ }
183
+ }
184
+ catch {
185
+ // Ignore stdin read errors and return the current buffer.
186
+ }
187
+ return Buffer.from(chars).toString("utf-8");
188
+ }
189
+ async function login(emailArg) {
190
+ const email = emailArg?.trim() ?? readLineSync(" Email: ");
191
+ const password = readLineSync(" Password: ", true);
192
+ console.log("\n Logging in...");
193
+ let res;
194
+ try {
195
+ res = await fetch(`${exports.LAXY_API_URL}/api/cli-auth`, {
196
+ method: "POST",
197
+ headers: { "Content-Type": "application/json" },
198
+ body: JSON.stringify({ email, password }),
199
+ });
200
+ }
201
+ catch {
202
+ console.error(` Could not reach ${exports.LAXY_API_URL}.`);
203
+ process.exit(1);
204
+ }
205
+ const contentType = res.headers.get("content-type") ?? "";
206
+ if (!contentType.includes("application/json")) {
207
+ const body = await res.text();
208
+ const preview = body.slice(0, 200).replace(/\n/g, " ");
209
+ console.error(` The CLI auth endpoint returned non-JSON content. (HTTP ${res.status})`);
210
+ console.error(` URL: ${exports.LAXY_API_URL}/api/cli-auth`);
211
+ console.error(` Response preview: ${preview}`);
212
+ console.error(" Check the deployed auth route and required server env vars.");
213
+ process.exit(1);
214
+ }
215
+ const data = (await res.json());
216
+ if (!res.ok || !data.token) {
217
+ console.error(` ${data.error ?? "Login failed."}`);
218
+ process.exit(1);
219
+ }
220
+ saveToken(data.token, email, data.expires_in ?? 30 * 24 * 60 * 60);
221
+ console.log(" Login succeeded. Run `laxy-verify .` to start verification.");
222
+ }