@superblocksteam/sdk 2.0.54 → 2.0.56-next.0
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/.turbo/turbo-build.log +1 -1
- package/dist/application-build.d.mts.map +1 -1
- package/dist/application-build.mjs +0 -2
- package/dist/application-build.mjs.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.d.ts.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.js +0 -4
- package/dist/cli-replacement/automatic-upgrades.js.map +1 -1
- package/dist/cli-replacement/dev.d.mts.map +1 -1
- package/dist/cli-replacement/dev.mjs +1 -0
- package/dist/cli-replacement/dev.mjs.map +1 -1
- package/dist/dev-utils/dev-server.d.mts.map +1 -1
- package/dist/dev-utils/dev-server.mjs +98 -6
- package/dist/dev-utils/dev-server.mjs.map +1 -1
- package/dist/flag.d.ts +0 -1
- package/dist/flag.d.ts.map +1 -1
- package/dist/flag.js +0 -3
- package/dist/flag.js.map +1 -1
- package/dist/types/common.d.ts +0 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js.map +1 -1
- package/dist/types/scoped-jwt-token-payload.d.ts +10 -0
- package/dist/types/scoped-jwt-token-payload.d.ts.map +1 -0
- package/dist/types/scoped-jwt-token-payload.js +2 -0
- package/dist/types/scoped-jwt-token-payload.js.map +1 -0
- package/dist/utils/token-utils.d.mts +4 -0
- package/dist/utils/token-utils.d.mts.map +1 -1
- package/dist/utils/token-utils.mjs +2 -0
- package/dist/utils/token-utils.mjs.map +1 -1
- package/dist/vite-plugin-inject-sb-ids-transform.d.mts +16 -2
- package/dist/vite-plugin-inject-sb-ids-transform.d.mts.map +1 -1
- package/dist/vite-plugin-inject-sb-ids-transform.mjs +2 -31
- package/dist/vite-plugin-inject-sb-ids-transform.mjs.map +1 -1
- package/dist/vite-plugin-optimize-lucide-imports.d.ts.map +1 -1
- package/dist/vite-plugin-optimize-lucide-imports.js +2 -0
- package/dist/vite-plugin-optimize-lucide-imports.js.map +1 -1
- package/package.json +6 -6
- package/src/application-build.mts +0 -2
- package/src/cli-replacement/automatic-upgrades.ts +0 -4
- package/src/cli-replacement/dev.mts +1 -0
- package/src/dev-utils/dev-server.mts +118 -7
- package/src/flag.ts +0 -4
- package/src/types/common.ts +0 -1
- package/src/types/scoped-jwt-token-payload.ts +12 -0
- package/src/utils/token-utils.mts +6 -0
- package/src/vite-plugin-inject-sb-ids-transform.mts +4 -45
- package/src/vite-plugin-optimize-lucide-imports.ts +2 -0
- package/tsconfig.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/turbo.json +2 -1
- package/dist/vite-plugin-generate-build-manifest.d.mts +0 -21
- package/dist/vite-plugin-generate-build-manifest.d.mts.map +0 -1
- package/dist/vite-plugin-generate-build-manifest.mjs +0 -137
- package/dist/vite-plugin-generate-build-manifest.mjs.map +0 -1
- package/src/vite-plugin-generate-build-manifest.mts +0 -202
|
@@ -2,12 +2,10 @@ import path from "node:path";
|
|
|
2
2
|
import { transformFromAstSync } from "@babel/core";
|
|
3
3
|
import { parse } from "@babel/parser";
|
|
4
4
|
import tsTransformPlugin from "@babel/plugin-transform-typescript";
|
|
5
|
-
import { supplementElementIds
|
|
6
|
-
import {
|
|
7
|
-
import fs from "fs-extra";
|
|
5
|
+
import { supplementElementIds } from "@superblocksteam/vite-plugin-file-sync";
|
|
6
|
+
import { red, yellow } from "colorette";
|
|
8
7
|
import { createLogger } from "vite";
|
|
9
8
|
import { getLogger } from "./telemetry/logging.js";
|
|
10
|
-
const routesFileBaseName = "routes.json";
|
|
11
9
|
/**
|
|
12
10
|
* Creates a Vite plugin that injects Superblocks IDs into the application.
|
|
13
11
|
* This will primarily be used during builds, as the dev server leverages the
|
|
@@ -34,7 +32,6 @@ export async function injectSuperblocksIdsPlugin(root) {
|
|
|
34
32
|
logger.error(red(msg));
|
|
35
33
|
};
|
|
36
34
|
viteLogger.clearScreen = () => { };
|
|
37
|
-
const routes = await getRoutes(root, viteLogger);
|
|
38
35
|
return {
|
|
39
36
|
name: "sb-inject-superblocks-ids",
|
|
40
37
|
enforce: "pre",
|
|
@@ -45,13 +42,6 @@ export async function injectSuperblocksIdsPlugin(root) {
|
|
|
45
42
|
!id.endsWith(".tsx")) {
|
|
46
43
|
return null;
|
|
47
44
|
}
|
|
48
|
-
const relativePath = path.relative(root, id);
|
|
49
|
-
if (relativePath === "root.tsx") {
|
|
50
|
-
return {
|
|
51
|
-
code: generateRootSource(code, routes),
|
|
52
|
-
map: null,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
45
|
const ast = parse(code, {
|
|
56
46
|
sourceType: "module",
|
|
57
47
|
sourceFilename: id,
|
|
@@ -76,23 +66,4 @@ export async function injectSuperblocksIdsPlugin(root) {
|
|
|
76
66
|
},
|
|
77
67
|
};
|
|
78
68
|
}
|
|
79
|
-
async function getRoutes(root, logger) {
|
|
80
|
-
const routesFile = path.join(root, routesFileBaseName);
|
|
81
|
-
if (!(await fs.pathExists(routesFile))) {
|
|
82
|
-
logger.warn(`routes file not found at expected location: ${routesFile}`);
|
|
83
|
-
return [];
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
const routesData = await fs.readFile(routesFile, "utf-8");
|
|
87
|
-
const routes = JSON.parse(routesData);
|
|
88
|
-
return Object.entries(routes).map(([path, { file }]) => ({
|
|
89
|
-
path,
|
|
90
|
-
component: file,
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
catch (err) {
|
|
94
|
-
logger.error(`error reading routes file: ${routesFile}. error=[${JSON.stringify(err)}]`);
|
|
95
|
-
}
|
|
96
|
-
return [];
|
|
97
|
-
}
|
|
98
69
|
//# sourceMappingURL=vite-plugin-inject-sb-ids-transform.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-inject-sb-ids-transform.mjs","sourceRoot":"","sources":["../src/vite-plugin-inject-sb-ids-transform.mts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;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|
1
|
-
{"version":3,"file":"vite-plugin-optimize-lucide-imports.d.ts","sourceRoot":"","sources":["../src/vite-plugin-optimize-lucide-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,MAAM,EAAE,MAAM,MAAM,CAAC;AAMpD;;;GAGG;AACH,iBAAS,gCAAgC,IAAI,MAAM,CA8BlD;
|
|
1
|
+
{"version":3,"file":"vite-plugin-optimize-lucide-imports.d.ts","sourceRoot":"","sources":["../src/vite-plugin-optimize-lucide-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,MAAM,EAAE,MAAM,MAAM,CAAC;AAMpD;;;GAGG;AACH,iBAAS,gCAAgC,IAAI,MAAM,CA8BlD;AAyFD,eAAe,gCAAgC,CAAC"}
|
|
@@ -75,12 +75,14 @@ function convertToIndividualImports(importNames, indentation, withSemicolon) {
|
|
|
75
75
|
* - CheckIcon -> check
|
|
76
76
|
* - BluetoothConnectedIcon -> bluetooth-connected
|
|
77
77
|
* - XIcon -> x
|
|
78
|
+
* - XCircleIcon -> x-circle
|
|
78
79
|
* - Loader2Icon -> loader-2
|
|
79
80
|
* - Grid2X2CheckIcon -> grid-2-x-2-check
|
|
80
81
|
*/
|
|
81
82
|
function convertToKebabCase(str) {
|
|
82
83
|
return str
|
|
83
84
|
.replace("Icon", "")
|
|
85
|
+
.replace(/([A-Z])([A-Z][a-z])/g, "$1-$2") // Handle consecutive uppercase letters (e.g., XCircle -> X-Circle)
|
|
84
86
|
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
85
87
|
.replace(/([a-zA-Z])([0-9])/g, "$1-$2")
|
|
86
88
|
.toLowerCase();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-optimize-lucide-imports.js","sourceRoot":"","sources":["../src/vite-plugin-optimize-lucide-imports.ts"],"names":[],"mappings":"AAEA,2CAA2C;AAC3C,MAAM,qBAAqB,GACzB,mEAAmE,CAAC;AAEtE;;;GAGG;AACH,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AE,CAAC;YACtB,UAAU,GAAG,IAAI,CAAC;YAClB,OAAO,iBAAiB,CAAC;QAC3B,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CACF,CAAC;IAEF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAS,0BAA0B,CACjC,WAAmB,EACnB,WAAmB,EACnB,aAAsB;IAEtB,OAAO,WAAW;SACf,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,MAAM,aAAa,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,OAAO,GAAG,WAAW,UAAU,IAAI,sCAAsC,aAAa,IAAI,SAAS,EAAE,CAAC;IACxG,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"vite-plugin-optimize-lucide-imports.js","sourceRoot":"","sources":["../src/vite-plugin-optimize-lucide-imports.ts"],"names":[],"mappings":"AAEA,2CAA2C;AAC3C,MAAM,qBAAqB,GACzB,mEAAmE,CAAC;AAEtE;;;GAGG;AACH,SAAS,gCAAgC;IACvC,OAAO;QACL,IAAI,EAAE,+BAA+B;QACrC,SAAS,CACP,UAAkB,EAClB,QAAgB;YAEhB,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC;gBAAE,OAAO,IAAI,CAAC;YAErD,IAAI,CAAC;gBACH,wDAAwD;gBACxD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC;oBAAE,OAAO,IAAI,CAAC;gBAEtD,MAAM,EAAE,eA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GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,MAAM,aAAa,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,OAAO,GAAG,WAAW,UAAU,IAAI,sCAAsC,aAAa,IAAI,SAAS,EAAE,CAAC;IACxG,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,kBAAkB,CAAC,GAAW;IACrC,OAAO,GAAG;SACP,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACnB,OAAO,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC,mEAAmE;SAC5G,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,WAAW,EAAE,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAAC,KAAc;IAC1C,MAAM,UAAU,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7E,OAAO,CAAC,KAAK,CAAC,gDAAgD,EAAE,UAAU,CAAC,CAAC;AAC9E,CAAC;AAED,eAAe,gCAAgC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superblocksteam/sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.56-next.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Superblocks JS SDK",
|
|
6
6
|
"homepage": "https://www.superblocks.com",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"@opentelemetry/semantic-conventions": "^1.28.0",
|
|
35
35
|
"@rollup/wasm-node": "^4.35.0",
|
|
36
36
|
"@superblocksteam/bucketeer-sdk": "0.5.0",
|
|
37
|
-
"@superblocksteam/library": "2.0.
|
|
38
|
-
"@superblocksteam/library-shared": "2.0.
|
|
39
|
-
"@superblocksteam/shared": "v0.
|
|
40
|
-
"@superblocksteam/util": "2.0.
|
|
41
|
-
"@superblocksteam/vite-plugin-file-sync": "2.0.
|
|
37
|
+
"@superblocksteam/library": "2.0.56-next.0",
|
|
38
|
+
"@superblocksteam/library-shared": "2.0.56-next.0",
|
|
39
|
+
"@superblocksteam/shared": "v0.9546.0",
|
|
40
|
+
"@superblocksteam/util": "2.0.56-next.0",
|
|
41
|
+
"@superblocksteam/vite-plugin-file-sync": "2.0.56-next.0",
|
|
42
42
|
"@vitejs/plugin-react": "4.3.4",
|
|
43
43
|
"axios": "^1.4.0",
|
|
44
44
|
"chokidar": "^4.0.3",
|
|
@@ -8,7 +8,6 @@ import tsconfigPaths from "vite-tsconfig-paths";
|
|
|
8
8
|
import { customComponentsPlugin } from "./dev-utils/custom-build.mjs";
|
|
9
9
|
import { ddRumPlugin } from "./dev-utils/vite-plugin-dd-rum.mjs";
|
|
10
10
|
import { getLogger } from "./telemetry/logging.js";
|
|
11
|
-
import { generateBuildManifestPlugin } from "./vite-plugin-generate-build-manifest.mjs";
|
|
12
11
|
import { injectSuperblocksIdsPlugin } from "./vite-plugin-inject-sb-ids-transform.mjs";
|
|
13
12
|
import createLucideReactImportOptimizer from "./vite-plugin-optimize-lucide-imports.js";
|
|
14
13
|
|
|
@@ -114,7 +113,6 @@ async function buildWithVite({
|
|
|
114
113
|
injectSuperblocksIdsPlugin(root),
|
|
115
114
|
react(),
|
|
116
115
|
createLucideReactImportOptimizer(),
|
|
117
|
-
generateBuildManifestPlugin(root),
|
|
118
116
|
ddRumPlugin({
|
|
119
117
|
clientToken: ddClientToken ?? "",
|
|
120
118
|
applicationId: ddApplicationId ?? "",
|
|
@@ -336,13 +336,9 @@ export async function checkVersionsAndWritePackageJson(
|
|
|
336
336
|
if (targetVersions.library.includes("-SNAPSHOT")) {
|
|
337
337
|
packageJson.dependencies["@superblocksteam/library"] =
|
|
338
338
|
`npm:@superblocksteam/library-ephemeral@${targetVersions.library}`;
|
|
339
|
-
packageJson.devDependencies["@superblocksteam/linter"] =
|
|
340
|
-
`npm:@superblocksteam/linter-ephemeral@${targetVersions.linter}`;
|
|
341
339
|
} else {
|
|
342
340
|
packageJson.dependencies["@superblocksteam/library"] =
|
|
343
341
|
targetVersions.library;
|
|
344
|
-
packageJson.devDependencies["@superblocksteam/linter"] =
|
|
345
|
-
targetVersions.linter;
|
|
346
342
|
}
|
|
347
343
|
|
|
348
344
|
await fs.writeFile(
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import net from "node:net";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { JwtVerifier } from "@superblocksteam/shared";
|
|
4
5
|
import { getSuperblocksResourceConfigIfExists } from "@superblocksteam/util";
|
|
5
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
type FileSyncPluginParams,
|
|
8
|
+
fileSyncVitePlugin,
|
|
9
|
+
} from "@superblocksteam/vite-plugin-file-sync";
|
|
6
10
|
import react from "@vitejs/plugin-react";
|
|
7
11
|
import cors from "cors";
|
|
8
12
|
import express from "express";
|
|
@@ -11,6 +15,10 @@ import tsconfigPaths from "vite-tsconfig-paths";
|
|
|
11
15
|
import pkg from "../../package.json" with { type: "json" };
|
|
12
16
|
import { getTracer } from "../telemetry/index.js";
|
|
13
17
|
import { getErrorMeta, getLogger } from "../telemetry/logging.js";
|
|
18
|
+
import {
|
|
19
|
+
EDIT_APPLICATION_SCOPE,
|
|
20
|
+
type SuperblocksScopedJwtPayload,
|
|
21
|
+
} from "../types/scoped-jwt-token-payload.js";
|
|
14
22
|
import { getCurrentGitBranchIfGit } from "../version-control.mjs";
|
|
15
23
|
import createLucideReactImportOptimizer from "../vite-plugin-optimize-lucide-imports.js";
|
|
16
24
|
import {
|
|
@@ -24,7 +32,7 @@ import type { AiService } from "@superblocksteam/vite-plugin-file-sync/ai-servic
|
|
|
24
32
|
import type { LockService } from "@superblocksteam/vite-plugin-file-sync/lock-service";
|
|
25
33
|
import type { OperationQueue } from "@superblocksteam/vite-plugin-file-sync/operation-queue";
|
|
26
34
|
import type { SyncService } from "@superblocksteam/vite-plugin-file-sync/sync-service";
|
|
27
|
-
import type { IRouter } from "express";
|
|
35
|
+
import type { IRouter, RequestHandler } from "express";
|
|
28
36
|
import type http from "node:http";
|
|
29
37
|
import type { HmrOptions } from "vite";
|
|
30
38
|
import type { ViteDevServer } from "vite";
|
|
@@ -33,6 +41,23 @@ const tracer = getTracer();
|
|
|
33
41
|
|
|
34
42
|
export const RESTART_EXIT_CODE = 98;
|
|
35
43
|
|
|
44
|
+
function getJwksUri(): string {
|
|
45
|
+
let isProd: boolean;
|
|
46
|
+
try {
|
|
47
|
+
const superblocksBaseUrl = new URL(process.env.SUPERBLOCKS_BASE_URL || "");
|
|
48
|
+
isProd = [
|
|
49
|
+
"app.superblocks.com",
|
|
50
|
+
"app.superblockshq.com",
|
|
51
|
+
"eu.superblocks.com",
|
|
52
|
+
].includes(superblocksBaseUrl.hostname);
|
|
53
|
+
} catch {
|
|
54
|
+
isProd = false;
|
|
55
|
+
}
|
|
56
|
+
return isProd
|
|
57
|
+
? "https://prod-cdn.superblocks.com/.well-known/jwks.json"
|
|
58
|
+
: "https://staging-cdn.superblocks.com/.well-known/jwks.json";
|
|
59
|
+
}
|
|
60
|
+
|
|
36
61
|
interface CreateDevServerOptions {
|
|
37
62
|
root: string;
|
|
38
63
|
mode: "development" | "production";
|
|
@@ -184,13 +209,95 @@ export async function createDevServer({
|
|
|
184
209
|
});
|
|
185
210
|
});
|
|
186
211
|
|
|
212
|
+
const jwtVerifier = new JwtVerifier({
|
|
213
|
+
jwksUri: getJwksUri(),
|
|
214
|
+
cache: true,
|
|
215
|
+
cacheMaxAge: 24 * 60 * 60 * 1000, // 24 hours
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const checkAuthorization: FileSyncPluginParams["checkAuthorization"] = async (
|
|
219
|
+
authorization,
|
|
220
|
+
) => {
|
|
221
|
+
if (!authorization) {
|
|
222
|
+
logger.error("Missing authorization header");
|
|
223
|
+
return {
|
|
224
|
+
success: false,
|
|
225
|
+
status: 401,
|
|
226
|
+
error: "Missing authorization header",
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
if (!authorization.startsWith("Bearer ")) {
|
|
230
|
+
logger.error("Invalid authorization header");
|
|
231
|
+
return {
|
|
232
|
+
success: false,
|
|
233
|
+
status: 401,
|
|
234
|
+
error: "Invalid authorization header",
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const token = authorization.substring("Bearer ".length);
|
|
239
|
+
if (!token) {
|
|
240
|
+
logger.error("Missing token in authorization header");
|
|
241
|
+
return {
|
|
242
|
+
success: false,
|
|
243
|
+
status: 401,
|
|
244
|
+
error: "Missing token in header",
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
try {
|
|
249
|
+
const payload = (await jwtVerifier.verify<{ scope: string }>(
|
|
250
|
+
token,
|
|
251
|
+
)) as SuperblocksScopedJwtPayload;
|
|
252
|
+
|
|
253
|
+
const scopes = payload.scope?.split(" ") ?? [];
|
|
254
|
+
if (!scopes.includes(EDIT_APPLICATION_SCOPE)) {
|
|
255
|
+
logger.error(`Token does not have ${EDIT_APPLICATION_SCOPE} scope`);
|
|
256
|
+
return {
|
|
257
|
+
success: false,
|
|
258
|
+
status: 403,
|
|
259
|
+
error: "Insufficient token scope",
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (payload.app_id !== resourceConfig.id) {
|
|
264
|
+
logger.error(
|
|
265
|
+
`Token application ID mismatch, expected ${resourceConfig.id}, received ${payload.app_id}`,
|
|
266
|
+
);
|
|
267
|
+
return {
|
|
268
|
+
success: false,
|
|
269
|
+
status: 403,
|
|
270
|
+
error: "Invalid token claims.",
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return { success: true };
|
|
275
|
+
} catch (err) {
|
|
276
|
+
logger.error("JWT verification failed", getErrorMeta(err as Error));
|
|
277
|
+
return {
|
|
278
|
+
success: false,
|
|
279
|
+
status: 401,
|
|
280
|
+
error: "Invalid or expired token",
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const authHandler: RequestHandler = async (req, res, next) => {
|
|
286
|
+
const result = await checkAuthorization(req.headers.authorization);
|
|
287
|
+
if (result.success) {
|
|
288
|
+
return next();
|
|
289
|
+
} else {
|
|
290
|
+
res.status(result.status).send(JSON.stringify({ error: result.error }));
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
187
294
|
app.get("/_sb_health", async (_req, res) => {
|
|
188
295
|
res.setHeader("Content-Type", "application/json");
|
|
189
296
|
res.send(JSON.stringify(healthResponse));
|
|
190
297
|
});
|
|
191
298
|
|
|
192
299
|
// Attach the vite server to the express app
|
|
193
|
-
app.get("/_sb_connect", async (req, res) => {
|
|
300
|
+
app.get("/_sb_connect", authHandler, async (req, res) => {
|
|
194
301
|
res.setHeader("Content-Type", "application/json");
|
|
195
302
|
|
|
196
303
|
if (process.env.SUPERBLOCKS_CLI_ENV !== "local") {
|
|
@@ -246,11 +353,11 @@ export async function createDevServer({
|
|
|
246
353
|
syncService,
|
|
247
354
|
lockService,
|
|
248
355
|
aiService,
|
|
356
|
+
checkAuthorization,
|
|
249
357
|
logger: loggerOverride,
|
|
250
358
|
httpServer,
|
|
251
359
|
features: {
|
|
252
360
|
enableSessionRecording: featureFlags?.enableSessionRecording() ?? false,
|
|
253
|
-
chakraComponents: featureFlags?.isChakraComponentsEnabled() ?? false,
|
|
254
361
|
},
|
|
255
362
|
}).then(
|
|
256
363
|
(result) => {
|
|
@@ -266,7 +373,7 @@ export async function createDevServer({
|
|
|
266
373
|
);
|
|
267
374
|
});
|
|
268
375
|
|
|
269
|
-
app.post("/_sb_disconnect", async (req, res) => {
|
|
376
|
+
app.post("/_sb_disconnect", authHandler, async (req, res) => {
|
|
270
377
|
logger.info("Disconnecting dev server...");
|
|
271
378
|
const { initiatedByEmail, switchingTo, isRestart } = req.body;
|
|
272
379
|
// TODO(code-mode): should this include any validation checks, such as getting a token?
|
|
@@ -311,7 +418,7 @@ export async function createDevServer({
|
|
|
311
418
|
}
|
|
312
419
|
});
|
|
313
420
|
|
|
314
|
-
app.get("/_sb_status", async (_req, res) => {
|
|
421
|
+
app.get("/_sb_status", authHandler, async (_req, res) => {
|
|
315
422
|
res.setHeader("Content-Type", "application/json");
|
|
316
423
|
if (lockService?.isLocked) {
|
|
317
424
|
res.send({
|
|
@@ -368,14 +475,15 @@ async function startVite({
|
|
|
368
475
|
syncService,
|
|
369
476
|
lockService,
|
|
370
477
|
aiService,
|
|
478
|
+
checkAuthorization,
|
|
371
479
|
logger: loggerOverride,
|
|
372
480
|
features,
|
|
373
481
|
}: CreateDevServerOptions & {
|
|
374
482
|
app: express.Express;
|
|
375
483
|
httpServer: http.Server;
|
|
484
|
+
checkAuthorization: FileSyncPluginParams["checkAuthorization"];
|
|
376
485
|
features: {
|
|
377
486
|
enableSessionRecording: boolean;
|
|
378
|
-
chakraComponents: boolean;
|
|
379
487
|
};
|
|
380
488
|
}): Promise<{
|
|
381
489
|
viteServer: ViteDevServer;
|
|
@@ -442,6 +550,7 @@ async function startVite({
|
|
|
442
550
|
lockService,
|
|
443
551
|
aiService,
|
|
444
552
|
httpServer,
|
|
553
|
+
checkAuthorization,
|
|
445
554
|
tracer,
|
|
446
555
|
logger,
|
|
447
556
|
features,
|
|
@@ -487,6 +596,8 @@ async function startVite({
|
|
|
487
596
|
react({
|
|
488
597
|
babel: {
|
|
489
598
|
plugins: [
|
|
599
|
+
// We will bring this back later
|
|
600
|
+
// "babel-plugin-react-compiler",
|
|
490
601
|
[
|
|
491
602
|
import.meta.resolve("@babel/plugin-proposal-decorators"),
|
|
492
603
|
{
|
package/src/flag.ts
CHANGED
|
@@ -27,10 +27,6 @@ export class FeatureFlags {
|
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
isChakraComponentsEnabled(): boolean {
|
|
31
|
-
return this.flags["ui.chakra-components"] ?? false;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
30
|
enableSessionRecording(): boolean {
|
|
35
31
|
return this.flags["ui.code-mode.enable-session-recording"] ?? false;
|
|
36
32
|
}
|
package/src/types/common.ts
CHANGED
|
@@ -12,7 +12,6 @@ export interface FlagBootstrap {
|
|
|
12
12
|
"superblocks.git.split.large.steps.enabled"?: boolean;
|
|
13
13
|
"superblocks.git.split.large.steps.new.enabled"?: boolean;
|
|
14
14
|
"superblocks.git.split.large.step.lines"?: number;
|
|
15
|
-
"ui.chakra-components"?: boolean;
|
|
16
15
|
"ui.code-mode.enable-session-recording"?: boolean;
|
|
17
16
|
"superblocks.dev-server.inactivity-timeout.cloud"?: number;
|
|
18
17
|
"superblocks.dev-server.inactivity-timeout.local"?: number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const EDIT_APPLICATION_SCOPE = "apps:update";
|
|
2
|
+
|
|
3
|
+
// NOTE: The primary definition of the type is in `packages/server/src/middleware/auth/superblocksJwt.ts`
|
|
4
|
+
// This is a subset of the type that is used in the CLI.
|
|
5
|
+
export interface SuperblocksScopedJwtPayload {
|
|
6
|
+
scope?: string;
|
|
7
|
+
org_id?: string;
|
|
8
|
+
app_id?: string;
|
|
9
|
+
dir_hash?: string;
|
|
10
|
+
user_email: string;
|
|
11
|
+
user_type: string;
|
|
12
|
+
}
|
|
@@ -5,6 +5,8 @@ export interface JwtPayload {
|
|
|
5
5
|
user_email: string;
|
|
6
6
|
scope: string;
|
|
7
7
|
exp?: number;
|
|
8
|
+
app_id?: string;
|
|
9
|
+
org_id?: string;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
// Token information interface
|
|
@@ -13,6 +15,8 @@ interface TokenInfoSuccess {
|
|
|
13
15
|
userEmail: string;
|
|
14
16
|
scope: string;
|
|
15
17
|
expiresAt?: Date;
|
|
18
|
+
appId?: string;
|
|
19
|
+
orgId?: string;
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
interface TokenInfoFailure {
|
|
@@ -33,6 +37,8 @@ export function tryDecodeJwtToken(token: string): TokenInfo {
|
|
|
33
37
|
userEmail: decoded.user_email,
|
|
34
38
|
scope: decoded.scope,
|
|
35
39
|
expiresAt: decoded.exp ? new Date(decoded.exp * 1000) : undefined,
|
|
40
|
+
appId: decoded.app_id,
|
|
41
|
+
orgId: decoded.org_id,
|
|
36
42
|
};
|
|
37
43
|
} catch {
|
|
38
44
|
// Not a valid JWT, assume it is an API key
|
|
@@ -2,18 +2,11 @@ import path from "node:path";
|
|
|
2
2
|
import { transformFromAstSync } from "@babel/core";
|
|
3
3
|
import { parse } from "@babel/parser";
|
|
4
4
|
import tsTransformPlugin from "@babel/plugin-transform-typescript";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
generateRootSource,
|
|
8
|
-
} from "@superblocksteam/vite-plugin-file-sync";
|
|
9
|
-
import { yellow, red } from "colorette";
|
|
10
|
-
import fs from "fs-extra";
|
|
5
|
+
import { supplementElementIds } from "@superblocksteam/vite-plugin-file-sync";
|
|
6
|
+
import { red, yellow } from "colorette";
|
|
11
7
|
import { createLogger } from "vite";
|
|
12
8
|
import { getLogger } from "./telemetry/logging.js";
|
|
13
|
-
import type {
|
|
14
|
-
import type { Logger, Plugin } from "vite";
|
|
15
|
-
|
|
16
|
-
const routesFileBaseName = "routes.json";
|
|
9
|
+
import type { Plugin } from "vite";
|
|
17
10
|
|
|
18
11
|
/**
|
|
19
12
|
* Creates a Vite plugin that injects Superblocks IDs into the application.
|
|
@@ -43,8 +36,6 @@ export async function injectSuperblocksIdsPlugin(root: string) {
|
|
|
43
36
|
|
|
44
37
|
viteLogger.clearScreen = () => {};
|
|
45
38
|
|
|
46
|
-
const routes: HydratedRoute[] = await getRoutes(root, viteLogger);
|
|
47
|
-
|
|
48
39
|
return {
|
|
49
40
|
name: "sb-inject-superblocks-ids",
|
|
50
41
|
enforce: "pre",
|
|
@@ -59,14 +50,6 @@ export async function injectSuperblocksIdsPlugin(root: string) {
|
|
|
59
50
|
return null;
|
|
60
51
|
}
|
|
61
52
|
|
|
62
|
-
const relativePath = path.relative(root, id);
|
|
63
|
-
if (relativePath === "root.tsx") {
|
|
64
|
-
return {
|
|
65
|
-
code: generateRootSource(code, routes),
|
|
66
|
-
map: null,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
53
|
const ast = parse(code, {
|
|
71
54
|
sourceType: "module",
|
|
72
55
|
sourceFilename: id,
|
|
@@ -92,29 +75,5 @@ export async function injectSuperblocksIdsPlugin(root: string) {
|
|
|
92
75
|
map: result?.map ?? null,
|
|
93
76
|
};
|
|
94
77
|
},
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async function getRoutes(root: string, logger: Logger) {
|
|
99
|
-
const routesFile = path.join(root, routesFileBaseName);
|
|
100
|
-
if (!(await fs.pathExists(routesFile))) {
|
|
101
|
-
logger.warn(`routes file not found at expected location: ${routesFile}`);
|
|
102
|
-
return [];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
const routesData = await fs.readFile(routesFile, "utf-8");
|
|
107
|
-
const routes = JSON.parse(routesData) as Record<string, { file: string }>;
|
|
108
|
-
|
|
109
|
-
return Object.entries(routes).map(([path, { file }]) => ({
|
|
110
|
-
path,
|
|
111
|
-
component: file,
|
|
112
|
-
}));
|
|
113
|
-
} catch (err) {
|
|
114
|
-
logger.error(
|
|
115
|
-
`error reading routes file: ${routesFile}. error=[${JSON.stringify(err)}]`,
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return [];
|
|
78
|
+
} satisfies Plugin;
|
|
120
79
|
}
|
|
@@ -106,12 +106,14 @@ function convertToIndividualImports(
|
|
|
106
106
|
* - CheckIcon -> check
|
|
107
107
|
* - BluetoothConnectedIcon -> bluetooth-connected
|
|
108
108
|
* - XIcon -> x
|
|
109
|
+
* - XCircleIcon -> x-circle
|
|
109
110
|
* - Loader2Icon -> loader-2
|
|
110
111
|
* - Grid2X2CheckIcon -> grid-2-x-2-check
|
|
111
112
|
*/
|
|
112
113
|
function convertToKebabCase(str: string): string {
|
|
113
114
|
return str
|
|
114
115
|
.replace("Icon", "")
|
|
116
|
+
.replace(/([A-Z])([A-Z][a-z])/g, "$1-$2") // Handle consecutive uppercase letters (e.g., XCircle -> X-Circle)
|
|
115
117
|
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
116
118
|
.replace(/([a-zA-Z])([0-9])/g, "$1-$2")
|
|
117
119
|
.toLowerCase();
|
package/tsconfig.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"declaration": true,
|
|
4
3
|
"importHelpers": true,
|
|
5
4
|
"module": "NodeNext",
|
|
6
5
|
"outDir": "dist",
|
|
@@ -9,10 +8,11 @@
|
|
|
9
8
|
"target": "es2022",
|
|
10
9
|
"lib": ["es2022"],
|
|
11
10
|
"sourceMap": true,
|
|
11
|
+
"declaration": true,
|
|
12
12
|
"declarationMap": true,
|
|
13
13
|
"esModuleInterop": true,
|
|
14
14
|
"skipLibCheck": true,
|
|
15
|
-
"
|
|
15
|
+
"incremental": true,
|
|
16
16
|
"resolveJsonModule": true
|
|
17
17
|
},
|
|
18
18
|
"include": ["src/**/*.ts", "src/**/*.mts"],
|