@hubspot/app-connect-sdk 1.0.0-alpha.5 → 1.0.0-alpha.7
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-format$colon$check.log +4 -0
- package/.turbo/turbo-lint.log +2 -0
- package/.turbo/turbo-test.log +78 -0
- package/.turbo/turbo-tsc.log +2 -1
- package/.turbo/turbo-tsdown.log +524 -523
- package/build/tsconfig.server.tsbuildinfo +1 -1
- package/dist/server/lovable/hubspot-connect/run-hubspot-connect-lovable-server.js +2 -4
- package/dist/server/lovable/hubspot-connect/run-hubspot-connect-lovable-server.js.map +1 -1
- package/dist/server/proxy.js.map +1 -1
- package/package.json +1 -1
- package/src/server/lovable/hubspot-connect/run-hubspot-connect-lovable-server.ts +2 -3
- package/src/server/proxy.ts +4 -1
|
@@ -9,7 +9,7 @@ const HUBSPOT_CONNECT_BASE_PATH = "/functions/v1/hubspot-connect";
|
|
|
9
9
|
function runHubSpotConnectLovableServer(options) {
|
|
10
10
|
const { appKeys, cimdClientMetadata } = options;
|
|
11
11
|
const hubspotConnectEnv = loadHubSpotConnectRoutesEnv();
|
|
12
|
-
|
|
12
|
+
return Deno.serve(serveOptions, (request) => {
|
|
13
13
|
const app = new Hono();
|
|
14
14
|
registerHubSpotConnectRoutes({
|
|
15
15
|
app: app.basePath(HUBSPOT_CONNECT_BASE_PATH),
|
|
@@ -19,9 +19,7 @@ function runHubSpotConnectLovableServer(options) {
|
|
|
19
19
|
cimdClientMetadata
|
|
20
20
|
});
|
|
21
21
|
return app.fetch(request);
|
|
22
|
-
});
|
|
23
|
-
console.log(`[hubspot-connect] Listening on ${result.addr.port}`);
|
|
24
|
-
return Promise.resolve();
|
|
22
|
+
}).finished;
|
|
25
23
|
}
|
|
26
24
|
//#endregion
|
|
27
25
|
export { runHubSpotConnectLovableServer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-hubspot-connect-lovable-server.js","names":[],"sources":["../../../../src/server/lovable/hubspot-connect/run-hubspot-connect-lovable-server.ts"],"sourcesContent":["import { Hono } from 'hono';\n\nimport type { SecureStartContext } from '../../deno/start.ts';\nimport type { HubSpotConnectCimdClientMetadata } from '../../hono/hubspot-connect-routes/cimd-client-metadata-types.ts';\nimport {\n loadHubSpotConnectRoutesEnv,\n registerHubSpotConnectRoutes,\n} from '../../hono/index.ts';\n\nconst PORT = Deno.env.get('PORT');\nconst serveOptions =\n typeof PORT === 'string' ? { port: parseInt(PORT, 10) } : {};\nconst HUBSPOT_CONNECT_BASE_PATH = '/functions/v1/hubspot-connect';\n\nexport interface RunHubSpotConnectLovableServerOptions extends SecureStartContext {\n cimdClientMetadata: HubSpotConnectCimdClientMetadata;\n}\n\nexport function runHubSpotConnectLovableServer(\n options: RunHubSpotConnectLovableServerOptions\n): Promise<void> {\n const { appKeys, cimdClientMetadata } = options;\n const hubspotConnectEnv = loadHubSpotConnectRoutesEnv();\n const
|
|
1
|
+
{"version":3,"file":"run-hubspot-connect-lovable-server.js","names":[],"sources":["../../../../src/server/lovable/hubspot-connect/run-hubspot-connect-lovable-server.ts"],"sourcesContent":["import { Hono } from 'hono';\n\nimport type { SecureStartContext } from '../../deno/start.ts';\nimport type { HubSpotConnectCimdClientMetadata } from '../../hono/hubspot-connect-routes/cimd-client-metadata-types.ts';\nimport {\n loadHubSpotConnectRoutesEnv,\n registerHubSpotConnectRoutes,\n} from '../../hono/index.ts';\n\nconst PORT = Deno.env.get('PORT');\nconst serveOptions =\n typeof PORT === 'string' ? { port: parseInt(PORT, 10) } : {};\nconst HUBSPOT_CONNECT_BASE_PATH = '/functions/v1/hubspot-connect';\n\nexport interface RunHubSpotConnectLovableServerOptions extends SecureStartContext {\n cimdClientMetadata: HubSpotConnectCimdClientMetadata;\n}\n\nexport function runHubSpotConnectLovableServer(\n options: RunHubSpotConnectLovableServerOptions\n): Promise<void> {\n const { appKeys, cimdClientMetadata } = options;\n const hubspotConnectEnv = loadHubSpotConnectRoutesEnv();\n const server = Deno.serve(serveOptions, (request) => {\n const app = new Hono();\n\n registerHubSpotConnectRoutes({\n app: app.basePath(HUBSPOT_CONNECT_BASE_PATH),\n appKeys,\n basePath: HUBSPOT_CONNECT_BASE_PATH,\n hubspotConnectEnv,\n cimdClientMetadata,\n });\n\n return app.fetch(request);\n });\n\n return server.finished;\n}\n"],"mappings":";;;;;AASA,MAAM,OAAO,KAAK,IAAI,IAAI,OAAO;AACjC,MAAM,eACJ,OAAO,SAAS,WAAW,EAAE,MAAM,SAAS,MAAM,GAAG,EAAE,GAAG,EAAE;AAC9D,MAAM,4BAA4B;AAMlC,SAAgB,+BACd,SACe;CACf,MAAM,EAAE,SAAS,uBAAuB;CACxC,MAAM,oBAAoB,6BAA6B;CAevD,OAde,KAAK,MAAM,eAAe,YAAY;EACnD,MAAM,MAAM,IAAI,MAAM;EAEtB,6BAA6B;GAC3B,KAAK,IAAI,SAAS,0BAA0B;GAC5C;GACA,UAAU;GACV;GACA;GACD,CAAC;EAEF,OAAO,IAAI,MAAM,QAAQ;GAGd,CAAC"}
|
package/dist/server/proxy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","names":[],"sources":["../../src/server/proxy.ts"],"sourcesContent":["import { noopLogger, type Logger } from '../shared/logger.ts';\nimport {\n type AppKeys,\n type HubSpotProxy,\n type HubSpotProxyRequest,\n type UserCredentials,\n} from './types.ts';\nimport { sha256base64url } from './utils/crypto-utils.ts';\nimport { signDpopProof } from './utils/dpop-utils.ts';\nimport {
|
|
1
|
+
{"version":3,"file":"proxy.js","names":[],"sources":["../../src/server/proxy.ts"],"sourcesContent":["import { noopLogger, type Logger } from '../shared/logger.ts';\nimport {\n type AppKeys,\n type HubSpotProxy,\n type HubSpotProxyRequest,\n type UserCredentials,\n} from './types.ts';\nimport { sha256base64url } from './utils/crypto-utils.ts';\nimport { signDpopProof } from './utils/dpop-utils.ts';\nimport {\n getHubSpotApiOrigin,\n isHubspotDpopEnabled,\n} from './utils/env-utils.ts';\n\nconst hubSpotApiOrigin = getHubSpotApiOrigin();\n\n/**\n * Options accepted by {@link createHubSpotProxy}.\n */\nexport interface CreateHubSpotProxyOptions {\n /**\n * User session context from the incoming browser request.\n */\n userCredentials: UserCredentials;\n\n /**\n * Imported app keys from `secureStart`, or `null` when CIMD and DPoP\n * are both disabled.\n */\n appKeys: AppKeys | null;\n /** Optional logger. Defaults to a no-op logger. */\n logger?: Logger;\n}\n\nconst notAuthenticated: HubSpotProxy = {\n authenticated: false,\n fetch: async (): Promise<Response> => {\n return new Response(null, {\n status: 401,\n statusText: 'Unauthorized',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n },\n};\n\nconst EMPTY_HEADERS = {};\n\nexport function createHubSpotProxy(\n options: CreateHubSpotProxyOptions\n): HubSpotProxy {\n const { userCredentials, appKeys, logger = noopLogger } = options;\n\n if (isHubspotDpopEnabled() && appKeys === null) {\n throw new Error(\n 'createHubSpotProxy: appKeys is required when HUBSPOT_DPOP_ENABLED is true'\n );\n }\n\n const { accessToken, sessionId } = userCredentials;\n\n if (!accessToken || !sessionId) {\n logger.debug(\n 'createHubSpotProxy: returning unauthenticated proxy (missing cookies)'\n );\n return notAuthenticated;\n }\n\n async function proxyFetch(request: HubSpotProxyRequest): Promise<Response> {\n const { path, method = 'GET', headers = EMPTY_HEADERS, body } = request;\n\n const targetUrl = `${hubSpotApiOrigin}${path}`;\n const useDpop = isHubspotDpopEnabled();\n\n let authorizationHeaders: Record<string, string>;\n if (useDpop) {\n const ath = await sha256base64url(accessToken!);\n const sid = await sha256base64url(sessionId!);\n const dpopProof = await signDpopProof({\n appKeys: appKeys!,\n claims: {\n htm: method,\n htu: targetUrl,\n jti: crypto.randomUUID(),\n iat: Math.floor(Date.now() / 1000),\n ath,\n sid,\n },\n });\n authorizationHeaders = {\n Authorization: `DPoP ${accessToken}`,\n DPoP: dpopProof,\n };\n } else {\n authorizationHeaders = {\n Authorization: `Bearer ${accessToken}`,\n };\n }\n\n const finalHeaders = { ...headers, ...authorizationHeaders };\n\n const requestInit: RequestInit = {\n headers: finalHeaders,\n method,\n };\n\n if (body != null) {\n requestInit.body = body;\n }\n\n return fetch(targetUrl, requestInit);\n }\n\n return {\n authenticated: true,\n fetch: proxyFetch,\n };\n}\n"],"mappings":";;;;;AAcA,MAAM,mBAAmB,qBAAqB;AAoB9C,MAAM,mBAAiC;CACrC,eAAe;CACf,OAAO,YAA+B;EACpC,OAAO,IAAI,SAAS,MAAM;GACxB,QAAQ;GACR,YAAY;GACZ,SAAS,EACP,gBAAgB,oBACjB;GACF,CAAC;;CAEL;AAED,MAAM,gBAAgB,EAAE;AAExB,SAAgB,mBACd,SACc;CACd,MAAM,EAAE,iBAAiB,SAAS,SAAS,eAAe;CAE1D,IAAI,sBAAsB,IAAI,YAAY,MACxC,MAAM,IAAI,MACR,4EACD;CAGH,MAAM,EAAE,aAAa,cAAc;CAEnC,IAAI,CAAC,eAAe,CAAC,WAAW;EAC9B,OAAO,MACL,wEACD;EACD,OAAO;;CAGT,eAAe,WAAW,SAAiD;EACzE,MAAM,EAAE,MAAM,SAAS,OAAO,UAAU,eAAe,SAAS;EAEhE,MAAM,YAAY,GAAG,mBAAmB;EACxC,MAAM,UAAU,sBAAsB;EAEtC,IAAI;EACJ,IAAI,SAAS;GACX,MAAM,MAAM,MAAM,gBAAgB,YAAa;GAC/C,MAAM,MAAM,MAAM,gBAAgB,UAAW;GAC7C,MAAM,YAAY,MAAM,cAAc;IAC3B;IACT,QAAQ;KACN,KAAK;KACL,KAAK;KACL,KAAK,OAAO,YAAY;KACxB,KAAK,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;KAClC;KACA;KACD;IACF,CAAC;GACF,uBAAuB;IACrB,eAAe,QAAQ;IACvB,MAAM;IACP;SAED,uBAAuB,EACrB,eAAe,UAAU,eAC1B;EAKH,MAAM,cAA2B;GAC/B,SAAS;IAHY,GAAG;IAAS,GAAG;IAGf;GACrB;GACD;EAED,IAAI,QAAQ,MACV,YAAY,OAAO;EAGrB,OAAO,MAAM,WAAW,YAAY;;CAGtC,OAAO;EACL,eAAe;EACf,OAAO;EACR"}
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ export function runHubSpotConnectLovableServer(
|
|
|
21
21
|
): Promise<void> {
|
|
22
22
|
const { appKeys, cimdClientMetadata } = options;
|
|
23
23
|
const hubspotConnectEnv = loadHubSpotConnectRoutesEnv();
|
|
24
|
-
const
|
|
24
|
+
const server = Deno.serve(serveOptions, (request) => {
|
|
25
25
|
const app = new Hono();
|
|
26
26
|
|
|
27
27
|
registerHubSpotConnectRoutes({
|
|
@@ -35,6 +35,5 @@ export function runHubSpotConnectLovableServer(
|
|
|
35
35
|
return app.fetch(request);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
return Promise.resolve();
|
|
38
|
+
return server.finished;
|
|
40
39
|
}
|
package/src/server/proxy.ts
CHANGED
|
@@ -7,7 +7,10 @@ import {
|
|
|
7
7
|
} from './types.ts';
|
|
8
8
|
import { sha256base64url } from './utils/crypto-utils.ts';
|
|
9
9
|
import { signDpopProof } from './utils/dpop-utils.ts';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
getHubSpotApiOrigin,
|
|
12
|
+
isHubspotDpopEnabled,
|
|
13
|
+
} from './utils/env-utils.ts';
|
|
11
14
|
|
|
12
15
|
const hubSpotApiOrigin = getHubSpotApiOrigin();
|
|
13
16
|
|