Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(sync): use remote DSS for sync permission tokens in local dev (#2538)
gbirman48932669f7a8
diff --git a/js/app/packages/core/constant/servers.ts b/js/app/packages/core/constant/servers.tsindex 52f9f1bd58..f0d6e869b8 100644--- a/js/app/packages/core/constant/servers.ts+++ b/js/app/packages/core/constant/servers.ts@@ -60,9 +60,8 @@ function selectLocalServers(): Servers {throw new Error(`unknown server name ${name}`);return true;}- const servers = selectedLocalServers- .split(',')- .reduce((acc: Servers, entry: string) => {+ const servers = selectedLocalServers.split(',').reduce(+ (acc: Servers, entry: string) => {// Support "service-name:port" to override the default local portconst [name, portOverride] = entry.split(':') as [string,@@ -78,7 +77,9 @@ function selectLocalServers(): Servers {}console.log(`Using local server ${name}: ${acc[name]}`);return acc;- }, serverHostRemote);+ },+ { ...serverHostRemote }+ );return servers;}@@ -113,6 +114,16 @@ function selectSyncServiceHost():export const SYNC_SERVICE_HOSTS = selectSyncServiceHost();+/**+ * The DSS host to use for sync-service permission tokens.+ * When the sync service is remote, permission tokens must come from the remote DSS+ * because they need to be signed with the matching JWT secret.+ */+export const SYNC_PERMISSION_TOKEN_DSS_HOST =+ SYNC_SERVICE_HOSTS === syncServiceHostRemote+ ? serverHostRemote['document-storage-service']+ : SERVER_HOSTS['document-storage-service'];+/** Creates endpoint URL for accessing a static file by its ID */export function staticFileIdEndpoint(id: string): string {return `${SERVER_HOSTS['static-file']}/file/${id}`;diff --git a/js/app/packages/service-clients/service-storage/client.ts b/js/app/packages/service-clients/service-storage/client.tsindex 9234597b38..4d36206302 100644--- a/js/app/packages/service-clients/service-storage/client.ts+++ b/js/app/packages/service-clients/service-storage/client.ts@@ -9,7 +9,10 @@ import { modificationDataReplacer } from '@block-pdf/util/buildModificationData'import type { BlockAlias, BlockName } from '@core/block';import { ENABLE_DOCX_TO_PDF } from '@core/constant/featureFlags';import { PaywallKey, usePaywallState } from '@core/constant/PaywallState';-import { SERVER_HOSTS } from '@core/constant/servers';+import {+ SERVER_HOSTS,+ SYNC_PERMISSION_TOKEN_DSS_HOST,+} from '@core/constant/servers';import type { FetchError } from '@core/service';import { cache } from '@core/util/cache';import {@@ -223,9 +226,11 @@ export const storageServiceClient = {},permissionsTokens: {+ // Uses SYNC_PERMISSION_TOKEN_DSS_HOST instead of dssFetch so that tokens are+ // always signed by the DSS whose JWT secret matches the sync service's secret.async createPermissionToken(args) {- return await dssFetch<GetDocumentPermissionsTokenResponse>(- `/documents/permissions_token/${args.document_id}`,+ return await fetchWithToken<GetDocumentPermissionsTokenResponse>(+ `${SYNC_PERMISSION_TOKEN_DSS_HOST}/documents/permissions_token/${args.document_id}`,{method: 'POST',}