@squadbase/vite-server 0.0.1-build-18 → 0.0.1-build-19
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/index.js +46 -10
- package/dist/index.js +61 -25
- package/dist/main.js +48 -12
- package/dist/vite-plugin.js +46 -10
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -16970,6 +16970,10 @@ var connectors = {
|
|
|
16970
16970
|
}
|
|
16971
16971
|
};
|
|
16972
16972
|
|
|
16973
|
+
// src/connector-client/registry.ts
|
|
16974
|
+
import { getContext } from "hono/context-storage";
|
|
16975
|
+
import { getCookie } from "hono/cookie";
|
|
16976
|
+
|
|
16973
16977
|
// src/connector-client/env.ts
|
|
16974
16978
|
function resolveEnvVar(entry, key, connectionId) {
|
|
16975
16979
|
const envVarName = entry.envVars[key];
|
|
@@ -17057,25 +17061,57 @@ function createConnectorRegistry() {
|
|
|
17057
17061
|
}
|
|
17058
17062
|
return { getQuery: getQuery2, loadConnections: loadConnections2, reloadEnvFile: reloadEnvFile2, watchConnectionsFile: watchConnectionsFile2 };
|
|
17059
17063
|
}
|
|
17064
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
17065
|
+
var PREVIEW_SESSION_COOKIE_NAME = "squadbase-preview-session";
|
|
17066
|
+
function resolveProxyUrl(connectionId) {
|
|
17067
|
+
const connectionPath = `/_sqcore/connections/${connectionId}/request`;
|
|
17068
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
17069
|
+
if (sandboxId) {
|
|
17070
|
+
const baseDomain2 = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
17071
|
+
return `https://${sandboxId}.${baseDomain2}${connectionPath}`;
|
|
17072
|
+
}
|
|
17073
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
17074
|
+
if (!projectId) {
|
|
17075
|
+
throw new Error(
|
|
17076
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17077
|
+
);
|
|
17078
|
+
}
|
|
17079
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
17080
|
+
return `https://${projectId}.${baseDomain}${connectionPath}`;
|
|
17081
|
+
}
|
|
17082
|
+
function resolveAuthHeaders() {
|
|
17083
|
+
const machineCredential = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
17084
|
+
if (machineCredential) {
|
|
17085
|
+
return { Authorization: `Bearer ${machineCredential}` };
|
|
17086
|
+
}
|
|
17087
|
+
const c = getContext();
|
|
17088
|
+
const cookies = getCookie(c);
|
|
17089
|
+
const previewSession = cookies[PREVIEW_SESSION_COOKIE_NAME];
|
|
17090
|
+
if (previewSession) {
|
|
17091
|
+
return {
|
|
17092
|
+
Cookie: `${PREVIEW_SESSION_COOKIE_NAME}=${previewSession}`
|
|
17093
|
+
};
|
|
17094
|
+
}
|
|
17095
|
+
const appSession = cookies[APP_SESSION_COOKIE_NAME];
|
|
17096
|
+
if (appSession) {
|
|
17097
|
+
return { Authorization: `Bearer ${appSession}` };
|
|
17098
|
+
}
|
|
17099
|
+
throw new Error(
|
|
17100
|
+
"No authentication method available for connection proxy."
|
|
17101
|
+
);
|
|
17102
|
+
}
|
|
17060
17103
|
function createProxyFetch(connectionId) {
|
|
17061
17104
|
return async (input, init) => {
|
|
17062
|
-
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
17063
|
-
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
17064
|
-
if (!token || !sandboxId) {
|
|
17065
|
-
throw new Error(
|
|
17066
|
-
"OAuth proxy requires INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL and INTERNAL_SQUADBASE_SANDBOX_ID"
|
|
17067
|
-
);
|
|
17068
|
-
}
|
|
17069
17105
|
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17070
17106
|
const originalMethod = init?.method ?? "GET";
|
|
17071
17107
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
17072
|
-
const
|
|
17073
|
-
const
|
|
17108
|
+
const proxyUrl = resolveProxyUrl(connectionId);
|
|
17109
|
+
const authHeaders = resolveAuthHeaders();
|
|
17074
17110
|
return fetch(proxyUrl, {
|
|
17075
17111
|
method: "POST",
|
|
17076
17112
|
headers: {
|
|
17077
17113
|
"Content-Type": "application/json",
|
|
17078
|
-
|
|
17114
|
+
...authHeaders
|
|
17079
17115
|
},
|
|
17080
17116
|
body: JSON.stringify({
|
|
17081
17117
|
url: originalUrl,
|
package/dist/index.js
CHANGED
|
@@ -16905,6 +16905,10 @@ var connectors = {
|
|
|
16905
16905
|
}
|
|
16906
16906
|
};
|
|
16907
16907
|
|
|
16908
|
+
// src/connector-client/registry.ts
|
|
16909
|
+
import { getContext } from "hono/context-storage";
|
|
16910
|
+
import { getCookie } from "hono/cookie";
|
|
16911
|
+
|
|
16908
16912
|
// src/connector-client/env.ts
|
|
16909
16913
|
function resolveEnvVar(entry, key, connectionId) {
|
|
16910
16914
|
const envVarName = entry.envVars[key];
|
|
@@ -16992,25 +16996,57 @@ function createConnectorRegistry() {
|
|
|
16992
16996
|
}
|
|
16993
16997
|
return { getQuery: getQuery2, loadConnections: loadConnections2, reloadEnvFile: reloadEnvFile2, watchConnectionsFile: watchConnectionsFile2 };
|
|
16994
16998
|
}
|
|
16999
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
17000
|
+
var PREVIEW_SESSION_COOKIE_NAME = "squadbase-preview-session";
|
|
17001
|
+
function resolveProxyUrl(connectionId) {
|
|
17002
|
+
const connectionPath = `/_sqcore/connections/${connectionId}/request`;
|
|
17003
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
17004
|
+
if (sandboxId) {
|
|
17005
|
+
const baseDomain2 = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
17006
|
+
return `https://${sandboxId}.${baseDomain2}${connectionPath}`;
|
|
17007
|
+
}
|
|
17008
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
17009
|
+
if (!projectId) {
|
|
17010
|
+
throw new Error(
|
|
17011
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17012
|
+
);
|
|
17013
|
+
}
|
|
17014
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
17015
|
+
return `https://${projectId}.${baseDomain}${connectionPath}`;
|
|
17016
|
+
}
|
|
17017
|
+
function resolveAuthHeaders() {
|
|
17018
|
+
const machineCredential = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
17019
|
+
if (machineCredential) {
|
|
17020
|
+
return { Authorization: `Bearer ${machineCredential}` };
|
|
17021
|
+
}
|
|
17022
|
+
const c = getContext();
|
|
17023
|
+
const cookies = getCookie(c);
|
|
17024
|
+
const previewSession = cookies[PREVIEW_SESSION_COOKIE_NAME];
|
|
17025
|
+
if (previewSession) {
|
|
17026
|
+
return {
|
|
17027
|
+
Cookie: `${PREVIEW_SESSION_COOKIE_NAME}=${previewSession}`
|
|
17028
|
+
};
|
|
17029
|
+
}
|
|
17030
|
+
const appSession = cookies[APP_SESSION_COOKIE_NAME];
|
|
17031
|
+
if (appSession) {
|
|
17032
|
+
return { Authorization: `Bearer ${appSession}` };
|
|
17033
|
+
}
|
|
17034
|
+
throw new Error(
|
|
17035
|
+
"No authentication method available for connection proxy."
|
|
17036
|
+
);
|
|
17037
|
+
}
|
|
16995
17038
|
function createProxyFetch(connectionId) {
|
|
16996
17039
|
return async (input, init) => {
|
|
16997
|
-
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
16998
|
-
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
16999
|
-
if (!token || !sandboxId) {
|
|
17000
|
-
throw new Error(
|
|
17001
|
-
"OAuth proxy requires INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL and INTERNAL_SQUADBASE_SANDBOX_ID"
|
|
17002
|
-
);
|
|
17003
|
-
}
|
|
17004
17040
|
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17005
17041
|
const originalMethod = init?.method ?? "GET";
|
|
17006
17042
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
17007
|
-
const
|
|
17008
|
-
const
|
|
17043
|
+
const proxyUrl = resolveProxyUrl(connectionId);
|
|
17044
|
+
const authHeaders = resolveAuthHeaders();
|
|
17009
17045
|
return fetch(proxyUrl, {
|
|
17010
17046
|
method: "POST",
|
|
17011
17047
|
headers: {
|
|
17012
17048
|
"Content-Type": "application/json",
|
|
17013
|
-
|
|
17049
|
+
...authHeaders
|
|
17014
17050
|
},
|
|
17015
17051
|
body: JSON.stringify({
|
|
17016
17052
|
url: originalUrl,
|
|
@@ -17855,15 +17891,15 @@ app4.get("/runtime-data", (c) => {
|
|
|
17855
17891
|
var pages_default = app4;
|
|
17856
17892
|
|
|
17857
17893
|
// src/connection.ts
|
|
17858
|
-
import { getContext } from "hono/context-storage";
|
|
17859
|
-
import { getCookie } from "hono/cookie";
|
|
17860
|
-
var
|
|
17861
|
-
var
|
|
17894
|
+
import { getContext as getContext2 } from "hono/context-storage";
|
|
17895
|
+
import { getCookie as getCookie2 } from "hono/cookie";
|
|
17896
|
+
var APP_SESSION_COOKIE_NAME2 = "__Host-squadbase-session";
|
|
17897
|
+
var PREVIEW_SESSION_COOKIE_NAME2 = "squadbase-preview-session";
|
|
17862
17898
|
var APP_BASE_DOMAIN = "squadbase.app";
|
|
17863
17899
|
var PREVIEW_BASE_DOMAIN = "preview.app.squadbase.dev";
|
|
17864
17900
|
var SANDBOX_ID_ENV_NAME = "INTERNAL_SQUADBASE_SANDBOX_ID";
|
|
17865
17901
|
var MACHINE_CREDENTIAL_ENV_NAME = "INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL";
|
|
17866
|
-
function
|
|
17902
|
+
function resolveProxyUrl2(connectionId) {
|
|
17867
17903
|
const connectionPath = `/_sqcore/connections/${connectionId}/request`;
|
|
17868
17904
|
const sandboxId = process.env[SANDBOX_ID_ENV_NAME];
|
|
17869
17905
|
if (sandboxId) {
|
|
@@ -17873,38 +17909,38 @@ function resolveProxyUrl(connectionId) {
|
|
|
17873
17909
|
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
17874
17910
|
if (!projectId) {
|
|
17875
17911
|
throw new Error(
|
|
17876
|
-
"
|
|
17912
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17877
17913
|
);
|
|
17878
17914
|
}
|
|
17879
17915
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? APP_BASE_DOMAIN;
|
|
17880
17916
|
return `https://${projectId}.${baseDomain}${connectionPath}`;
|
|
17881
17917
|
}
|
|
17882
|
-
function
|
|
17918
|
+
function resolveAuthHeaders2() {
|
|
17883
17919
|
const machineCredential = process.env[MACHINE_CREDENTIAL_ENV_NAME];
|
|
17884
17920
|
if (machineCredential) {
|
|
17885
17921
|
return { Authorization: `Bearer ${machineCredential}` };
|
|
17886
17922
|
}
|
|
17887
|
-
const c =
|
|
17888
|
-
const cookies =
|
|
17889
|
-
const previewSession = cookies[
|
|
17923
|
+
const c = getContext2();
|
|
17924
|
+
const cookies = getCookie2(c);
|
|
17925
|
+
const previewSession = cookies[PREVIEW_SESSION_COOKIE_NAME2];
|
|
17890
17926
|
if (previewSession) {
|
|
17891
17927
|
return {
|
|
17892
|
-
Cookie: `${
|
|
17928
|
+
Cookie: `${PREVIEW_SESSION_COOKIE_NAME2}=${previewSession}`
|
|
17893
17929
|
};
|
|
17894
17930
|
}
|
|
17895
|
-
const appSession = cookies[
|
|
17931
|
+
const appSession = cookies[APP_SESSION_COOKIE_NAME2];
|
|
17896
17932
|
if (appSession) {
|
|
17897
17933
|
return { Authorization: `Bearer ${appSession}` };
|
|
17898
17934
|
}
|
|
17899
17935
|
throw new Error(
|
|
17900
|
-
"No authentication method available for connection proxy.
|
|
17936
|
+
"No authentication method available for connection proxy."
|
|
17901
17937
|
);
|
|
17902
17938
|
}
|
|
17903
17939
|
function connection(connectionId) {
|
|
17904
17940
|
return {
|
|
17905
17941
|
async fetch(url, options) {
|
|
17906
|
-
const proxyUrl =
|
|
17907
|
-
const authHeaders =
|
|
17942
|
+
const proxyUrl = resolveProxyUrl2(connectionId);
|
|
17943
|
+
const authHeaders = resolveAuthHeaders2();
|
|
17908
17944
|
return await fetch(proxyUrl, {
|
|
17909
17945
|
method: "POST",
|
|
17910
17946
|
headers: {
|
package/dist/main.js
CHANGED
|
@@ -16905,6 +16905,10 @@ var connectors = {
|
|
|
16905
16905
|
}
|
|
16906
16906
|
};
|
|
16907
16907
|
|
|
16908
|
+
// src/connector-client/registry.ts
|
|
16909
|
+
import { getContext } from "hono/context-storage";
|
|
16910
|
+
import { getCookie } from "hono/cookie";
|
|
16911
|
+
|
|
16908
16912
|
// src/connector-client/env.ts
|
|
16909
16913
|
function resolveEnvVar(entry, key, connectionId) {
|
|
16910
16914
|
const envVarName = entry.envVars[key];
|
|
@@ -16992,25 +16996,57 @@ function createConnectorRegistry() {
|
|
|
16992
16996
|
}
|
|
16993
16997
|
return { getQuery: getQuery2, loadConnections: loadConnections2, reloadEnvFile: reloadEnvFile2, watchConnectionsFile: watchConnectionsFile2 };
|
|
16994
16998
|
}
|
|
16999
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
17000
|
+
var PREVIEW_SESSION_COOKIE_NAME = "squadbase-preview-session";
|
|
17001
|
+
function resolveProxyUrl(connectionId) {
|
|
17002
|
+
const connectionPath = `/_sqcore/connections/${connectionId}/request`;
|
|
17003
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
17004
|
+
if (sandboxId) {
|
|
17005
|
+
const baseDomain2 = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
17006
|
+
return `https://${sandboxId}.${baseDomain2}${connectionPath}`;
|
|
17007
|
+
}
|
|
17008
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
17009
|
+
if (!projectId) {
|
|
17010
|
+
throw new Error(
|
|
17011
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17012
|
+
);
|
|
17013
|
+
}
|
|
17014
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
17015
|
+
return `https://${projectId}.${baseDomain}${connectionPath}`;
|
|
17016
|
+
}
|
|
17017
|
+
function resolveAuthHeaders() {
|
|
17018
|
+
const machineCredential = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
17019
|
+
if (machineCredential) {
|
|
17020
|
+
return { Authorization: `Bearer ${machineCredential}` };
|
|
17021
|
+
}
|
|
17022
|
+
const c = getContext();
|
|
17023
|
+
const cookies = getCookie(c);
|
|
17024
|
+
const previewSession = cookies[PREVIEW_SESSION_COOKIE_NAME];
|
|
17025
|
+
if (previewSession) {
|
|
17026
|
+
return {
|
|
17027
|
+
Cookie: `${PREVIEW_SESSION_COOKIE_NAME}=${previewSession}`
|
|
17028
|
+
};
|
|
17029
|
+
}
|
|
17030
|
+
const appSession = cookies[APP_SESSION_COOKIE_NAME];
|
|
17031
|
+
if (appSession) {
|
|
17032
|
+
return { Authorization: `Bearer ${appSession}` };
|
|
17033
|
+
}
|
|
17034
|
+
throw new Error(
|
|
17035
|
+
"No authentication method available for connection proxy."
|
|
17036
|
+
);
|
|
17037
|
+
}
|
|
16995
17038
|
function createProxyFetch(connectionId) {
|
|
16996
17039
|
return async (input, init) => {
|
|
16997
|
-
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
16998
|
-
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
16999
|
-
if (!token || !sandboxId) {
|
|
17000
|
-
throw new Error(
|
|
17001
|
-
"OAuth proxy requires INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL and INTERNAL_SQUADBASE_SANDBOX_ID"
|
|
17002
|
-
);
|
|
17003
|
-
}
|
|
17004
17040
|
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17005
17041
|
const originalMethod = init?.method ?? "GET";
|
|
17006
17042
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
17007
|
-
const
|
|
17008
|
-
const
|
|
17043
|
+
const proxyUrl = resolveProxyUrl(connectionId);
|
|
17044
|
+
const authHeaders = resolveAuthHeaders();
|
|
17009
17045
|
return fetch(proxyUrl, {
|
|
17010
17046
|
method: "POST",
|
|
17011
17047
|
headers: {
|
|
17012
17048
|
"Content-Type": "application/json",
|
|
17013
|
-
|
|
17049
|
+
...authHeaders
|
|
17014
17050
|
},
|
|
17015
17051
|
body: JSON.stringify({
|
|
17016
17052
|
url: originalUrl,
|
|
@@ -17593,8 +17629,8 @@ app4.get("/runtime-data", (c) => {
|
|
|
17593
17629
|
var pages_default = app4;
|
|
17594
17630
|
|
|
17595
17631
|
// src/connection.ts
|
|
17596
|
-
import { getContext } from "hono/context-storage";
|
|
17597
|
-
import { getCookie } from "hono/cookie";
|
|
17632
|
+
import { getContext as getContext2 } from "hono/context-storage";
|
|
17633
|
+
import { getCookie as getCookie2 } from "hono/cookie";
|
|
17598
17634
|
|
|
17599
17635
|
// src/index.ts
|
|
17600
17636
|
var apiApp = new Hono5();
|
package/dist/vite-plugin.js
CHANGED
|
@@ -16906,6 +16906,10 @@ var connectors = {
|
|
|
16906
16906
|
}
|
|
16907
16907
|
};
|
|
16908
16908
|
|
|
16909
|
+
// src/connector-client/registry.ts
|
|
16910
|
+
import { getContext } from "hono/context-storage";
|
|
16911
|
+
import { getCookie } from "hono/cookie";
|
|
16912
|
+
|
|
16909
16913
|
// src/connector-client/env.ts
|
|
16910
16914
|
function resolveEnvVar(entry, key, connectionId) {
|
|
16911
16915
|
const envVarName = entry.envVars[key];
|
|
@@ -16993,25 +16997,57 @@ function createConnectorRegistry() {
|
|
|
16993
16997
|
}
|
|
16994
16998
|
return { getQuery: getQuery2, loadConnections: loadConnections2, reloadEnvFile: reloadEnvFile2, watchConnectionsFile: watchConnectionsFile2 };
|
|
16995
16999
|
}
|
|
17000
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
17001
|
+
var PREVIEW_SESSION_COOKIE_NAME = "squadbase-preview-session";
|
|
17002
|
+
function resolveProxyUrl(connectionId) {
|
|
17003
|
+
const connectionPath = `/_sqcore/connections/${connectionId}/request`;
|
|
17004
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
17005
|
+
if (sandboxId) {
|
|
17006
|
+
const baseDomain2 = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
17007
|
+
return `https://${sandboxId}.${baseDomain2}${connectionPath}`;
|
|
17008
|
+
}
|
|
17009
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
17010
|
+
if (!projectId) {
|
|
17011
|
+
throw new Error(
|
|
17012
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
17013
|
+
);
|
|
17014
|
+
}
|
|
17015
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
17016
|
+
return `https://${projectId}.${baseDomain}${connectionPath}`;
|
|
17017
|
+
}
|
|
17018
|
+
function resolveAuthHeaders() {
|
|
17019
|
+
const machineCredential = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
17020
|
+
if (machineCredential) {
|
|
17021
|
+
return { Authorization: `Bearer ${machineCredential}` };
|
|
17022
|
+
}
|
|
17023
|
+
const c = getContext();
|
|
17024
|
+
const cookies = getCookie(c);
|
|
17025
|
+
const previewSession = cookies[PREVIEW_SESSION_COOKIE_NAME];
|
|
17026
|
+
if (previewSession) {
|
|
17027
|
+
return {
|
|
17028
|
+
Cookie: `${PREVIEW_SESSION_COOKIE_NAME}=${previewSession}`
|
|
17029
|
+
};
|
|
17030
|
+
}
|
|
17031
|
+
const appSession = cookies[APP_SESSION_COOKIE_NAME];
|
|
17032
|
+
if (appSession) {
|
|
17033
|
+
return { Authorization: `Bearer ${appSession}` };
|
|
17034
|
+
}
|
|
17035
|
+
throw new Error(
|
|
17036
|
+
"No authentication method available for connection proxy."
|
|
17037
|
+
);
|
|
17038
|
+
}
|
|
16996
17039
|
function createProxyFetch(connectionId) {
|
|
16997
17040
|
return async (input, init) => {
|
|
16998
|
-
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
16999
|
-
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
17000
|
-
if (!token || !sandboxId) {
|
|
17001
|
-
throw new Error(
|
|
17002
|
-
"OAuth proxy requires INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL and INTERNAL_SQUADBASE_SANDBOX_ID"
|
|
17003
|
-
);
|
|
17004
|
-
}
|
|
17005
17041
|
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
17006
17042
|
const originalMethod = init?.method ?? "GET";
|
|
17007
17043
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
17008
|
-
const
|
|
17009
|
-
const
|
|
17044
|
+
const proxyUrl = resolveProxyUrl(connectionId);
|
|
17045
|
+
const authHeaders = resolveAuthHeaders();
|
|
17010
17046
|
return fetch(proxyUrl, {
|
|
17011
17047
|
method: "POST",
|
|
17012
17048
|
headers: {
|
|
17013
17049
|
"Content-Type": "application/json",
|
|
17014
|
-
|
|
17050
|
+
...authHeaders
|
|
17015
17051
|
},
|
|
17016
17052
|
body: JSON.stringify({
|
|
17017
17053
|
url: originalUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squadbase/vite-server",
|
|
3
|
-
"version": "0.0.1-build-
|
|
3
|
+
"version": "0.0.1-build-19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@clack/prompts": "^0.9.1",
|
|
57
|
-
"@squadbase/connectors": "^0.0.
|
|
57
|
+
"@squadbase/connectors": "^0.0.4",
|
|
58
58
|
"@types/node": "^22.15.0",
|
|
59
59
|
"@types/pg": "^8.16.0",
|
|
60
60
|
"@types/snowflake-sdk": "^1.6.24",
|