@omni-co/embed 0.13.0 → 0.14.1-alpha.1

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/README.md CHANGED
@@ -210,6 +210,9 @@ type EmbedSsoDashboardProps = {
210
210
  */
211
211
  mode?: EmbedSessionMode;
212
212
 
213
+ // Optional object that determines the model permissions for the embed user.
214
+ modelRoles?: Record<string, EmbedConnectionRoles>;
215
+
213
216
  // Required name of the external user.
214
217
  name: string;
215
218
 
@@ -353,6 +356,9 @@ type EmbedSsoWorkbookProps = {
353
356
  */
354
357
  mode?: EmbedSessionMode;
355
358
 
359
+ // Optional object that determines the model permissions for the embed user.
360
+ modelRoles?: Record<string, EmbedConnectionRoles>;
361
+
356
362
  // Required name of the external user.
357
363
  name: string;
358
364
 
@@ -488,6 +494,9 @@ type EmbedSsoContentDiscoveryProps = {
488
494
  */
489
495
  mode?: EmbedSessionMode;
490
496
 
497
+ // Optional object that determines the model permissions for the embed user.
498
+ modelRoles?: Record<string, EmbedConnectionRoles>;
499
+
491
500
  // Required name of the external user.
492
501
  name: string;
493
502
 
@@ -655,6 +664,9 @@ type CreateSessionTokenProps = {
655
664
  */
656
665
  mode?: EmbedSessionMode;
657
666
 
667
+ // Optional object that determines the model permissions for the embed user.
668
+ modelRoles?: Record<string, EmbedConnectionRoles>;
669
+
658
670
  // Required name of the external user.
659
671
  name: string;
660
672
 
@@ -0,0 +1,82 @@
1
+ export declare enum EmbedSessionMode {
2
+ Application = "APPLICATION",
3
+ SingleContent = "SINGLE_CONTENT"
4
+ }
5
+ export declare enum CustomThemeProperty {
6
+ DASHBOARD_BACKGROUND = "dashboard-background",
7
+ DASHBOARD_PAGE_PADDING = "dashboard-page-padding",
8
+ DASHBOARD_TILE_MARGIN = "dashboard-tile-margin",
9
+ DASHBOARD_TILE_BACKGROUND = "dashboard-tile-background",
10
+ DASHBOARD_TILE_SHADOW = "dashboard-tile-shadow",
11
+ DASHBOARD_TILE_TEXT_BODY_COLOR = "dashboard-tile-text-body-color",
12
+ DASHBOARD_TILE_TEXT_SECONDARY_COLOR = "dashboard-tile-text-secondary-color",
13
+ DASHBOARD_TILE_BORDER_COLOR = "dashboard-tile-border-color",
14
+ DASHBOARD_TILE_BORDER_RADIUS = "dashboard-tile-border-radius",
15
+ DASHBOARD_TILE_BORDER_STYLE = "dashboard-tile-border-style",
16
+ DASHBOARD_TILE_BORDER_WIDTH = "dashboard-tile-border-width",
17
+ DASHBOARD_TILE_TITLE_FONT_SIZE = "dashboard-tile-title-font-size",
18
+ DASHBOARD_TILE_TITLE_FONT_WEIGHT = "dashboard-tile-title-font-weight",
19
+ DASHBOARD_TILE_TITLE_TEXT_COLOR = "dashboard-tile-title-text-color",
20
+ DASHBOARD_TILE_TITLE_FONT_FAMILY = "dashboard-tile-title-font-family",
21
+ DASHBOARD_TILE_TEXT_BODY_FONT_FAMILY = "dashboard-tile-text-body-font-family",
22
+ DASHBOARD_TILE_TEXT_CODE_FONT_FAMILY = "dashboard-tile-text-code-font-family",
23
+ DASHBOARD_KEY_COLOR = "dashboard-key-color",
24
+ DASHBOARD_KEY_TEXT_COLOR = "dashboard-key-text-color",
25
+ DASHBOARD_BUTTON_RADIUS = "dashboard-button-radius",
26
+ DASHBOARD_BUTTON_TRANSPARENT_TEXT_COLOR = "dashboard-button-transparent-text-color",
27
+ DASHBOARD_BUTTON_TRANSPARENT_INTERACTIVE_COLOR = "dashboard-button-transparent-interactive-color",
28
+ DASHBOARD_MENU_ITEM_INTERACTIVE_COLOR = "dashboard-menu-item-interactive-color",
29
+ DASHBOARD_CONTROL_BACKGROUND = "dashboard-control-background",
30
+ DASHBOARD_CONTROL_RADIUS = "dashboard-control-radius",
31
+ DASHBOARD_CONTROL_BORDER_COLOR = "dashboard-control-border-color",
32
+ DASHBOARD_CONTROL_TEXT_COLOR = "dashboard-control-text-color",
33
+ DASHBOARD_CONTROL_PLACEHOLDER_COLOR = "dashboard-control-placeholder-color",
34
+ DASHBOARD_CONTROL_LABEL_COLOR = "dashboard-control-label-color",
35
+ DASHBOARD_CONTROL_OUTLINE_COLOR = "dashboard-control-outline-color",
36
+ DASHBOARD_CONTROL_POPOVER_BACKGROUND = "dashboard-control-popover-background",
37
+ DASHBOARD_CONTROL_POPOVER_TEXT_COLOR = "dashboard-control-popover-text-color",
38
+ DASHBOARD_CONTROL_POPOVER_SECONDARY_TEXT_COLOR = "dashboard-control-popover-secondary-text-color",
39
+ DASHBOARD_CONTROL_POPOVER_LINK_COLOR = "dashboard-control-popover-link-color",
40
+ DASHBOARD_CONTROL_POPOVER_DIVIDER_COLOR = "dashboard-control-popover-divider-color",
41
+ DASHBOARD_CONTROL_POPOVER_RADIUS = "dashboard-control-popover-radius",
42
+ DASHBOARD_CONTROL_POPOVER_BORDER_COLOR = "dashboard-control-popover-border-color",
43
+ DASHBOARD_FILTER_INPUT_BACKGROUND = "dashboard-filter-input-background",
44
+ DASHBOARD_FILTER_INPUT_RADIUS = "dashboard-filter-input-radius",
45
+ DASHBOARD_FILTER_INPUT_BORDER_COLOR = "dashboard-filter-input-border-color",
46
+ DASHBOARD_FILTER_INPUT_TEXT_COLOR = "dashboard-filter-input-text-color",
47
+ DASHBOARD_FILTER_INPUT_PLACEHOLDER_COLOR = "dashboard-filter-input-placeholder-color",
48
+ DASHBOARD_FILTER_INPUT_ICON_COLOR = "dashboard-filter-input-icon-color",
49
+ DASHBOARD_FILTER_INPUT_OUTLINE_COLOR = "dashboard-filter-input-outline-color",
50
+ DASHBOARD_FILTER_INPUT_ACCENT_COLOR = "dashboard-filter-input-accent-color",
51
+ DASHBOARD_FILTER_INPUT_ACCENT_INVERT_COLOR = "dashboard-filter-input-accent-invert-color",
52
+ DASHBOARD_FILTER_INPUT_TOKEN_COLOR = "dashboard-filter-input-token-color",
53
+ DASHBOARD_FILTER_INPUT_TOKEN_TEXT_COLOR = "dashboard-filter-input-token-text-color"
54
+ }
55
+ export declare enum EmbeddedContent {
56
+ Dashboard = "dashboards",
57
+ Workbook = "w"
58
+ }
59
+ export declare enum EmbedConnectionRoles {
60
+ RESTRICTED_QUERIER = "RESTRICTED_QUERIER",
61
+ VIEWER = "VIEWER",
62
+ QUERIER = "QUERIER"
63
+ }
64
+ /**
65
+ * Levels of access a user can have to their associated embed entity folder.
66
+ */
67
+ export declare enum EmbedEntityFolderContentRoles {
68
+ MANAGER = "MANAGER",
69
+ EDITOR = "EDITOR",
70
+ VIEWER = "VIEWER",
71
+ NO_ACCESS = "NO_ACCESS"
72
+ }
73
+ /**
74
+ * UI settings used as keys of the uiSettings sso embed parameter.
75
+ */
76
+ export declare enum EmbedUiSettings {
77
+ /**
78
+ * When false, hides all in-app navigation elements. Note that in-app navigation
79
+ * is only visible when the embed session is in APPLICATION mode.
80
+ */
81
+ SHOW_NAVIGATION = "showNavigation"
82
+ }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmbedUiSettings = exports.EmbedEntityFolderContentRoles = exports.EmbedConnectionRoles = exports.EmbeddedContent = exports.CustomThemeProperty = exports.EmbedSessionMode = void 0;
4
+ var EmbedSessionMode;
5
+ (function (EmbedSessionMode) {
6
+ EmbedSessionMode["Application"] = "APPLICATION";
7
+ EmbedSessionMode["SingleContent"] = "SINGLE_CONTENT";
8
+ })(EmbedSessionMode || (exports.EmbedSessionMode = EmbedSessionMode = {}));
9
+ var CustomThemeProperty;
10
+ (function (CustomThemeProperty) {
11
+ CustomThemeProperty["DASHBOARD_BACKGROUND"] = "dashboard-background";
12
+ CustomThemeProperty["DASHBOARD_PAGE_PADDING"] = "dashboard-page-padding";
13
+ CustomThemeProperty["DASHBOARD_TILE_MARGIN"] = "dashboard-tile-margin";
14
+ CustomThemeProperty["DASHBOARD_TILE_BACKGROUND"] = "dashboard-tile-background";
15
+ CustomThemeProperty["DASHBOARD_TILE_SHADOW"] = "dashboard-tile-shadow";
16
+ CustomThemeProperty["DASHBOARD_TILE_TEXT_BODY_COLOR"] = "dashboard-tile-text-body-color";
17
+ CustomThemeProperty["DASHBOARD_TILE_TEXT_SECONDARY_COLOR"] = "dashboard-tile-text-secondary-color";
18
+ CustomThemeProperty["DASHBOARD_TILE_BORDER_COLOR"] = "dashboard-tile-border-color";
19
+ CustomThemeProperty["DASHBOARD_TILE_BORDER_RADIUS"] = "dashboard-tile-border-radius";
20
+ CustomThemeProperty["DASHBOARD_TILE_BORDER_STYLE"] = "dashboard-tile-border-style";
21
+ CustomThemeProperty["DASHBOARD_TILE_BORDER_WIDTH"] = "dashboard-tile-border-width";
22
+ CustomThemeProperty["DASHBOARD_TILE_TITLE_FONT_SIZE"] = "dashboard-tile-title-font-size";
23
+ CustomThemeProperty["DASHBOARD_TILE_TITLE_FONT_WEIGHT"] = "dashboard-tile-title-font-weight";
24
+ CustomThemeProperty["DASHBOARD_TILE_TITLE_TEXT_COLOR"] = "dashboard-tile-title-text-color";
25
+ CustomThemeProperty["DASHBOARD_TILE_TITLE_FONT_FAMILY"] = "dashboard-tile-title-font-family";
26
+ CustomThemeProperty["DASHBOARD_TILE_TEXT_BODY_FONT_FAMILY"] = "dashboard-tile-text-body-font-family";
27
+ CustomThemeProperty["DASHBOARD_TILE_TEXT_CODE_FONT_FAMILY"] = "dashboard-tile-text-code-font-family";
28
+ CustomThemeProperty["DASHBOARD_KEY_COLOR"] = "dashboard-key-color";
29
+ CustomThemeProperty["DASHBOARD_KEY_TEXT_COLOR"] = "dashboard-key-text-color";
30
+ CustomThemeProperty["DASHBOARD_BUTTON_RADIUS"] = "dashboard-button-radius";
31
+ CustomThemeProperty["DASHBOARD_BUTTON_TRANSPARENT_TEXT_COLOR"] = "dashboard-button-transparent-text-color";
32
+ CustomThemeProperty["DASHBOARD_BUTTON_TRANSPARENT_INTERACTIVE_COLOR"] = "dashboard-button-transparent-interactive-color";
33
+ CustomThemeProperty["DASHBOARD_MENU_ITEM_INTERACTIVE_COLOR"] = "dashboard-menu-item-interactive-color";
34
+ // These styles are applied to controls directly on the dashboard,
35
+ // typically these are single select control,
36
+ // period-over-period control or advanced filter controls
37
+ CustomThemeProperty["DASHBOARD_CONTROL_BACKGROUND"] = "dashboard-control-background";
38
+ CustomThemeProperty["DASHBOARD_CONTROL_RADIUS"] = "dashboard-control-radius";
39
+ CustomThemeProperty["DASHBOARD_CONTROL_BORDER_COLOR"] = "dashboard-control-border-color";
40
+ CustomThemeProperty["DASHBOARD_CONTROL_TEXT_COLOR"] = "dashboard-control-text-color";
41
+ CustomThemeProperty["DASHBOARD_CONTROL_PLACEHOLDER_COLOR"] = "dashboard-control-placeholder-color";
42
+ CustomThemeProperty["DASHBOARD_CONTROL_LABEL_COLOR"] = "dashboard-control-label-color";
43
+ CustomThemeProperty["DASHBOARD_CONTROL_OUTLINE_COLOR"] = "dashboard-control-outline-color";
44
+ // These styles are applied the popover container
45
+ // that is triggered when clicking a dashboard control
46
+ CustomThemeProperty["DASHBOARD_CONTROL_POPOVER_BACKGROUND"] = "dashboard-control-popover-background";
47
+ CustomThemeProperty["DASHBOARD_CONTROL_POPOVER_TEXT_COLOR"] = "dashboard-control-popover-text-color";
48
+ CustomThemeProperty["DASHBOARD_CONTROL_POPOVER_SECONDARY_TEXT_COLOR"] = "dashboard-control-popover-secondary-text-color";
49
+ CustomThemeProperty["DASHBOARD_CONTROL_POPOVER_LINK_COLOR"] = "dashboard-control-popover-link-color";
50
+ CustomThemeProperty["DASHBOARD_CONTROL_POPOVER_DIVIDER_COLOR"] = "dashboard-control-popover-divider-color";
51
+ CustomThemeProperty["DASHBOARD_CONTROL_POPOVER_RADIUS"] = "dashboard-control-popover-radius";
52
+ CustomThemeProperty["DASHBOARD_CONTROL_POPOVER_BORDER_COLOR"] = "dashboard-control-popover-border-color";
53
+ // These styles are applied to filter inputs inside the control popover
54
+ CustomThemeProperty["DASHBOARD_FILTER_INPUT_BACKGROUND"] = "dashboard-filter-input-background";
55
+ CustomThemeProperty["DASHBOARD_FILTER_INPUT_RADIUS"] = "dashboard-filter-input-radius";
56
+ CustomThemeProperty["DASHBOARD_FILTER_INPUT_BORDER_COLOR"] = "dashboard-filter-input-border-color";
57
+ CustomThemeProperty["DASHBOARD_FILTER_INPUT_TEXT_COLOR"] = "dashboard-filter-input-text-color";
58
+ CustomThemeProperty["DASHBOARD_FILTER_INPUT_PLACEHOLDER_COLOR"] = "dashboard-filter-input-placeholder-color";
59
+ CustomThemeProperty["DASHBOARD_FILTER_INPUT_ICON_COLOR"] = "dashboard-filter-input-icon-color";
60
+ CustomThemeProperty["DASHBOARD_FILTER_INPUT_OUTLINE_COLOR"] = "dashboard-filter-input-outline-color";
61
+ CustomThemeProperty["DASHBOARD_FILTER_INPUT_ACCENT_COLOR"] = "dashboard-filter-input-accent-color";
62
+ CustomThemeProperty["DASHBOARD_FILTER_INPUT_ACCENT_INVERT_COLOR"] = "dashboard-filter-input-accent-invert-color";
63
+ CustomThemeProperty["DASHBOARD_FILTER_INPUT_TOKEN_COLOR"] = "dashboard-filter-input-token-color";
64
+ CustomThemeProperty["DASHBOARD_FILTER_INPUT_TOKEN_TEXT_COLOR"] = "dashboard-filter-input-token-text-color";
65
+ })(CustomThemeProperty || (exports.CustomThemeProperty = CustomThemeProperty = {}));
66
+ var EmbeddedContent;
67
+ (function (EmbeddedContent) {
68
+ EmbeddedContent["Dashboard"] = "dashboards";
69
+ EmbeddedContent["Workbook"] = "w";
70
+ })(EmbeddedContent || (exports.EmbeddedContent = EmbeddedContent = {}));
71
+ var EmbedConnectionRoles;
72
+ (function (EmbedConnectionRoles) {
73
+ EmbedConnectionRoles["RESTRICTED_QUERIER"] = "RESTRICTED_QUERIER";
74
+ EmbedConnectionRoles["VIEWER"] = "VIEWER";
75
+ EmbedConnectionRoles["QUERIER"] = "QUERIER";
76
+ })(EmbedConnectionRoles || (exports.EmbedConnectionRoles = EmbedConnectionRoles = {}));
77
+ /**
78
+ * Levels of access a user can have to their associated embed entity folder.
79
+ */
80
+ var EmbedEntityFolderContentRoles;
81
+ (function (EmbedEntityFolderContentRoles) {
82
+ EmbedEntityFolderContentRoles["MANAGER"] = "MANAGER";
83
+ EmbedEntityFolderContentRoles["EDITOR"] = "EDITOR";
84
+ EmbedEntityFolderContentRoles["VIEWER"] = "VIEWER";
85
+ EmbedEntityFolderContentRoles["NO_ACCESS"] = "NO_ACCESS";
86
+ })(EmbedEntityFolderContentRoles || (exports.EmbedEntityFolderContentRoles = EmbedEntityFolderContentRoles = {}));
87
+ /**
88
+ * UI settings used as keys of the uiSettings sso embed parameter.
89
+ */
90
+ var EmbedUiSettings;
91
+ (function (EmbedUiSettings) {
92
+ /**
93
+ * When false, hides all in-app navigation elements. Note that in-app navigation
94
+ * is only visible when the embed session is in APPLICATION mode.
95
+ */
96
+ EmbedUiSettings["SHOW_NAVIGATION"] = "showNavigation";
97
+ })(EmbedUiSettings || (exports.EmbedUiSettings = EmbedUiSettings = {}));
@@ -1,4 +1,4 @@
1
- import { EmbedSsoContentDiscoveryProps, EmbedSsoDashboardProps, EmbedSsoWorkbookProps, CreateSessionTokenProps, RedeemSessionTokenProps } from "./types";
1
+ import { EmbedSsoContentDiscoveryProps, EmbedSsoDashboardProps, EmbedSsoWorkbookProps, CreateSessionTokenProps, RedeemSessionTokenProps } from "./types.js";
2
2
  export declare const embedSsoDashboard: (props: EmbedSsoDashboardProps) => Promise<string>;
3
3
  export declare const embedSsoWorkbook: (props: EmbedSsoWorkbookProps) => Promise<string>;
4
4
  /**
package/lib/cjs/embed.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.redeemSessionToken = exports.createSessionToken = exports.embedSsoContentDiscovery = exports.embedSsoWorkbook = exports.embedSsoDashboard = void 0;
4
- const random_str_1 = require("./random-str");
5
- const signature_1 = require("./signature");
6
- const types_1 = require("./types");
4
+ const random_str_js_1 = require("./random-str.js");
5
+ const signature_js_1 = require("./signature.js");
6
+ const constants_js_1 = require("./constants.js");
7
7
  const defaultEmbedDomain = "embed-omniapp.co";
8
8
  const embedLoginPath = "/embed/login";
9
9
  const generateSsoEmbedSessionPath = "/api/unstable/embed/sso/generate-session";
@@ -18,7 +18,7 @@ const createEmbedRequestUrl = (props) => {
18
18
  }
19
19
  // Generate the url for the embed login route
20
20
  if (!host)
21
- host = `${organizationName}.${domain !== null && domain !== void 0 ? domain : defaultEmbedDomain}`;
21
+ host = `${organizationName}.${domain ?? defaultEmbedDomain}`;
22
22
  const url = new URL(props.requestPath, `https://${host}${props.port ? `:${props.port}` : ""}`);
23
23
  return url;
24
24
  };
@@ -54,14 +54,15 @@ const validateProps = (props) => {
54
54
  };
55
55
  const embedSsoContent = async (props) => {
56
56
  validateProps(props);
57
- let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, domain, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, externalId, filterSearchParam, groups: rawGroups, host, linkAccess, mode, name, nonce, organizationName, preserveEntityFolderContentRole, prefersDark, port, secret, theme, uiSettings: rawUiSettings, userAttributes: rawUserAttributes, } = props;
57
+ let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, domain, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, externalId, filterSearchParam, groups: rawGroups, host, linkAccess, mode, modelRoles: rawModelRoles, name, nonce, organizationName, preserveEntityFolderContentRole, prefersDark, port, secret, theme, uiSettings: rawUiSettings, userAttributes: rawUserAttributes, } = props;
58
58
  // Handle defaults
59
- nonce = nonce !== null && nonce !== void 0 ? nonce : (await (0, random_str_1.random32ByteString)());
59
+ nonce = nonce ?? (await (0, random_str_js_1.random32ByteString)());
60
60
  const uiSettings = rawUiSettings && JSON.stringify(rawUiSettings);
61
61
  const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
62
62
  const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
63
63
  const connectionRoles = rawConnectionRoles && JSON.stringify(rawConnectionRoles);
64
64
  const groups = rawGroups && JSON.stringify(rawGroups);
65
+ const modelRoles = rawModelRoles && JSON.stringify(rawModelRoles);
65
66
  const url = createEmbedRequestUrl({
66
67
  domain,
67
68
  host,
@@ -70,7 +71,7 @@ const embedSsoContent = async (props) => {
70
71
  requestPath: embedLoginPath,
71
72
  });
72
73
  // Get a signature for the request
73
- const signature = (0, signature_1.getSignature)({
74
+ const signature = (0, signature_js_1.getSignature)({
74
75
  // Required parameters
75
76
  loginUrl: url.toString(),
76
77
  contentPath,
@@ -93,6 +94,7 @@ const embedSsoContent = async (props) => {
93
94
  groups,
94
95
  linkAccess,
95
96
  mode,
97
+ modelRoles,
96
98
  prefersDark,
97
99
  preserveEntityFolderContentRole,
98
100
  theme,
@@ -119,6 +121,7 @@ const embedSsoContent = async (props) => {
119
121
  connectionRoles &&
120
122
  url.searchParams.append("connectionRoles", connectionRoles);
121
123
  mode && url.searchParams.append("mode", mode);
124
+ modelRoles && url.searchParams.append("modelRoles", modelRoles);
122
125
  entityFolderContentRole &&
123
126
  url.searchParams.append("entityFolderContentRole", entityFolderContentRole);
124
127
  entityFolderGroupContentRole &&
@@ -136,12 +139,12 @@ const embedSsoContent = async (props) => {
136
139
  };
137
140
  const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
138
141
  const embedSsoDashboard = async (props) => {
139
- const contentPath = buildContentPath(types_1.EmbeddedContent.Dashboard, props.contentId);
142
+ const contentPath = buildContentPath(constants_js_1.EmbeddedContent.Dashboard, props.contentId);
140
143
  return embedSsoContent({ ...props, contentPath });
141
144
  };
142
145
  exports.embedSsoDashboard = embedSsoDashboard;
143
146
  const embedSsoWorkbook = async (props) => {
144
- const contentPath = `${buildContentPath(types_1.EmbeddedContent.Workbook, props.contentId)}/duplicate`;
147
+ const contentPath = `${buildContentPath(constants_js_1.EmbeddedContent.Workbook, props.contentId)}/duplicate`;
145
148
  return embedSsoContent({ ...props, contentPath });
146
149
  };
147
150
  exports.embedSsoWorkbook = embedSsoWorkbook;
@@ -194,7 +197,7 @@ const createSessionToken = async ({ apiKey, domain, host, organizationName, port
194
197
  error: `Failed to generate embed session: ${fetchResponse.statusText}`,
195
198
  success: false,
196
199
  };
197
- const fetchData = await fetchResponse.json();
200
+ const fetchData = (await fetchResponse.json());
198
201
  if (!fetchData.sessionId)
199
202
  return { error: "No session ID returned from endpoint.", success: false };
200
203
  return { sessionToken: fetchData.sessionId, success: true };
@@ -214,8 +217,8 @@ theme, }) => {
214
217
  port,
215
218
  requestPath: redeemSsoEmbedSessionPath,
216
219
  });
217
- const nonce = propsNonce !== null && propsNonce !== void 0 ? propsNonce : (await (0, random_str_1.random32ByteString)());
218
- const signature = (0, signature_1.signSessionRedemption)({
220
+ const nonce = propsNonce ?? (await (0, random_str_js_1.random32ByteString)());
221
+ const signature = (0, signature_js_1.signSessionRedemption)({
219
222
  requestUrl: redeemRequestUrl.toString(),
220
223
  nonce,
221
224
  prefersDark,
@@ -1,3 +1,4 @@
1
- export * from "./embed";
2
- export * from "./types";
3
- export * from "./signature";
1
+ export * from "./embed.js";
2
+ export * from "./types.js";
3
+ export * from "./signature.js";
4
+ export * from "./constants.js";
package/lib/cjs/index.js CHANGED
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./embed"), exports);
18
- __exportStar(require("./types"), exports);
19
- __exportStar(require("./signature"), exports);
17
+ __exportStar(require("./embed.js"), exports);
18
+ __exportStar(require("./types.js"), exports);
19
+ __exportStar(require("./signature.js"), exports);
20
+ __exportStar(require("./constants.js"), exports);
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Client / browser entrypoint for the Omni Embed SDK.
3
+ */
4
+ export * from "./constants.js";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /**
18
+ * Client / browser entrypoint for the Omni Embed SDK.
19
+ */
20
+ __exportStar(require("./constants.js"), exports);
@@ -0,0 +1 @@
1
+ {"type": "commonjs"}
@@ -86,6 +86,10 @@ type SignatureProps = {
86
86
  * The mode of the embedded content.
87
87
  */
88
88
  mode?: string;
89
+ /**
90
+ * The model roles to be associated with the embed user. Expected to be a stringified JSON object.
91
+ */
92
+ modelRoles?: string;
89
93
  /**
90
94
  * Whether the user prefers light, dark, or system theme.
91
95
  */
@@ -131,6 +135,6 @@ type SignSessionRedemptionProps = Pick<SignatureProps, "nonce" | "prefersDark" |
131
135
  */
132
136
  export declare const signSessionRedemption: ({ requestUrl, nonce, sessionId, secret, prefersDark, theme, }: SignSessionRedemptionProps) => string;
133
137
  export declare const TEST_ONLY: {
134
- generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, prefersDark, preserveEntityFolderContentRole, theme, uiSettings, userAttributes, }: Omit<SignatureProps, "secret">) => string;
138
+ generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, modelRoles, prefersDark, preserveEntityFolderContentRole, theme, uiSettings, userAttributes, }: Omit<SignatureProps, "secret">) => string;
135
139
  };
136
140
  export {};
@@ -5,19 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TEST_ONLY = exports.signSessionRedemption = exports.getSignature = exports.hmacSign = void 0;
7
7
  const crypto_1 = __importDefault(require("crypto"));
8
- const base64url_1 = __importDefault(require("base64url"));
9
8
  const hmacSign = (data, secret) => {
10
9
  const hmac = crypto_1.default.createHmac("sha256", secret);
11
10
  hmac.update(data);
12
11
  const b64 = hmac.digest("base64");
13
- return base64url_1.default.fromBase64(b64);
12
+ return Buffer.from(b64, "base64").toString("base64url");
14
13
  };
15
14
  exports.hmacSign = hmacSign;
16
15
  const generateStringForSignature = ({
17
16
  // Required parameters
18
17
  loginUrl, contentPath, externalId, name, nonce,
19
18
  // Optional parameters
20
- accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, prefersDark, preserveEntityFolderContentRole, theme, uiSettings, userAttributes, }) => {
19
+ accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, modelRoles, prefersDark, preserveEntityFolderContentRole, theme, uiSettings, userAttributes, }) => {
21
20
  // We create a map of optional params and convert it to an array
22
21
  // to ensure that the order of the optional params is alphabetical and consistent.
23
22
  const optionalParamsMap = {
@@ -35,6 +34,7 @@ accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityF
35
34
  ...(groups && { groups }),
36
35
  ...(linkAccess && { linkAccess }),
37
36
  ...(mode && { mode }),
37
+ ...(modelRoles && { modelRoles }),
38
38
  ...(prefersDark && { prefersDark }),
39
39
  ...(preserveEntityFolderContentRole !== undefined && {
40
40
  preserveEntityFolderContentRole: preserveEntityFolderContentRole.toString(),
@@ -1,8 +1,5 @@
1
+ import { CustomThemeProperty, EmbedConnectionRoles, EmbedEntityFolderContentRoles, EmbedSessionMode, EmbedUiSettings } from "./constants.js";
1
2
  type UserAttributeValue = string | string[] | number | number[];
2
- export declare enum EmbedSessionMode {
3
- Application = "APPLICATION",
4
- SingleContent = "SINGLE_CONTENT"
5
- }
6
3
  type HostProps = {
7
4
  host?: never;
8
5
  /**
@@ -47,6 +44,11 @@ type EmbedSsoBaseProps = {
47
44
  * Object values should be connection roles.
48
45
  */
49
46
  connectionRoles?: Record<string, EmbedConnectionRoles>;
47
+ /**
48
+ * Optional model roles setting. Object keys should be model IDs from the embedded Omni instance.
49
+ * Object values should be connection roles.
50
+ */
51
+ modelRoles?: Record<string, EmbedConnectionRoles>;
50
52
  /**
51
53
  * Optional mode setting that determines whether the entire application should be embedded or a single piece of content.
52
54
  *
@@ -118,56 +120,6 @@ type EmbedContentIdProp = {
118
120
  type EmbedContentPathProp = {
119
121
  contentPath: string;
120
122
  };
121
- export declare enum CustomThemeProperty {
122
- DASHBOARD_BACKGROUND = "dashboard-background",
123
- DASHBOARD_PAGE_PADDING = "dashboard-page-padding",
124
- DASHBOARD_TILE_MARGIN = "dashboard-tile-margin",
125
- DASHBOARD_TILE_BACKGROUND = "dashboard-tile-background",
126
- DASHBOARD_TILE_SHADOW = "dashboard-tile-shadow",
127
- DASHBOARD_TILE_TEXT_BODY_COLOR = "dashboard-tile-text-body-color",
128
- DASHBOARD_TILE_TEXT_SECONDARY_COLOR = "dashboard-tile-text-secondary-color",
129
- DASHBOARD_TILE_BORDER_COLOR = "dashboard-tile-border-color",
130
- DASHBOARD_TILE_BORDER_RADIUS = "dashboard-tile-border-radius",
131
- DASHBOARD_TILE_BORDER_STYLE = "dashboard-tile-border-style",
132
- DASHBOARD_TILE_BORDER_WIDTH = "dashboard-tile-border-width",
133
- DASHBOARD_TILE_TITLE_FONT_SIZE = "dashboard-tile-title-font-size",
134
- DASHBOARD_TILE_TITLE_FONT_WEIGHT = "dashboard-tile-title-font-weight",
135
- DASHBOARD_TILE_TITLE_TEXT_COLOR = "dashboard-tile-title-text-color",
136
- DASHBOARD_TILE_TITLE_FONT_FAMILY = "dashboard-tile-title-font-family",
137
- DASHBOARD_TILE_TEXT_BODY_FONT_FAMILY = "dashboard-tile-text-body-font-family",
138
- DASHBOARD_TILE_TEXT_CODE_FONT_FAMILY = "dashboard-tile-text-code-font-family",
139
- DASHBOARD_KEY_COLOR = "dashboard-key-color",
140
- DASHBOARD_KEY_TEXT_COLOR = "dashboard-key-text-color",
141
- DASHBOARD_BUTTON_RADIUS = "dashboard-button-radius",
142
- DASHBOARD_BUTTON_TRANSPARENT_TEXT_COLOR = "dashboard-button-transparent-text-color",
143
- DASHBOARD_BUTTON_TRANSPARENT_INTERACTIVE_COLOR = "dashboard-button-transparent-interactive-color",
144
- DASHBOARD_MENU_ITEM_INTERACTIVE_COLOR = "dashboard-menu-item-interactive-color",
145
- DASHBOARD_CONTROL_BACKGROUND = "dashboard-control-background",
146
- DASHBOARD_CONTROL_RADIUS = "dashboard-control-radius",
147
- DASHBOARD_CONTROL_BORDER_COLOR = "dashboard-control-border-color",
148
- DASHBOARD_CONTROL_TEXT_COLOR = "dashboard-control-text-color",
149
- DASHBOARD_CONTROL_PLACEHOLDER_COLOR = "dashboard-control-placeholder-color",
150
- DASHBOARD_CONTROL_LABEL_COLOR = "dashboard-control-label-color",
151
- DASHBOARD_CONTROL_OUTLINE_COLOR = "dashboard-control-outline-color",
152
- DASHBOARD_CONTROL_POPOVER_BACKGROUND = "dashboard-control-popover-background",
153
- DASHBOARD_CONTROL_POPOVER_TEXT_COLOR = "dashboard-control-popover-text-color",
154
- DASHBOARD_CONTROL_POPOVER_SECONDARY_TEXT_COLOR = "dashboard-control-popover-secondary-text-color",
155
- DASHBOARD_CONTROL_POPOVER_LINK_COLOR = "dashboard-control-popover-link-color",
156
- DASHBOARD_CONTROL_POPOVER_DIVIDER_COLOR = "dashboard-control-popover-divider-color",
157
- DASHBOARD_CONTROL_POPOVER_RADIUS = "dashboard-control-popover-radius",
158
- DASHBOARD_CONTROL_POPOVER_BORDER_COLOR = "dashboard-control-popover-border-color",
159
- DASHBOARD_FILTER_INPUT_BACKGROUND = "dashboard-filter-input-background",
160
- DASHBOARD_FILTER_INPUT_RADIUS = "dashboard-filter-input-radius",
161
- DASHBOARD_FILTER_INPUT_BORDER_COLOR = "dashboard-filter-input-border-color",
162
- DASHBOARD_FILTER_INPUT_TEXT_COLOR = "dashboard-filter-input-text-color",
163
- DASHBOARD_FILTER_INPUT_PLACEHOLDER_COLOR = "dashboard-filter-input-placeholder-color",
164
- DASHBOARD_FILTER_INPUT_ICON_COLOR = "dashboard-filter-input-icon-color",
165
- DASHBOARD_FILTER_INPUT_OUTLINE_COLOR = "dashboard-filter-input-outline-color",
166
- DASHBOARD_FILTER_INPUT_ACCENT_COLOR = "dashboard-filter-input-accent-color",
167
- DASHBOARD_FILTER_INPUT_ACCENT_INVERT_COLOR = "dashboard-filter-input-accent-invert-color",
168
- DASHBOARD_FILTER_INPUT_TOKEN_COLOR = "dashboard-filter-input-token-color",
169
- DASHBOARD_FILTER_INPUT_TOKEN_TEXT_COLOR = "dashboard-filter-input-token-text-color"
170
- }
171
123
  export type CustomThemeProperties = {
172
124
  [CustomThemeProperty.DASHBOARD_BACKGROUND]?: string;
173
125
  [CustomThemeProperty.DASHBOARD_PAGE_PADDING]?: string;
@@ -219,34 +171,6 @@ export type CustomThemeProperties = {
219
171
  [CustomThemeProperty.DASHBOARD_FILTER_INPUT_TOKEN_TEXT_COLOR]?: string;
220
172
  [CustomThemeProperty.DASHBOARD_BUTTON_RADIUS]?: string;
221
173
  };
222
- export declare enum EmbeddedContent {
223
- Dashboard = "dashboards",
224
- Workbook = "w"
225
- }
226
- export declare enum EmbedConnectionRoles {
227
- RESTRICTED_QUERIER = "RESTRICTED_QUERIER",
228
- VIEWER = "VIEWER",
229
- QUERIER = "QUERIER"
230
- }
231
- /**
232
- * Levels of access a user can have to their associated embed entity folder.
233
- */
234
- export declare enum EmbedEntityFolderContentRoles {
235
- MANAGER = "MANAGER",
236
- EDITOR = "EDITOR",
237
- VIEWER = "VIEWER",
238
- NO_ACCESS = "NO_ACCESS"
239
- }
240
- /**
241
- * UI settings used as keys of the uiSettings sso embed parameter.
242
- */
243
- export declare enum EmbedUiSettings {
244
- /**
245
- * When false, hides all in-app navigation elements. Note that in-app navigation
246
- * is only visible when the embed session is in APPLICATION mode.
247
- */
248
- SHOW_NAVIGATION = "showNavigation"
249
- }
250
174
  export type EmbedSsoContentProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentPathProp;
251
175
  /**
252
176
  * Consumers of this SDK will rely on these three types to embed workbooks and dashboards.
@@ -254,16 +178,23 @@ export type EmbedSsoContentProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProp
254
178
  export type EmbedSsoDashboardProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentIdProp;
255
179
  export type EmbedSsoWorkbookProps = EmbedSsoBaseProps & EmbedContentIdProp;
256
180
  export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
181
+ /**
182
+ * Path name of the content discovery page to embed.
183
+ */
184
+ path: string;
185
+ } & ({
257
186
  /**
258
187
  * Required connection roles object. Object keys should be connection IDs from the embedded Omni instance.
259
188
  * Object values should be connection roles.
260
189
  */
261
190
  connectionRoles: Record<string, EmbedConnectionRoles>;
191
+ } | {
262
192
  /**
263
- * Path name of the content discovery page to embed.
193
+ * Required model roles object. Object keys should be connection IDs from the embedded Omni instance.
194
+ * Object values should be connection roles.
264
195
  */
265
- path: string;
266
- };
196
+ modelRoles: Record<string, EmbedConnectionRoles>;
197
+ });
267
198
  export type CreateSessionTokenProps = Omit<EmbedSsoContentProps, "prefersDark" | "theme" | "secret" | "nonce"> & {
268
199
  apiKey: string;
269
200
  } & HostProps;