@uniformdev/mesh-sdk 20.50.2-alpha.2 → 20.50.2-alpha.39

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/index.d.mts CHANGED
@@ -5,6 +5,44 @@ import { ProjectMapNode } from '@uniformdev/project-map';
5
5
  import { AssetDefinitionType } from '@uniformdev/assets';
6
6
  import { Emitter } from 'mitt';
7
7
 
8
+ interface DelegationTokenClientOptions {
9
+ /** Uniform API host (e.g. 'https://uniform.app'). */
10
+ apiHost: string;
11
+ /** UUID of the integration definition. */
12
+ integrationId: string;
13
+ /** Plaintext app secret for this integration. */
14
+ integrationSecret: string;
15
+ }
16
+ interface DelegationTokenResponse {
17
+ /** Bearer access token that can be used to call Uniform APIs on behalf of the user. */
18
+ accessToken: string;
19
+ /** Refresh token for obtaining a new access token when the current one expires. Absent when the session was minted with `allowRefresh: false`. */
20
+ refreshToken?: string;
21
+ /** Always 'Bearer'. */
22
+ tokenType: 'Bearer';
23
+ /** Token lifetime in seconds. */
24
+ expiresIn: number;
25
+ }
26
+ /**
27
+ * Server-side client for the Uniform token exchange endpoint.
28
+ * Use this in your integration's backend to exchange a session token (obtained from the
29
+ * Mesh SDK iframe context) for a delegation token, or to refresh an existing delegation token.
30
+ */
31
+ declare class DelegationTokenClient {
32
+ #private;
33
+ constructor(options: DelegationTokenClientOptions);
34
+ /**
35
+ * Exchanges a short-lived session token for a delegation token and refresh token.
36
+ * The session token is obtained by the integration's frontend via `sdk.getSessionToken()`.
37
+ */
38
+ exchangeSessionToken(sessionToken: string): Promise<DelegationTokenResponse>;
39
+ /**
40
+ * Exchanges a refresh token for a new delegation token and refresh token.
41
+ * Implements rolling refresh — each refresh token can only be used once.
42
+ */
43
+ refreshDelegationToken(refreshToken: string): Promise<DelegationTokenResponse>;
44
+ }
45
+
8
46
  interface paths$1 {
9
47
  "/api/v1/integration-definitions": {
10
48
  parameters: {
@@ -43,6 +81,9 @@ interface paths$1 {
43
81
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "translation" | "uniform" | "ai" | "unknown";
44
82
  public?: boolean;
45
83
  scopes?: string[];
84
+ identityDelegation?: boolean;
85
+ /** Format: uuid */
86
+ integrationId?: string;
46
87
  baseLocationUrl?: string;
47
88
  locations: {
48
89
  install?: {
@@ -321,6 +362,7 @@ interface paths$1 {
321
362
  /** @enum {string} */
322
363
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "translation" | "uniform" | "ai" | "unknown";
323
364
  scopes?: string[];
365
+ identityDelegation?: boolean;
324
366
  baseLocationUrl?: string;
325
367
  locations: {
326
368
  install?: {
@@ -565,6 +607,8 @@ interface paths$1 {
565
607
  parameterTypes: string[];
566
608
  }[];
567
609
  };
610
+ /** @description When true, regenerates the app secret for identity delegation. Only valid when identity delegation is enabled. */
611
+ regenerateSecret?: boolean;
568
612
  };
569
613
  };
570
614
  };
@@ -584,6 +628,12 @@ interface paths$1 {
584
628
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "translation" | "uniform" | "ai" | "unknown";
585
629
  public?: boolean;
586
630
  scopes?: string[];
631
+ identityDelegation?: boolean;
632
+ /**
633
+ * Format: uuid
634
+ * @description Stable id for this integration definition. Required for identity delegation token exchange.
635
+ */
636
+ integrationId: string;
587
637
  baseLocationUrl?: string;
588
638
  locations: {
589
639
  install?: {
@@ -827,6 +877,8 @@ interface paths$1 {
827
877
  } | null;
828
878
  parameterTypes: string[];
829
879
  }[];
880
+ /** @description Plaintext app secret for identity delegation. Only returned on create or when regenerateSecret is true. */
881
+ appSecret?: string;
830
882
  };
831
883
  };
832
884
  };
@@ -1210,6 +1262,8 @@ declare class IntegrationDefinitionClient extends ApiClient<DefClientOptions> {
1210
1262
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "translation" | "uniform" | "ai" | "unknown";
1211
1263
  public?: boolean;
1212
1264
  scopes?: string[];
1265
+ identityDelegation?: boolean;
1266
+ integrationId: string;
1213
1267
  baseLocationUrl?: string;
1214
1268
  locations: {
1215
1269
  install?: {
@@ -1436,6 +1490,7 @@ declare class IntegrationDefinitionClient extends ApiClient<DefClientOptions> {
1436
1490
  } | null;
1437
1491
  parameterTypes: string[];
1438
1492
  }[];
1493
+ appSecret?: string;
1439
1494
  }>;
1440
1495
  /** Deletes a mesh app from a team */
1441
1496
  remove(body: Omit<IntegrationDefinitionDeleteParameters, 'teamId'>): Promise<void>;
@@ -1796,7 +1851,34 @@ type UniformUser = {
1796
1851
  isAdmin: boolean;
1797
1852
  };
1798
1853
 
1799
- type MeshSDKEventInterface = Awaited<ReturnType<typeof connectToParent>>['parent'] & {
1854
+ /**
1855
+ * Methods the parent frame exposes to the Mesh SDK over the iframe bridge (`connectToParent().parent`).
1856
+ * The dashboard implements the same shape when wiring `setupIframeListeners` / mesh location hosts.
1857
+ */
1858
+ interface MeshParentConnection {
1859
+ resize: ({ height }: {
1860
+ height: CSSHeight;
1861
+ }) => Promise<void>;
1862
+ setValue: (value: SetValueMessage) => Promise<void>;
1863
+ openDialog: (message: OpenDialogMessage) => Promise<Pick<DialogResponseData, 'value' | 'dialogId'> | undefined>;
1864
+ closeDialog: (message: CloseDialogMessage) => Promise<void>;
1865
+ getDataResource: <TExpectedResult>(message: GetDataResourceMessage) => Promise<TExpectedResult>;
1866
+ navigate: (message: NavigateMessage) => Promise<void>;
1867
+ reloadLocation: () => Promise<void>;
1868
+ editConnectedData: (message: EditConnectedDataMessage) => Promise<EditConnectedDataResponse>;
1869
+ /**
1870
+ * Returns a short-lived session token for identity delegation, or `undefined` when delegation
1871
+ * is not enabled for this integration.
1872
+ */
1873
+ getSessionToken: () => Promise<string | undefined>;
1874
+ }
1875
+ type ConnectToParentResult = {
1876
+ initData: MeshContextData;
1877
+ parent: MeshParentConnection;
1878
+ };
1879
+ /** Shape of the handler object the mesh parent iframe must provide (includes `initialize` for the host side). */
1880
+ type MeshSDKEventInterface = MeshParentConnection & {
1881
+ /** Invoked by the child on startup; not part of `connectToParent().parent` but required on the host. */
1800
1882
  initialize: () => Promise<MeshContextData>;
1801
1883
  };
1802
1884
  /**
@@ -1807,21 +1889,7 @@ declare function connectToParent({ dialogResponseHandlers, onMetadataUpdated, on
1807
1889
  dialogResponseHandlers: DialogResponseHandlers;
1808
1890
  onMetadataUpdated: (metadata: unknown) => void;
1809
1891
  onValueExternallyUpdated: (value: unknown) => void;
1810
- }): Promise<{
1811
- initData: MeshContextData;
1812
- parent: {
1813
- resize: ({ height }: {
1814
- height: CSSHeight;
1815
- }) => Promise<void>;
1816
- setValue: (value: SetValueMessage) => Promise<void>;
1817
- openDialog: (message: OpenDialogMessage) => Promise<Pick<DialogResponseData, "value" | "dialogId"> | undefined>;
1818
- closeDialog: (message: CloseDialogMessage) => Promise<void>;
1819
- getDataResource: <TExpectedResult>(message: GetDataResourceMessage) => Promise<TExpectedResult>;
1820
- navigate: (message: NavigateMessage) => Promise<void>;
1821
- reloadLocation: () => Promise<void>;
1822
- editConnectedData: (message: EditConnectedDataMessage) => Promise<EditConnectedDataResponse>;
1823
- };
1824
- }>;
1892
+ }): Promise<ConnectToParentResult>;
1825
1893
 
1826
1894
  type SetLocationFunction<TSetValue> = (value: TSetValue, options?: SetValueOptions) => Promise<void> | void;
1827
1895
  /** Core shared generic for a mesh location context */
@@ -1953,6 +2021,12 @@ type MeshLocationUserPermissions =
1953
2021
  | 'COMPOSITIONS_WRITE'
1954
2022
  /** Uniform Canvas:Compositions:Delete */
1955
2023
  | 'COMPOSITIONS_DELETE'
2024
+ /** Uniform Canvas:Labels:Create */
2025
+ | 'LABELS_CREATE'
2026
+ /** Uniform Canvas:Labels:Update */
2027
+ | 'LABELS_UPDATE'
2028
+ /** Uniform Canvas:Labels:Delete */
2029
+ | 'LABELS_DELETE'
1956
2030
  /** Uniform Canvas:Compositions:Read Published */
1957
2031
  | 'COMPOSITIONS_READ'
1958
2032
  /** Uniform Canvas:Compositions:Publish */
@@ -2195,6 +2269,14 @@ interface UniformMeshSDK {
2195
2269
  }>['setValue']>[0]> | undefined>;
2196
2270
  /** Explicitly close a location dialog. Called when rendering current location in the dialog. */
2197
2271
  closeCurrentLocationDialog(): Promise<void>;
2272
+ /**
2273
+ * Requests a fresh short-lived session token for identity delegation.
2274
+ * Returns `undefined` when the integration does not have `identityDelegation` enabled.
2275
+ * Call this on demand — the token has a very short TTL (~10 s) and should be
2276
+ * consumed immediately by your backend to exchange for a delegation token
2277
+ * via `POST /api/v1/token` with `grant_type=delegation_token` or DelegationTokenClient.
2278
+ */
2279
+ getSessionToken(): Promise<string | undefined>;
2198
2280
  }
2199
2281
  declare global {
2200
2282
  interface Window {
@@ -2215,4 +2297,4 @@ declare const hasPermissions: (permissions: MeshLocationUserPermissions | MeshLo
2215
2297
  */
2216
2298
  declare const hasRole: (role: string, user: UniformUser) => boolean;
2217
2299
 
2218
- export { type AIGenerateLocation, type AIGenerateLocationMetadata, type AIPromptMetadataLocation, type AssetLibraryLocation, type AssetLibraryLocationMetadata, type AssetParameterLocation, type AssetParameterLocationMetadata, type BindableTypes, type CSSHeight, type CanvasEditorEntityType, type CanvasEditorToolsData, type CanvasEditorToolsLocation, type CanvasEditorToolsLocationMetadata, type CloseDialogMessage, type CloseLocationDialogOptions, type CommonMetadata, type DashboardToolLocation, type DashboardToolLocationMetadata, type DataConnectorInfo, type DataResourceLocation, type DataResourceLocationMetadata, type DataSourceLocation, type DataSourceLocationMetadata, type DataSourceLocationValue, type DataTypeLocation, type DataTypeLocationMetadata, type DataTypeLocationValue, type DialogContext, type DialogOptions, type DialogParamValue, type DialogParams, type DialogResponseData, type DialogResponseHandler, type DialogResponseHandlers, type DialogType, type DynamicInput, type DynamicInputs, type EditConnectedDataMessage, type EditConnectedDataResponse, type EditConnectedDataResponseCancellationContext, type EmbeddedEditorLocation, type EmbeddedEditorLocationMetadata, type EmbeddedEditorLocationSetValue, type EmbeddedEditorLocationValue, type FunctionCallResponse, type FunctionCallSystemParameter, type GetDataResourceLocation, type GetDataResourceMessage, IntegrationDefinitionClient, type IntegrationDefinitionDeleteParameters, type IntegrationDefinitionGetParameters, type IntegrationDefinitionGetResponse, type IntegrationDefinitionPutParameters, type IntegrationDefinitionPutResponse, IntegrationInstallationClient, type IntegrationInstallationDeleteParameters, type IntegrationInstallationGetParameters, type IntegrationInstallationGetResponse, type IntegrationInstallationPutParameters, type LocationDialogResponse, type MeshContextData, type MeshLocation, type MeshLocationCore, type MeshLocationTypes, type MeshLocationUserPermissions, type MeshRouter, type MeshSDKEventInterface, type NavigateMessage, type OpenConfirmationDialogOptions, type OpenConfirmationDialogResult, type OpenDialogMessage, type OpenDialogResult, type OpenLocationDialogOptions, type ParamTypeConfigLocation, type ParamTypeConfigLocationMetadata, type ParamTypeLocation, type ParamTypeLocationMetadata, type PersonalizationCriteriaLocation, type PersonalizationCriteriaLocationMetadata, type ProjectToolLocation, type ProjectToolLocationMetadata, type PromptSettingsLocationMetadata, type SdkWindow, type SetLocationFunction, type SetValueMessage, type SetValueOptions, type SettingsLocation, type SettingsLocationMetadata, type UniformMeshSDK, type UniformMeshSDKEvents, type UniformUser, type ValidationResult, functionCallSystemParameters, hasPermissions, hasRole, initializeUniformMeshSDK, parseFunctionCall };
2300
+ export { type AIGenerateLocation, type AIGenerateLocationMetadata, type AIPromptMetadataLocation, type AssetLibraryLocation, type AssetLibraryLocationMetadata, type AssetParameterLocation, type AssetParameterLocationMetadata, type BindableTypes, type CSSHeight, type CanvasEditorEntityType, type CanvasEditorToolsData, type CanvasEditorToolsLocation, type CanvasEditorToolsLocationMetadata, type CloseDialogMessage, type CloseLocationDialogOptions, type CommonMetadata, type ConnectToParentResult, type DashboardToolLocation, type DashboardToolLocationMetadata, type DataConnectorInfo, type DataResourceLocation, type DataResourceLocationMetadata, type DataSourceLocation, type DataSourceLocationMetadata, type DataSourceLocationValue, type DataTypeLocation, type DataTypeLocationMetadata, type DataTypeLocationValue, DelegationTokenClient, type DelegationTokenClientOptions, type DelegationTokenResponse, type DialogContext, type DialogOptions, type DialogParamValue, type DialogParams, type DialogResponseData, type DialogResponseHandler, type DialogResponseHandlers, type DialogType, type DynamicInput, type DynamicInputs, type EditConnectedDataMessage, type EditConnectedDataResponse, type EditConnectedDataResponseCancellationContext, type EmbeddedEditorLocation, type EmbeddedEditorLocationMetadata, type EmbeddedEditorLocationSetValue, type EmbeddedEditorLocationValue, type FunctionCallResponse, type FunctionCallSystemParameter, type GetDataResourceLocation, type GetDataResourceMessage, IntegrationDefinitionClient, type IntegrationDefinitionDeleteParameters, type IntegrationDefinitionGetParameters, type IntegrationDefinitionGetResponse, type IntegrationDefinitionPutParameters, type IntegrationDefinitionPutResponse, IntegrationInstallationClient, type IntegrationInstallationDeleteParameters, type IntegrationInstallationGetParameters, type IntegrationInstallationGetResponse, type IntegrationInstallationPutParameters, type LocationDialogResponse, type MeshContextData, type MeshLocation, type MeshLocationCore, type MeshLocationTypes, type MeshLocationUserPermissions, type MeshParentConnection, type MeshRouter, type MeshSDKEventInterface, type NavigateMessage, type OpenConfirmationDialogOptions, type OpenConfirmationDialogResult, type OpenDialogMessage, type OpenDialogResult, type OpenLocationDialogOptions, type ParamTypeConfigLocation, type ParamTypeConfigLocationMetadata, type ParamTypeLocation, type ParamTypeLocationMetadata, type PersonalizationCriteriaLocation, type PersonalizationCriteriaLocationMetadata, type ProjectToolLocation, type ProjectToolLocationMetadata, type PromptSettingsLocationMetadata, type SdkWindow, type SetLocationFunction, type SetValueMessage, type SetValueOptions, type SettingsLocation, type SettingsLocationMetadata, type UniformMeshSDK, type UniformMeshSDKEvents, type UniformUser, type ValidationResult, functionCallSystemParameters, hasPermissions, hasRole, initializeUniformMeshSDK, parseFunctionCall };
package/dist/index.d.ts CHANGED
@@ -5,6 +5,44 @@ import { ProjectMapNode } from '@uniformdev/project-map';
5
5
  import { AssetDefinitionType } from '@uniformdev/assets';
6
6
  import { Emitter } from 'mitt';
7
7
 
8
+ interface DelegationTokenClientOptions {
9
+ /** Uniform API host (e.g. 'https://uniform.app'). */
10
+ apiHost: string;
11
+ /** UUID of the integration definition. */
12
+ integrationId: string;
13
+ /** Plaintext app secret for this integration. */
14
+ integrationSecret: string;
15
+ }
16
+ interface DelegationTokenResponse {
17
+ /** Bearer access token that can be used to call Uniform APIs on behalf of the user. */
18
+ accessToken: string;
19
+ /** Refresh token for obtaining a new access token when the current one expires. Absent when the session was minted with `allowRefresh: false`. */
20
+ refreshToken?: string;
21
+ /** Always 'Bearer'. */
22
+ tokenType: 'Bearer';
23
+ /** Token lifetime in seconds. */
24
+ expiresIn: number;
25
+ }
26
+ /**
27
+ * Server-side client for the Uniform token exchange endpoint.
28
+ * Use this in your integration's backend to exchange a session token (obtained from the
29
+ * Mesh SDK iframe context) for a delegation token, or to refresh an existing delegation token.
30
+ */
31
+ declare class DelegationTokenClient {
32
+ #private;
33
+ constructor(options: DelegationTokenClientOptions);
34
+ /**
35
+ * Exchanges a short-lived session token for a delegation token and refresh token.
36
+ * The session token is obtained by the integration's frontend via `sdk.getSessionToken()`.
37
+ */
38
+ exchangeSessionToken(sessionToken: string): Promise<DelegationTokenResponse>;
39
+ /**
40
+ * Exchanges a refresh token for a new delegation token and refresh token.
41
+ * Implements rolling refresh — each refresh token can only be used once.
42
+ */
43
+ refreshDelegationToken(refreshToken: string): Promise<DelegationTokenResponse>;
44
+ }
45
+
8
46
  interface paths$1 {
9
47
  "/api/v1/integration-definitions": {
10
48
  parameters: {
@@ -43,6 +81,9 @@ interface paths$1 {
43
81
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "translation" | "uniform" | "ai" | "unknown";
44
82
  public?: boolean;
45
83
  scopes?: string[];
84
+ identityDelegation?: boolean;
85
+ /** Format: uuid */
86
+ integrationId?: string;
46
87
  baseLocationUrl?: string;
47
88
  locations: {
48
89
  install?: {
@@ -321,6 +362,7 @@ interface paths$1 {
321
362
  /** @enum {string} */
322
363
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "translation" | "uniform" | "ai" | "unknown";
323
364
  scopes?: string[];
365
+ identityDelegation?: boolean;
324
366
  baseLocationUrl?: string;
325
367
  locations: {
326
368
  install?: {
@@ -565,6 +607,8 @@ interface paths$1 {
565
607
  parameterTypes: string[];
566
608
  }[];
567
609
  };
610
+ /** @description When true, regenerates the app secret for identity delegation. Only valid when identity delegation is enabled. */
611
+ regenerateSecret?: boolean;
568
612
  };
569
613
  };
570
614
  };
@@ -584,6 +628,12 @@ interface paths$1 {
584
628
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "translation" | "uniform" | "ai" | "unknown";
585
629
  public?: boolean;
586
630
  scopes?: string[];
631
+ identityDelegation?: boolean;
632
+ /**
633
+ * Format: uuid
634
+ * @description Stable id for this integration definition. Required for identity delegation token exchange.
635
+ */
636
+ integrationId: string;
587
637
  baseLocationUrl?: string;
588
638
  locations: {
589
639
  install?: {
@@ -827,6 +877,8 @@ interface paths$1 {
827
877
  } | null;
828
878
  parameterTypes: string[];
829
879
  }[];
880
+ /** @description Plaintext app secret for identity delegation. Only returned on create or when regenerateSecret is true. */
881
+ appSecret?: string;
830
882
  };
831
883
  };
832
884
  };
@@ -1210,6 +1262,8 @@ declare class IntegrationDefinitionClient extends ApiClient<DefClientOptions> {
1210
1262
  category?: "analytics" | "cdn" | "classic" | "commerce" | "content" | "comingSoon" | "data" | "deprecated" | "email" | "framework" | "search" | "starters" | "translation" | "uniform" | "ai" | "unknown";
1211
1263
  public?: boolean;
1212
1264
  scopes?: string[];
1265
+ identityDelegation?: boolean;
1266
+ integrationId: string;
1213
1267
  baseLocationUrl?: string;
1214
1268
  locations: {
1215
1269
  install?: {
@@ -1436,6 +1490,7 @@ declare class IntegrationDefinitionClient extends ApiClient<DefClientOptions> {
1436
1490
  } | null;
1437
1491
  parameterTypes: string[];
1438
1492
  }[];
1493
+ appSecret?: string;
1439
1494
  }>;
1440
1495
  /** Deletes a mesh app from a team */
1441
1496
  remove(body: Omit<IntegrationDefinitionDeleteParameters, 'teamId'>): Promise<void>;
@@ -1796,7 +1851,34 @@ type UniformUser = {
1796
1851
  isAdmin: boolean;
1797
1852
  };
1798
1853
 
1799
- type MeshSDKEventInterface = Awaited<ReturnType<typeof connectToParent>>['parent'] & {
1854
+ /**
1855
+ * Methods the parent frame exposes to the Mesh SDK over the iframe bridge (`connectToParent().parent`).
1856
+ * The dashboard implements the same shape when wiring `setupIframeListeners` / mesh location hosts.
1857
+ */
1858
+ interface MeshParentConnection {
1859
+ resize: ({ height }: {
1860
+ height: CSSHeight;
1861
+ }) => Promise<void>;
1862
+ setValue: (value: SetValueMessage) => Promise<void>;
1863
+ openDialog: (message: OpenDialogMessage) => Promise<Pick<DialogResponseData, 'value' | 'dialogId'> | undefined>;
1864
+ closeDialog: (message: CloseDialogMessage) => Promise<void>;
1865
+ getDataResource: <TExpectedResult>(message: GetDataResourceMessage) => Promise<TExpectedResult>;
1866
+ navigate: (message: NavigateMessage) => Promise<void>;
1867
+ reloadLocation: () => Promise<void>;
1868
+ editConnectedData: (message: EditConnectedDataMessage) => Promise<EditConnectedDataResponse>;
1869
+ /**
1870
+ * Returns a short-lived session token for identity delegation, or `undefined` when delegation
1871
+ * is not enabled for this integration.
1872
+ */
1873
+ getSessionToken: () => Promise<string | undefined>;
1874
+ }
1875
+ type ConnectToParentResult = {
1876
+ initData: MeshContextData;
1877
+ parent: MeshParentConnection;
1878
+ };
1879
+ /** Shape of the handler object the mesh parent iframe must provide (includes `initialize` for the host side). */
1880
+ type MeshSDKEventInterface = MeshParentConnection & {
1881
+ /** Invoked by the child on startup; not part of `connectToParent().parent` but required on the host. */
1800
1882
  initialize: () => Promise<MeshContextData>;
1801
1883
  };
1802
1884
  /**
@@ -1807,21 +1889,7 @@ declare function connectToParent({ dialogResponseHandlers, onMetadataUpdated, on
1807
1889
  dialogResponseHandlers: DialogResponseHandlers;
1808
1890
  onMetadataUpdated: (metadata: unknown) => void;
1809
1891
  onValueExternallyUpdated: (value: unknown) => void;
1810
- }): Promise<{
1811
- initData: MeshContextData;
1812
- parent: {
1813
- resize: ({ height }: {
1814
- height: CSSHeight;
1815
- }) => Promise<void>;
1816
- setValue: (value: SetValueMessage) => Promise<void>;
1817
- openDialog: (message: OpenDialogMessage) => Promise<Pick<DialogResponseData, "value" | "dialogId"> | undefined>;
1818
- closeDialog: (message: CloseDialogMessage) => Promise<void>;
1819
- getDataResource: <TExpectedResult>(message: GetDataResourceMessage) => Promise<TExpectedResult>;
1820
- navigate: (message: NavigateMessage) => Promise<void>;
1821
- reloadLocation: () => Promise<void>;
1822
- editConnectedData: (message: EditConnectedDataMessage) => Promise<EditConnectedDataResponse>;
1823
- };
1824
- }>;
1892
+ }): Promise<ConnectToParentResult>;
1825
1893
 
1826
1894
  type SetLocationFunction<TSetValue> = (value: TSetValue, options?: SetValueOptions) => Promise<void> | void;
1827
1895
  /** Core shared generic for a mesh location context */
@@ -1953,6 +2021,12 @@ type MeshLocationUserPermissions =
1953
2021
  | 'COMPOSITIONS_WRITE'
1954
2022
  /** Uniform Canvas:Compositions:Delete */
1955
2023
  | 'COMPOSITIONS_DELETE'
2024
+ /** Uniform Canvas:Labels:Create */
2025
+ | 'LABELS_CREATE'
2026
+ /** Uniform Canvas:Labels:Update */
2027
+ | 'LABELS_UPDATE'
2028
+ /** Uniform Canvas:Labels:Delete */
2029
+ | 'LABELS_DELETE'
1956
2030
  /** Uniform Canvas:Compositions:Read Published */
1957
2031
  | 'COMPOSITIONS_READ'
1958
2032
  /** Uniform Canvas:Compositions:Publish */
@@ -2195,6 +2269,14 @@ interface UniformMeshSDK {
2195
2269
  }>['setValue']>[0]> | undefined>;
2196
2270
  /** Explicitly close a location dialog. Called when rendering current location in the dialog. */
2197
2271
  closeCurrentLocationDialog(): Promise<void>;
2272
+ /**
2273
+ * Requests a fresh short-lived session token for identity delegation.
2274
+ * Returns `undefined` when the integration does not have `identityDelegation` enabled.
2275
+ * Call this on demand — the token has a very short TTL (~10 s) and should be
2276
+ * consumed immediately by your backend to exchange for a delegation token
2277
+ * via `POST /api/v1/token` with `grant_type=delegation_token` or DelegationTokenClient.
2278
+ */
2279
+ getSessionToken(): Promise<string | undefined>;
2198
2280
  }
2199
2281
  declare global {
2200
2282
  interface Window {
@@ -2215,4 +2297,4 @@ declare const hasPermissions: (permissions: MeshLocationUserPermissions | MeshLo
2215
2297
  */
2216
2298
  declare const hasRole: (role: string, user: UniformUser) => boolean;
2217
2299
 
2218
- export { type AIGenerateLocation, type AIGenerateLocationMetadata, type AIPromptMetadataLocation, type AssetLibraryLocation, type AssetLibraryLocationMetadata, type AssetParameterLocation, type AssetParameterLocationMetadata, type BindableTypes, type CSSHeight, type CanvasEditorEntityType, type CanvasEditorToolsData, type CanvasEditorToolsLocation, type CanvasEditorToolsLocationMetadata, type CloseDialogMessage, type CloseLocationDialogOptions, type CommonMetadata, type DashboardToolLocation, type DashboardToolLocationMetadata, type DataConnectorInfo, type DataResourceLocation, type DataResourceLocationMetadata, type DataSourceLocation, type DataSourceLocationMetadata, type DataSourceLocationValue, type DataTypeLocation, type DataTypeLocationMetadata, type DataTypeLocationValue, type DialogContext, type DialogOptions, type DialogParamValue, type DialogParams, type DialogResponseData, type DialogResponseHandler, type DialogResponseHandlers, type DialogType, type DynamicInput, type DynamicInputs, type EditConnectedDataMessage, type EditConnectedDataResponse, type EditConnectedDataResponseCancellationContext, type EmbeddedEditorLocation, type EmbeddedEditorLocationMetadata, type EmbeddedEditorLocationSetValue, type EmbeddedEditorLocationValue, type FunctionCallResponse, type FunctionCallSystemParameter, type GetDataResourceLocation, type GetDataResourceMessage, IntegrationDefinitionClient, type IntegrationDefinitionDeleteParameters, type IntegrationDefinitionGetParameters, type IntegrationDefinitionGetResponse, type IntegrationDefinitionPutParameters, type IntegrationDefinitionPutResponse, IntegrationInstallationClient, type IntegrationInstallationDeleteParameters, type IntegrationInstallationGetParameters, type IntegrationInstallationGetResponse, type IntegrationInstallationPutParameters, type LocationDialogResponse, type MeshContextData, type MeshLocation, type MeshLocationCore, type MeshLocationTypes, type MeshLocationUserPermissions, type MeshRouter, type MeshSDKEventInterface, type NavigateMessage, type OpenConfirmationDialogOptions, type OpenConfirmationDialogResult, type OpenDialogMessage, type OpenDialogResult, type OpenLocationDialogOptions, type ParamTypeConfigLocation, type ParamTypeConfigLocationMetadata, type ParamTypeLocation, type ParamTypeLocationMetadata, type PersonalizationCriteriaLocation, type PersonalizationCriteriaLocationMetadata, type ProjectToolLocation, type ProjectToolLocationMetadata, type PromptSettingsLocationMetadata, type SdkWindow, type SetLocationFunction, type SetValueMessage, type SetValueOptions, type SettingsLocation, type SettingsLocationMetadata, type UniformMeshSDK, type UniformMeshSDKEvents, type UniformUser, type ValidationResult, functionCallSystemParameters, hasPermissions, hasRole, initializeUniformMeshSDK, parseFunctionCall };
2300
+ export { type AIGenerateLocation, type AIGenerateLocationMetadata, type AIPromptMetadataLocation, type AssetLibraryLocation, type AssetLibraryLocationMetadata, type AssetParameterLocation, type AssetParameterLocationMetadata, type BindableTypes, type CSSHeight, type CanvasEditorEntityType, type CanvasEditorToolsData, type CanvasEditorToolsLocation, type CanvasEditorToolsLocationMetadata, type CloseDialogMessage, type CloseLocationDialogOptions, type CommonMetadata, type ConnectToParentResult, type DashboardToolLocation, type DashboardToolLocationMetadata, type DataConnectorInfo, type DataResourceLocation, type DataResourceLocationMetadata, type DataSourceLocation, type DataSourceLocationMetadata, type DataSourceLocationValue, type DataTypeLocation, type DataTypeLocationMetadata, type DataTypeLocationValue, DelegationTokenClient, type DelegationTokenClientOptions, type DelegationTokenResponse, type DialogContext, type DialogOptions, type DialogParamValue, type DialogParams, type DialogResponseData, type DialogResponseHandler, type DialogResponseHandlers, type DialogType, type DynamicInput, type DynamicInputs, type EditConnectedDataMessage, type EditConnectedDataResponse, type EditConnectedDataResponseCancellationContext, type EmbeddedEditorLocation, type EmbeddedEditorLocationMetadata, type EmbeddedEditorLocationSetValue, type EmbeddedEditorLocationValue, type FunctionCallResponse, type FunctionCallSystemParameter, type GetDataResourceLocation, type GetDataResourceMessage, IntegrationDefinitionClient, type IntegrationDefinitionDeleteParameters, type IntegrationDefinitionGetParameters, type IntegrationDefinitionGetResponse, type IntegrationDefinitionPutParameters, type IntegrationDefinitionPutResponse, IntegrationInstallationClient, type IntegrationInstallationDeleteParameters, type IntegrationInstallationGetParameters, type IntegrationInstallationGetResponse, type IntegrationInstallationPutParameters, type LocationDialogResponse, type MeshContextData, type MeshLocation, type MeshLocationCore, type MeshLocationTypes, type MeshLocationUserPermissions, type MeshParentConnection, type MeshRouter, type MeshSDKEventInterface, type NavigateMessage, type OpenConfirmationDialogOptions, type OpenConfirmationDialogResult, type OpenDialogMessage, type OpenDialogResult, type OpenLocationDialogOptions, type ParamTypeConfigLocation, type ParamTypeConfigLocationMetadata, type ParamTypeLocation, type ParamTypeLocationMetadata, type PersonalizationCriteriaLocation, type PersonalizationCriteriaLocationMetadata, type ProjectToolLocation, type ProjectToolLocationMetadata, type PromptSettingsLocationMetadata, type SdkWindow, type SetLocationFunction, type SetValueMessage, type SetValueOptions, type SettingsLocation, type SettingsLocationMetadata, type UniformMeshSDK, type UniformMeshSDKEvents, type UniformUser, type ValidationResult, functionCallSystemParameters, hasPermissions, hasRole, initializeUniformMeshSDK, parseFunctionCall };
package/dist/index.esm.js CHANGED
@@ -4,6 +4,75 @@ var __typeError = (msg) => {
4
4
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
5
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
6
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
+
10
+ // src/clients/DelegationTokenClient.ts
11
+ var _options, _DelegationTokenClient_instances, post_fn;
12
+ var DelegationTokenClient = class {
13
+ constructor(options) {
14
+ __privateAdd(this, _DelegationTokenClient_instances);
15
+ __privateAdd(this, _options);
16
+ __privateSet(this, _options, options);
17
+ }
18
+ /**
19
+ * Exchanges a short-lived session token for a delegation token and refresh token.
20
+ * The session token is obtained by the integration's frontend via `sdk.getSessionToken()`.
21
+ */
22
+ async exchangeSessionToken(sessionToken) {
23
+ return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
24
+ grant_type: "delegation_token",
25
+ sessionToken,
26
+ integrationId: __privateGet(this, _options).integrationId,
27
+ integrationSecret: __privateGet(this, _options).integrationSecret
28
+ });
29
+ }
30
+ /**
31
+ * Exchanges a refresh token for a new delegation token and refresh token.
32
+ * Implements rolling refresh — each refresh token can only be used once.
33
+ */
34
+ async refreshDelegationToken(refreshToken) {
35
+ return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
36
+ grant_type: "refresh_token",
37
+ refreshToken,
38
+ integrationId: __privateGet(this, _options).integrationId,
39
+ integrationSecret: __privateGet(this, _options).integrationSecret
40
+ });
41
+ }
42
+ };
43
+ _options = new WeakMap();
44
+ _DelegationTokenClient_instances = new WeakSet();
45
+ post_fn = async function(body) {
46
+ var _a;
47
+ const url = `${__privateGet(this, _options).apiHost}/api/v1/token`;
48
+ const response = await fetch(url, {
49
+ method: "POST",
50
+ headers: { "Content-Type": "application/json" },
51
+ body: JSON.stringify(body)
52
+ });
53
+ if (!response.ok) {
54
+ const text = await response.text().catch(() => "");
55
+ const detail = (_a = extractErrorMessage(text)) != null ? _a : text;
56
+ throw new Error(`Token exchange failed (${response.status}): ${detail}`);
57
+ }
58
+ return await response.json();
59
+ };
60
+ function extractErrorMessage(text) {
61
+ try {
62
+ const parsed = JSON.parse(text);
63
+ if (typeof parsed.errorMessage === "string") {
64
+ return parsed.errorMessage;
65
+ }
66
+ if (typeof parsed.error === "string") {
67
+ return parsed.error;
68
+ }
69
+ if (typeof parsed.message === "string") {
70
+ return parsed.message;
71
+ }
72
+ } catch (e) {
73
+ }
74
+ return void 0;
75
+ }
7
76
 
8
77
  // src/clients/IntegrationDefinitionClient.ts
9
78
  import { ApiClient } from "@uniformdev/context/api";
@@ -131,7 +200,7 @@ var getLogger = (prefix, debug) => {
131
200
  };
132
201
 
133
202
  // src/temp/version.ts
134
- var UNIFORM_MESH_SDK_VERSION = "20.50.1";
203
+ var UNIFORM_MESH_SDK_VERSION = "20.60.0";
135
204
 
136
205
  // src/framepost/constants.ts
137
206
  var DEFAULT_REQUEST_TIMEOUT = 5e3;
@@ -488,56 +557,63 @@ async function connectToParent({
488
557
  });
489
558
  client.onRequest("metadata-value", onMetadataUpdated);
490
559
  client.onRequest("external-value-update", onValueExternallyUpdated);
491
- return {
492
- initData,
493
- parent: {
494
- resize: async ({ height }) => {
495
- await client.request("resize", { height });
496
- },
497
- setValue: async (value) => {
498
- await client.request("setValue", value);
499
- },
500
- openDialog: async (message) => {
501
- const res = await client.request(
502
- "openDialog",
503
- message
504
- );
505
- const dialogId = res == null ? void 0 : res.dialogId;
506
- if (!dialogId) {
507
- return;
508
- }
509
- return new Promise((resolve, reject) => {
510
- dialogResponseHandlers[dialogId] = { resolve, reject };
511
- });
512
- },
513
- closeDialog: async (message) => {
514
- await client.request("closeDialog", message);
515
- },
516
- getDataResource: async (message) => {
517
- return await client.request("getDataResource", message, {
518
- timeout: 3e4
519
- });
520
- },
521
- navigate: async (message) => {
522
- await client.request("navigate", message);
523
- },
524
- reloadLocation: async () => {
525
- await client.request("reload");
526
- },
527
- editConnectedData: async (message) => {
528
- return await client.request(
529
- "editConnectedData",
530
- message,
531
- {
532
- timeout: (
533
- // 24 hours in ms
534
- 864e5
535
- )
536
- }
537
- );
560
+ const parent = {
561
+ resize: async ({ height }) => {
562
+ await client.request("resize", { height });
563
+ },
564
+ setValue: async (value) => {
565
+ await client.request("setValue", value);
566
+ },
567
+ openDialog: async (message) => {
568
+ const res = await client.request(
569
+ "openDialog",
570
+ message
571
+ );
572
+ const dialogId = res == null ? void 0 : res.dialogId;
573
+ if (!dialogId) {
574
+ return;
538
575
  }
576
+ return new Promise((resolve, reject) => {
577
+ dialogResponseHandlers[dialogId] = { resolve, reject };
578
+ });
579
+ },
580
+ closeDialog: async (message) => {
581
+ await client.request("closeDialog", message);
582
+ },
583
+ getDataResource: async (message) => {
584
+ return await client.request("getDataResource", message, {
585
+ timeout: 3e4
586
+ });
587
+ },
588
+ navigate: async (message) => {
589
+ await client.request("navigate", message);
590
+ },
591
+ reloadLocation: async () => {
592
+ await client.request("reload");
593
+ },
594
+ editConnectedData: async (message) => {
595
+ return await client.request(
596
+ "editConnectedData",
597
+ message,
598
+ {
599
+ timeout: (
600
+ // 24 hours in ms
601
+ 864e5
602
+ )
603
+ }
604
+ );
605
+ },
606
+ getSessionToken: async () => {
607
+ return await client.request("getSessionToken", void 0, {
608
+ // Delegation may wait on consent UI + token API; default framepost timeout (5s) is too short.
609
+ timeout: 12e4
610
+ });
539
611
  }
540
612
  };
613
+ return {
614
+ initData,
615
+ parent
616
+ };
541
617
  }
542
618
 
543
619
  // src/sdkWindow.ts
@@ -816,7 +892,8 @@ async function initializeUniformMeshSDK({
816
892
  },
817
893
  closeCurrentLocationDialog: async () => {
818
894
  await parent.closeDialog({ dialogId: void 0, dialogType: "currentLocation" });
819
- }
895
+ },
896
+ getSessionToken: () => parent.getSessionToken()
820
897
  };
821
898
  window.UniformMeshSDK = sdk;
822
899
  initializing = false;
@@ -838,6 +915,7 @@ var hasRole = (role, user) => {
838
915
  return user.roles.some((userRole) => userRole.name === role || userRole.id === role);
839
916
  };
840
917
  export {
918
+ DelegationTokenClient,
841
919
  IntegrationDefinitionClient,
842
920
  IntegrationInstallationClient,
843
921
  functionCallSystemParameters,
package/dist/index.js CHANGED
@@ -32,10 +32,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
32
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
33
33
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
34
34
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
35
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
35
37
 
36
38
  // src/index.ts
37
39
  var src_exports = {};
38
40
  __export(src_exports, {
41
+ DelegationTokenClient: () => DelegationTokenClient,
39
42
  IntegrationDefinitionClient: () => IntegrationDefinitionClient,
40
43
  IntegrationInstallationClient: () => IntegrationInstallationClient,
41
44
  functionCallSystemParameters: () => functionCallSystemParameters,
@@ -46,6 +49,73 @@ __export(src_exports, {
46
49
  });
47
50
  module.exports = __toCommonJS(src_exports);
48
51
 
52
+ // src/clients/DelegationTokenClient.ts
53
+ var _options, _DelegationTokenClient_instances, post_fn;
54
+ var DelegationTokenClient = class {
55
+ constructor(options) {
56
+ __privateAdd(this, _DelegationTokenClient_instances);
57
+ __privateAdd(this, _options);
58
+ __privateSet(this, _options, options);
59
+ }
60
+ /**
61
+ * Exchanges a short-lived session token for a delegation token and refresh token.
62
+ * The session token is obtained by the integration's frontend via `sdk.getSessionToken()`.
63
+ */
64
+ async exchangeSessionToken(sessionToken) {
65
+ return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
66
+ grant_type: "delegation_token",
67
+ sessionToken,
68
+ integrationId: __privateGet(this, _options).integrationId,
69
+ integrationSecret: __privateGet(this, _options).integrationSecret
70
+ });
71
+ }
72
+ /**
73
+ * Exchanges a refresh token for a new delegation token and refresh token.
74
+ * Implements rolling refresh — each refresh token can only be used once.
75
+ */
76
+ async refreshDelegationToken(refreshToken) {
77
+ return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
78
+ grant_type: "refresh_token",
79
+ refreshToken,
80
+ integrationId: __privateGet(this, _options).integrationId,
81
+ integrationSecret: __privateGet(this, _options).integrationSecret
82
+ });
83
+ }
84
+ };
85
+ _options = new WeakMap();
86
+ _DelegationTokenClient_instances = new WeakSet();
87
+ post_fn = async function(body) {
88
+ var _a;
89
+ const url = `${__privateGet(this, _options).apiHost}/api/v1/token`;
90
+ const response = await fetch(url, {
91
+ method: "POST",
92
+ headers: { "Content-Type": "application/json" },
93
+ body: JSON.stringify(body)
94
+ });
95
+ if (!response.ok) {
96
+ const text = await response.text().catch(() => "");
97
+ const detail = (_a = extractErrorMessage(text)) != null ? _a : text;
98
+ throw new Error(`Token exchange failed (${response.status}): ${detail}`);
99
+ }
100
+ return await response.json();
101
+ };
102
+ function extractErrorMessage(text) {
103
+ try {
104
+ const parsed = JSON.parse(text);
105
+ if (typeof parsed.errorMessage === "string") {
106
+ return parsed.errorMessage;
107
+ }
108
+ if (typeof parsed.error === "string") {
109
+ return parsed.error;
110
+ }
111
+ if (typeof parsed.message === "string") {
112
+ return parsed.message;
113
+ }
114
+ } catch (e) {
115
+ }
116
+ return void 0;
117
+ }
118
+
49
119
  // src/clients/IntegrationDefinitionClient.ts
50
120
  var import_api = require("@uniformdev/context/api");
51
121
  var _url;
@@ -172,7 +242,7 @@ var getLogger = (prefix, debug) => {
172
242
  };
173
243
 
174
244
  // src/temp/version.ts
175
- var UNIFORM_MESH_SDK_VERSION = "20.50.1";
245
+ var UNIFORM_MESH_SDK_VERSION = "20.60.0";
176
246
 
177
247
  // src/framepost/constants.ts
178
248
  var DEFAULT_REQUEST_TIMEOUT = 5e3;
@@ -529,56 +599,63 @@ async function connectToParent({
529
599
  });
530
600
  client.onRequest("metadata-value", onMetadataUpdated);
531
601
  client.onRequest("external-value-update", onValueExternallyUpdated);
532
- return {
533
- initData,
534
- parent: {
535
- resize: async ({ height }) => {
536
- await client.request("resize", { height });
537
- },
538
- setValue: async (value) => {
539
- await client.request("setValue", value);
540
- },
541
- openDialog: async (message) => {
542
- const res = await client.request(
543
- "openDialog",
544
- message
545
- );
546
- const dialogId = res == null ? void 0 : res.dialogId;
547
- if (!dialogId) {
548
- return;
549
- }
550
- return new Promise((resolve, reject) => {
551
- dialogResponseHandlers[dialogId] = { resolve, reject };
552
- });
553
- },
554
- closeDialog: async (message) => {
555
- await client.request("closeDialog", message);
556
- },
557
- getDataResource: async (message) => {
558
- return await client.request("getDataResource", message, {
559
- timeout: 3e4
560
- });
561
- },
562
- navigate: async (message) => {
563
- await client.request("navigate", message);
564
- },
565
- reloadLocation: async () => {
566
- await client.request("reload");
567
- },
568
- editConnectedData: async (message) => {
569
- return await client.request(
570
- "editConnectedData",
571
- message,
572
- {
573
- timeout: (
574
- // 24 hours in ms
575
- 864e5
576
- )
577
- }
578
- );
602
+ const parent = {
603
+ resize: async ({ height }) => {
604
+ await client.request("resize", { height });
605
+ },
606
+ setValue: async (value) => {
607
+ await client.request("setValue", value);
608
+ },
609
+ openDialog: async (message) => {
610
+ const res = await client.request(
611
+ "openDialog",
612
+ message
613
+ );
614
+ const dialogId = res == null ? void 0 : res.dialogId;
615
+ if (!dialogId) {
616
+ return;
579
617
  }
618
+ return new Promise((resolve, reject) => {
619
+ dialogResponseHandlers[dialogId] = { resolve, reject };
620
+ });
621
+ },
622
+ closeDialog: async (message) => {
623
+ await client.request("closeDialog", message);
624
+ },
625
+ getDataResource: async (message) => {
626
+ return await client.request("getDataResource", message, {
627
+ timeout: 3e4
628
+ });
629
+ },
630
+ navigate: async (message) => {
631
+ await client.request("navigate", message);
632
+ },
633
+ reloadLocation: async () => {
634
+ await client.request("reload");
635
+ },
636
+ editConnectedData: async (message) => {
637
+ return await client.request(
638
+ "editConnectedData",
639
+ message,
640
+ {
641
+ timeout: (
642
+ // 24 hours in ms
643
+ 864e5
644
+ )
645
+ }
646
+ );
647
+ },
648
+ getSessionToken: async () => {
649
+ return await client.request("getSessionToken", void 0, {
650
+ // Delegation may wait on consent UI + token API; default framepost timeout (5s) is too short.
651
+ timeout: 12e4
652
+ });
580
653
  }
581
654
  };
655
+ return {
656
+ initData,
657
+ parent
658
+ };
582
659
  }
583
660
 
584
661
  // src/sdkWindow.ts
@@ -857,7 +934,8 @@ async function initializeUniformMeshSDK({
857
934
  },
858
935
  closeCurrentLocationDialog: async () => {
859
936
  await parent.closeDialog({ dialogId: void 0, dialogType: "currentLocation" });
860
- }
937
+ },
938
+ getSessionToken: () => parent.getSessionToken()
861
939
  };
862
940
  window.UniformMeshSDK = sdk;
863
941
  initializing = false;
@@ -880,6 +958,7 @@ var hasRole = (role, user) => {
880
958
  };
881
959
  // Annotate the CommonJS export names for ESM import in node:
882
960
  0 && (module.exports = {
961
+ DelegationTokenClient,
883
962
  IntegrationDefinitionClient,
884
963
  IntegrationInstallationClient,
885
964
  functionCallSystemParameters,
package/dist/index.mjs CHANGED
@@ -4,6 +4,75 @@ var __typeError = (msg) => {
4
4
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
5
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
6
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
+
10
+ // src/clients/DelegationTokenClient.ts
11
+ var _options, _DelegationTokenClient_instances, post_fn;
12
+ var DelegationTokenClient = class {
13
+ constructor(options) {
14
+ __privateAdd(this, _DelegationTokenClient_instances);
15
+ __privateAdd(this, _options);
16
+ __privateSet(this, _options, options);
17
+ }
18
+ /**
19
+ * Exchanges a short-lived session token for a delegation token and refresh token.
20
+ * The session token is obtained by the integration's frontend via `sdk.getSessionToken()`.
21
+ */
22
+ async exchangeSessionToken(sessionToken) {
23
+ return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
24
+ grant_type: "delegation_token",
25
+ sessionToken,
26
+ integrationId: __privateGet(this, _options).integrationId,
27
+ integrationSecret: __privateGet(this, _options).integrationSecret
28
+ });
29
+ }
30
+ /**
31
+ * Exchanges a refresh token for a new delegation token and refresh token.
32
+ * Implements rolling refresh — each refresh token can only be used once.
33
+ */
34
+ async refreshDelegationToken(refreshToken) {
35
+ return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
36
+ grant_type: "refresh_token",
37
+ refreshToken,
38
+ integrationId: __privateGet(this, _options).integrationId,
39
+ integrationSecret: __privateGet(this, _options).integrationSecret
40
+ });
41
+ }
42
+ };
43
+ _options = new WeakMap();
44
+ _DelegationTokenClient_instances = new WeakSet();
45
+ post_fn = async function(body) {
46
+ var _a;
47
+ const url = `${__privateGet(this, _options).apiHost}/api/v1/token`;
48
+ const response = await fetch(url, {
49
+ method: "POST",
50
+ headers: { "Content-Type": "application/json" },
51
+ body: JSON.stringify(body)
52
+ });
53
+ if (!response.ok) {
54
+ const text = await response.text().catch(() => "");
55
+ const detail = (_a = extractErrorMessage(text)) != null ? _a : text;
56
+ throw new Error(`Token exchange failed (${response.status}): ${detail}`);
57
+ }
58
+ return await response.json();
59
+ };
60
+ function extractErrorMessage(text) {
61
+ try {
62
+ const parsed = JSON.parse(text);
63
+ if (typeof parsed.errorMessage === "string") {
64
+ return parsed.errorMessage;
65
+ }
66
+ if (typeof parsed.error === "string") {
67
+ return parsed.error;
68
+ }
69
+ if (typeof parsed.message === "string") {
70
+ return parsed.message;
71
+ }
72
+ } catch (e) {
73
+ }
74
+ return void 0;
75
+ }
7
76
 
8
77
  // src/clients/IntegrationDefinitionClient.ts
9
78
  import { ApiClient } from "@uniformdev/context/api";
@@ -131,7 +200,7 @@ var getLogger = (prefix, debug) => {
131
200
  };
132
201
 
133
202
  // src/temp/version.ts
134
- var UNIFORM_MESH_SDK_VERSION = "20.50.1";
203
+ var UNIFORM_MESH_SDK_VERSION = "20.60.0";
135
204
 
136
205
  // src/framepost/constants.ts
137
206
  var DEFAULT_REQUEST_TIMEOUT = 5e3;
@@ -488,56 +557,63 @@ async function connectToParent({
488
557
  });
489
558
  client.onRequest("metadata-value", onMetadataUpdated);
490
559
  client.onRequest("external-value-update", onValueExternallyUpdated);
491
- return {
492
- initData,
493
- parent: {
494
- resize: async ({ height }) => {
495
- await client.request("resize", { height });
496
- },
497
- setValue: async (value) => {
498
- await client.request("setValue", value);
499
- },
500
- openDialog: async (message) => {
501
- const res = await client.request(
502
- "openDialog",
503
- message
504
- );
505
- const dialogId = res == null ? void 0 : res.dialogId;
506
- if (!dialogId) {
507
- return;
508
- }
509
- return new Promise((resolve, reject) => {
510
- dialogResponseHandlers[dialogId] = { resolve, reject };
511
- });
512
- },
513
- closeDialog: async (message) => {
514
- await client.request("closeDialog", message);
515
- },
516
- getDataResource: async (message) => {
517
- return await client.request("getDataResource", message, {
518
- timeout: 3e4
519
- });
520
- },
521
- navigate: async (message) => {
522
- await client.request("navigate", message);
523
- },
524
- reloadLocation: async () => {
525
- await client.request("reload");
526
- },
527
- editConnectedData: async (message) => {
528
- return await client.request(
529
- "editConnectedData",
530
- message,
531
- {
532
- timeout: (
533
- // 24 hours in ms
534
- 864e5
535
- )
536
- }
537
- );
560
+ const parent = {
561
+ resize: async ({ height }) => {
562
+ await client.request("resize", { height });
563
+ },
564
+ setValue: async (value) => {
565
+ await client.request("setValue", value);
566
+ },
567
+ openDialog: async (message) => {
568
+ const res = await client.request(
569
+ "openDialog",
570
+ message
571
+ );
572
+ const dialogId = res == null ? void 0 : res.dialogId;
573
+ if (!dialogId) {
574
+ return;
538
575
  }
576
+ return new Promise((resolve, reject) => {
577
+ dialogResponseHandlers[dialogId] = { resolve, reject };
578
+ });
579
+ },
580
+ closeDialog: async (message) => {
581
+ await client.request("closeDialog", message);
582
+ },
583
+ getDataResource: async (message) => {
584
+ return await client.request("getDataResource", message, {
585
+ timeout: 3e4
586
+ });
587
+ },
588
+ navigate: async (message) => {
589
+ await client.request("navigate", message);
590
+ },
591
+ reloadLocation: async () => {
592
+ await client.request("reload");
593
+ },
594
+ editConnectedData: async (message) => {
595
+ return await client.request(
596
+ "editConnectedData",
597
+ message,
598
+ {
599
+ timeout: (
600
+ // 24 hours in ms
601
+ 864e5
602
+ )
603
+ }
604
+ );
605
+ },
606
+ getSessionToken: async () => {
607
+ return await client.request("getSessionToken", void 0, {
608
+ // Delegation may wait on consent UI + token API; default framepost timeout (5s) is too short.
609
+ timeout: 12e4
610
+ });
539
611
  }
540
612
  };
613
+ return {
614
+ initData,
615
+ parent
616
+ };
541
617
  }
542
618
 
543
619
  // src/sdkWindow.ts
@@ -816,7 +892,8 @@ async function initializeUniformMeshSDK({
816
892
  },
817
893
  closeCurrentLocationDialog: async () => {
818
894
  await parent.closeDialog({ dialogId: void 0, dialogType: "currentLocation" });
819
- }
895
+ },
896
+ getSessionToken: () => parent.getSessionToken()
820
897
  };
821
898
  window.UniformMeshSDK = sdk;
822
899
  initializing = false;
@@ -838,6 +915,7 @@ var hasRole = (role, user) => {
838
915
  return user.roles.some((userRole) => userRole.name === role || userRole.id === role);
839
916
  };
840
917
  export {
918
+ DelegationTokenClient,
841
919
  IntegrationDefinitionClient,
842
920
  IntegrationInstallationClient,
843
921
  functionCallSystemParameters,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/mesh-sdk",
3
- "version": "20.50.2-alpha.2+5f918e9716",
3
+ "version": "20.50.2-alpha.39+83d081969c",
4
4
  "description": "Uniform Mesh Framework SDK",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -33,10 +33,10 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@uniformdev/assets": "20.50.2-alpha.2+5f918e9716",
37
- "@uniformdev/canvas": "20.50.2-alpha.2+5f918e9716",
38
- "@uniformdev/context": "20.50.2-alpha.2+5f918e9716",
39
- "@uniformdev/project-map": "20.50.2-alpha.2+5f918e9716",
36
+ "@uniformdev/assets": "20.50.2-alpha.39+83d081969c",
37
+ "@uniformdev/canvas": "20.50.2-alpha.39+83d081969c",
38
+ "@uniformdev/context": "20.50.2-alpha.39+83d081969c",
39
+ "@uniformdev/project-map": "20.50.2-alpha.39+83d081969c",
40
40
  "imagesloaded": "^5.0.0",
41
41
  "mitt": "^3.0.1"
42
42
  },
@@ -44,5 +44,5 @@
44
44
  "@types/imagesloaded": "^4.1.2",
45
45
  "openai": "4.94.0"
46
46
  },
47
- "gitHead": "5f918e9716a4e8b9af3bfefa881a5a569e54b279"
47
+ "gitHead": "83d081969cac03a901e60d5c78bad66eef78de80"
48
48
  }