framer-dalton 0.0.11 → 0.0.12

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/cli.js CHANGED
@@ -10,7 +10,7 @@ import { z } from 'zod';
10
10
  import { fileURLToPath } from 'url';
11
11
  import { createTRPCClient, httpLink } from '@trpc/client';
12
12
 
13
- /* @framer/ai CLI v0.0.11 */
13
+ /* @framer/ai CLI v0.0.12 */
14
14
  var __defProp = Object.defineProperty;
15
15
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
16
16
  function openUrl(url) {
@@ -204,6 +204,16 @@ __name(printError, "printError");
204
204
 
205
205
  // src/auth-callback.ts
206
206
  var TIMEOUT_MS = 3e5;
207
+ var codeMessages = {
208
+ "user.denied": "Authorization denied by user.",
209
+ "project.access_denied": "You don\u2019t have access to this project.",
210
+ "project.not_found": "Project not found. Check that the project ID is correct.",
211
+ "project.unauthorized": "Not logged in to Framer.",
212
+ "api_key.access_denied": "You don\u2019t have permission to create API keys for this project.",
213
+ "api_key.unauthorized": "Session expired.",
214
+ connection_error: "Could not connect to Framer.",
215
+ unknown: "Authorization failed."
216
+ };
207
217
  var themes = {
208
218
  dark: {
209
219
  pageBackground: "rgb(17, 17, 17)",
@@ -271,15 +281,6 @@ function successHtml(theme) {
271
281
  });
272
282
  }
273
283
  __name(successHtml, "successHtml");
274
- function deniedHtml(theme) {
275
- return htmlPage({
276
- title: "Framer \u2014 Authorization Denied",
277
- heading: "Authorization Denied",
278
- message: "Agent access was denied. You can close this tab.",
279
- theme
280
- });
281
- }
282
- __name(deniedHtml, "deniedHtml");
283
284
  function errorHtml(theme) {
284
285
  return htmlPage({
285
286
  title: "Framer \u2014 Authorization Failed",
@@ -289,10 +290,26 @@ function errorHtml(theme) {
289
290
  });
290
291
  }
291
292
  __name(errorHtml, "errorHtml");
293
+ function codeHtml(code, theme) {
294
+ const heading = code === "user.denied" ? "Authorization Denied" : "Authorization Failed";
295
+ return htmlPage({
296
+ title: `Framer \u2014 ${heading}`,
297
+ heading,
298
+ message: codeMessages[code],
299
+ theme
300
+ });
301
+ }
302
+ __name(codeHtml, "codeHtml");
292
303
  function parseTheme(value) {
293
304
  return value === "light" ? "light" : "dark";
294
305
  }
295
306
  __name(parseTheme, "parseTheme");
307
+ var validCodes = new Set(Object.keys(codeMessages));
308
+ function parseCode(value) {
309
+ if (value !== null && validCodes.has(value)) return value;
310
+ return null;
311
+ }
312
+ __name(parseCode, "parseCode");
296
313
  async function acquireKeyFromBrowser(projectId) {
297
314
  const state = crypto.randomBytes(16).toString("hex");
298
315
  return new Promise((resolve, reject) => {
@@ -324,12 +341,14 @@ async function acquireKeyFromBrowser(projectId) {
324
341
  return;
325
342
  }
326
343
  const theme = parseTheme(url.searchParams.get("theme"));
327
- const error = url.searchParams.get("error");
328
- if (error === "denied") {
344
+ const legacyError = url.searchParams.get("error");
345
+ const legacyCode = legacyError === "denied" ? "user.denied" : legacyError === "failed" ? "project.unauthorized" : null;
346
+ const code = parseCode(url.searchParams.get("code")) ?? legacyCode;
347
+ if (code !== null) {
329
348
  res.writeHead(200, { "Content-Type": "text/html" });
330
- res.end(deniedHtml(theme));
349
+ res.end(codeHtml(code, theme));
331
350
  cleanup();
332
- reject(new Error("Authorization denied by user."));
351
+ reject(new Error(codeMessages[code]));
333
352
  return;
334
353
  }
335
354
  const apiKey = url.searchParams.get("apiKey");
@@ -14910,7 +14929,7 @@ ${typeDef}`);
14910
14929
  __name(renderDocs, "renderDocs");
14911
14930
  var __filename$1 = fileURLToPath(import.meta.url);
14912
14931
  var __dirname$1 = path4.dirname(__filename$1);
14913
- var VERSION = "0.0.11" ;
14932
+ var VERSION = "0.0.12" ;
14914
14933
  var RELAY_PORT = Number(process.env.FRAMER_CLI_PORT) || 19988;
14915
14934
  var client = createTRPCClient({
14916
14935
  links: [
@@ -13,7 +13,7 @@ import { createRequire } from 'module';
13
13
  import * as vm from 'vm';
14
14
  import { connect } from 'framer-api';
15
15
 
16
- /* @framer/ai relay server v0.0.11 */
16
+ /* @framer/ai relay server v0.0.12 */
17
17
  var __defProp = Object.defineProperty;
18
18
  var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
19
19
  var __typeError = (msg) => {
@@ -91,7 +91,7 @@ function log(message) {
91
91
  __name(log, "log");
92
92
  var __filename$1 = fileURLToPath(import.meta.url);
93
93
  path.dirname(__filename$1);
94
- var VERSION = "0.0.11" ;
94
+ var VERSION = "0.0.12" ;
95
95
  var RELAY_PORT = Number(process.env.FRAMER_CLI_PORT) || 19988;
96
96
  createTRPCClient({
97
97
  links: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framer-dalton",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "framer-dalton": "./dist/cli.js"