@omni-co/embed 0.7.0 → 0.9.0

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/lib/cjs/embed.js CHANGED
@@ -23,7 +23,7 @@ const createEmbedRequestUrl = (props) => {
23
23
  return url;
24
24
  };
25
25
  const validateProps = (props) => {
26
- const { externalId, name, nonce, secret, userAttributes, customTheme, customThemeId, } = props;
26
+ const { externalId, name, nonce, secret, uiSettings, userAttributes, customTheme, customThemeId, } = props;
27
27
  let host, domain, organizationName;
28
28
  if ("host" in props)
29
29
  host = props.host;
@@ -47,14 +47,17 @@ const validateProps = (props) => {
47
47
  console.warn("`domain` is deprecated and will be removed in a future v1.0.0 release. Use `host` to specify your vanity domain instead (eg `host: 'omni.my-company.com'`).");
48
48
  if (nonce && nonce.length !== 32)
49
49
  throw new Error("nonce must be 32 characters");
50
+ if (typeof uiSettings !== "object" && uiSettings)
51
+ throw new Error("uiSettings must be an object");
50
52
  if (typeof userAttributes !== "object" && userAttributes)
51
53
  throw new Error("userAttributes must be an object");
52
54
  };
53
55
  const embedSsoContent = async (props) => {
54
56
  validateProps(props);
55
- let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, domain, email, externalId, filterSearchParam, host, linkAccess, mode, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, entityFolderContentRole, groups: rawGroups, } = props;
57
+ let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, domain, email, externalId, filterSearchParam, host, linkAccess, mode, name, nonce, organizationName, port, secret, uiSettings: rawUiSettings, userAttributes: rawUserAttributes, entity, prefersDark, theme, entityFolderContentRole, groups: rawGroups, } = props;
56
58
  // Handle defaults
57
59
  nonce = nonce !== null && nonce !== void 0 ? nonce : (await (0, random_str_1.random32ByteString)());
60
+ const uiSettings = rawUiSettings && JSON.stringify(rawUiSettings);
58
61
  const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
59
62
  const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
60
63
  const connectionRoles = rawConnectionRoles && JSON.stringify(rawConnectionRoles);
@@ -89,6 +92,7 @@ const embedSsoContent = async (props) => {
89
92
  mode,
90
93
  prefersDark,
91
94
  theme,
95
+ uiSettings,
92
96
  userAttributes,
93
97
  });
94
98
  // Build and return the signed url
@@ -115,6 +119,7 @@ const embedSsoContent = async (props) => {
115
119
  url.searchParams.append("entityFolderContentRole", entityFolderContentRole);
116
120
  groups && url.searchParams.append("groups", groups);
117
121
  email && url.searchParams.append("email", email);
122
+ uiSettings && url.searchParams.append("uiSettings", uiSettings);
118
123
  return url.toString();
119
124
  };
120
125
  const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
@@ -82,6 +82,10 @@ type SignatureProps = {
82
82
  * The theme of the embed.
83
83
  */
84
84
  theme?: string;
85
+ /**
86
+ * The UI settings for the embedded content.
87
+ */
88
+ uiSettings?: string;
85
89
  /**
86
90
  * The user attributes to be sent with the request. Expected to be a stringified JSON object.
87
91
  *
@@ -96,17 +100,7 @@ export declare const getSignature: ({ secret, ...props }: SignatureProps) => str
96
100
  type RequestUrl = {
97
101
  requestUrl: string;
98
102
  };
99
- type GenerateSessionSignatureProps = Omit<SignatureProps, "loginUrl" | "prefersDark" | "theme"> & RequestUrl;
100
- /**
101
- * Creates a signature value for the /embed/sso/generate-session endpoint.
102
- *
103
- * For context, the /embed/sso/generate-session endpoint is step 1 of the
104
- * embed 2-step login flow. All requests to this endpoint require a signature
105
- * that is generated based on all other request parameters. That signature is
106
- * validated by the Omni app server to ensure the request is authentic.
107
- */
108
- export declare const signSessionRequest: ({ requestUrl, secret, ...props }: GenerateSessionSignatureProps) => string;
109
- type UseSessionSignatureProps = Pick<SignatureProps, "nonce" | "prefersDark" | "theme" | "secret"> & RequestUrl & {
103
+ type SignSessionRedemptionProps = Pick<SignatureProps, "nonce" | "prefersDark" | "theme" | "secret"> & RequestUrl & {
110
104
  sessionId: string;
111
105
  };
112
106
  /**
@@ -117,8 +111,8 @@ type UseSessionSignatureProps = Pick<SignatureProps, "nonce" | "prefersDark" | "
117
111
  * that is generated based on all other request parameters. That signature is
118
112
  * validated by the Omni app server to ensure the request is authentic.
119
113
  */
120
- export declare const signSessionRedemption: ({ requestUrl, nonce, sessionId, secret, prefersDark, theme, }: UseSessionSignatureProps) => string;
114
+ export declare const signSessionRedemption: ({ requestUrl, nonce, sessionId, secret, prefersDark, theme, }: SignSessionRedemptionProps) => string;
121
115
  export declare const TEST_ONLY: {
122
- generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, userAttributes, }: Omit<SignatureProps, "secret">) => string;
116
+ generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, uiSettings, userAttributes, }: Omit<SignatureProps, "secret">) => string;
123
117
  };
124
118
  export {};
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TEST_ONLY = exports.signSessionRedemption = exports.signSessionRequest = exports.getSignature = exports.hmacSign = void 0;
6
+ exports.TEST_ONLY = exports.signSessionRedemption = exports.getSignature = exports.hmacSign = void 0;
7
7
  const crypto_1 = __importDefault(require("crypto"));
8
8
  const base64url_1 = __importDefault(require("base64url"));
9
9
  const hmacSign = (data, secret) => {
@@ -17,7 +17,7 @@ const generateStringForSignature = ({
17
17
  // Required parameters
18
18
  loginUrl, contentPath, externalId, name, nonce,
19
19
  // Optional parameters
20
- accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, userAttributes, }) => {
20
+ accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, uiSettings, userAttributes, }) => {
21
21
  // We create a map of optional params and convert it to an array
22
22
  // to ensure that the order of the optional params is alphabetical and consistent.
23
23
  const optionalParamsMap = {
@@ -34,6 +34,7 @@ accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityF
34
34
  ...(mode && { mode }),
35
35
  ...(prefersDark && { prefersDark }),
36
36
  ...(theme && { theme }),
37
+ ...(uiSettings && { uiSettings }),
37
38
  ...(userAttributes && { userAttributes }),
38
39
  };
39
40
  const optionalParams = Object.keys(optionalParamsMap)
@@ -59,18 +60,6 @@ const getSignature = ({ secret, ...props }) => {
59
60
  return (0, exports.hmacSign)(generateStringForSignature(props), secret);
60
61
  };
61
62
  exports.getSignature = getSignature;
62
- /**
63
- * Creates a signature value for the /embed/sso/generate-session endpoint.
64
- *
65
- * For context, the /embed/sso/generate-session endpoint is step 1 of the
66
- * embed 2-step login flow. All requests to this endpoint require a signature
67
- * that is generated based on all other request parameters. That signature is
68
- * validated by the Omni app server to ensure the request is authentic.
69
- */
70
- const signSessionRequest = ({ requestUrl, secret, ...props }) => {
71
- return (0, exports.getSignature)({ secret, loginUrl: requestUrl, ...props });
72
- };
73
- exports.signSessionRequest = signSessionRequest;
74
63
  /**
75
64
  * Creates a signature value for the /embed/sso/redeem-session endpoint.
76
65
  *
@@ -72,6 +72,7 @@ type EmbedSsoBaseProps = {
72
72
  email?: string;
73
73
  filterSearchParam?: string;
74
74
  linkAccess?: string;
75
+ uiSettings?: Record<EmbedUiSettings, boolean>;
75
76
  nonce?: string;
76
77
  port?: number;
77
78
  } & HostProps;
@@ -202,6 +203,16 @@ export declare enum EmbedEntityFolderContentRoles {
202
203
  EDITOR = "EDITOR",
203
204
  VIEWER = "VIEWER"
204
205
  }
206
+ /**
207
+ * UI settings used as keys of the uiSettings sso embed parameter.
208
+ */
209
+ export declare enum EmbedUiSettings {
210
+ /**
211
+ * When false, hides all in-app navigation elements. Note that in-app navigation
212
+ * is only visible when the embed session is in APPLICATION mode.
213
+ */
214
+ SHOW_NAVIGATION = "showNavigation"
215
+ }
205
216
  export type EmbedSsoContentProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentPathProp;
206
217
  /**
207
218
  * Consumers of this SDK will rely on these three types to embed workbooks and dashboards.
package/lib/cjs/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmbedEntityFolderContentRoles = exports.EmbedConnectionRoles = exports.EmbeddedContent = exports.CustomThemeProperty = exports.EmbedSessionMode = void 0;
3
+ exports.EmbedUiSettings = exports.EmbedEntityFolderContentRoles = exports.EmbedConnectionRoles = exports.EmbeddedContent = exports.CustomThemeProperty = exports.EmbedSessionMode = void 0;
4
4
  var EmbedSessionMode;
5
5
  (function (EmbedSessionMode) {
6
6
  EmbedSessionMode["Application"] = "APPLICATION";
@@ -83,3 +83,14 @@ var EmbedEntityFolderContentRoles;
83
83
  EmbedEntityFolderContentRoles["EDITOR"] = "EDITOR";
84
84
  EmbedEntityFolderContentRoles["VIEWER"] = "VIEWER";
85
85
  })(EmbedEntityFolderContentRoles || (exports.EmbedEntityFolderContentRoles = EmbedEntityFolderContentRoles = {}));
86
+ /**
87
+ * UI settings used as keys of the uiSettings sso embed parameter.
88
+ */
89
+ var EmbedUiSettings;
90
+ (function (EmbedUiSettings) {
91
+ /**
92
+ * When false, hides all in-app navigation elements. Note that in-app navigation
93
+ * is only visible when the embed session is in APPLICATION mode.
94
+ */
95
+ EmbedUiSettings["SHOW_NAVIGATION"] = "showNavigation";
96
+ })(EmbedUiSettings || (exports.EmbedUiSettings = EmbedUiSettings = {}));
package/lib/esm/embed.js CHANGED
@@ -20,7 +20,7 @@ const createEmbedRequestUrl = (props) => {
20
20
  return url;
21
21
  };
22
22
  const validateProps = (props) => {
23
- const { externalId, name, nonce, secret, userAttributes, customTheme, customThemeId, } = props;
23
+ const { externalId, name, nonce, secret, uiSettings, userAttributes, customTheme, customThemeId, } = props;
24
24
  let host, domain, organizationName;
25
25
  if ("host" in props)
26
26
  host = props.host;
@@ -44,14 +44,17 @@ const validateProps = (props) => {
44
44
  console.warn("`domain` is deprecated and will be removed in a future v1.0.0 release. Use `host` to specify your vanity domain instead (eg `host: 'omni.my-company.com'`).");
45
45
  if (nonce && nonce.length !== 32)
46
46
  throw new Error("nonce must be 32 characters");
47
+ if (typeof uiSettings !== "object" && uiSettings)
48
+ throw new Error("uiSettings must be an object");
47
49
  if (typeof userAttributes !== "object" && userAttributes)
48
50
  throw new Error("userAttributes must be an object");
49
51
  };
50
52
  const embedSsoContent = async (props) => {
51
53
  validateProps(props);
52
- let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, domain, email, externalId, filterSearchParam, host, linkAccess, mode, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, entityFolderContentRole, groups: rawGroups, } = props;
54
+ let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, domain, email, externalId, filterSearchParam, host, linkAccess, mode, name, nonce, organizationName, port, secret, uiSettings: rawUiSettings, userAttributes: rawUserAttributes, entity, prefersDark, theme, entityFolderContentRole, groups: rawGroups, } = props;
53
55
  // Handle defaults
54
56
  nonce = nonce !== null && nonce !== void 0 ? nonce : (await random32ByteString());
57
+ const uiSettings = rawUiSettings && JSON.stringify(rawUiSettings);
55
58
  const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
56
59
  const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
57
60
  const connectionRoles = rawConnectionRoles && JSON.stringify(rawConnectionRoles);
@@ -86,6 +89,7 @@ const embedSsoContent = async (props) => {
86
89
  mode,
87
90
  prefersDark,
88
91
  theme,
92
+ uiSettings,
89
93
  userAttributes,
90
94
  });
91
95
  // Build and return the signed url
@@ -112,6 +116,7 @@ const embedSsoContent = async (props) => {
112
116
  url.searchParams.append("entityFolderContentRole", entityFolderContentRole);
113
117
  groups && url.searchParams.append("groups", groups);
114
118
  email && url.searchParams.append("email", email);
119
+ uiSettings && url.searchParams.append("uiSettings", uiSettings);
115
120
  return url.toString();
116
121
  };
117
122
  const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
@@ -82,6 +82,10 @@ type SignatureProps = {
82
82
  * The theme of the embed.
83
83
  */
84
84
  theme?: string;
85
+ /**
86
+ * The UI settings for the embedded content.
87
+ */
88
+ uiSettings?: string;
85
89
  /**
86
90
  * The user attributes to be sent with the request. Expected to be a stringified JSON object.
87
91
  *
@@ -96,17 +100,7 @@ export declare const getSignature: ({ secret, ...props }: SignatureProps) => str
96
100
  type RequestUrl = {
97
101
  requestUrl: string;
98
102
  };
99
- type GenerateSessionSignatureProps = Omit<SignatureProps, "loginUrl" | "prefersDark" | "theme"> & RequestUrl;
100
- /**
101
- * Creates a signature value for the /embed/sso/generate-session endpoint.
102
- *
103
- * For context, the /embed/sso/generate-session endpoint is step 1 of the
104
- * embed 2-step login flow. All requests to this endpoint require a signature
105
- * that is generated based on all other request parameters. That signature is
106
- * validated by the Omni app server to ensure the request is authentic.
107
- */
108
- export declare const signSessionRequest: ({ requestUrl, secret, ...props }: GenerateSessionSignatureProps) => string;
109
- type UseSessionSignatureProps = Pick<SignatureProps, "nonce" | "prefersDark" | "theme" | "secret"> & RequestUrl & {
103
+ type SignSessionRedemptionProps = Pick<SignatureProps, "nonce" | "prefersDark" | "theme" | "secret"> & RequestUrl & {
110
104
  sessionId: string;
111
105
  };
112
106
  /**
@@ -117,8 +111,8 @@ type UseSessionSignatureProps = Pick<SignatureProps, "nonce" | "prefersDark" | "
117
111
  * that is generated based on all other request parameters. That signature is
118
112
  * validated by the Omni app server to ensure the request is authentic.
119
113
  */
120
- export declare const signSessionRedemption: ({ requestUrl, nonce, sessionId, secret, prefersDark, theme, }: UseSessionSignatureProps) => string;
114
+ export declare const signSessionRedemption: ({ requestUrl, nonce, sessionId, secret, prefersDark, theme, }: SignSessionRedemptionProps) => string;
121
115
  export declare const TEST_ONLY: {
122
- generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, userAttributes, }: Omit<SignatureProps, "secret">) => string;
116
+ generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, uiSettings, userAttributes, }: Omit<SignatureProps, "secret">) => string;
123
117
  };
124
118
  export {};
@@ -10,7 +10,7 @@ const generateStringForSignature = ({
10
10
  // Required parameters
11
11
  loginUrl, contentPath, externalId, name, nonce,
12
12
  // Optional parameters
13
- accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, userAttributes, }) => {
13
+ accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, uiSettings, userAttributes, }) => {
14
14
  // We create a map of optional params and convert it to an array
15
15
  // to ensure that the order of the optional params is alphabetical and consistent.
16
16
  const optionalParamsMap = {
@@ -27,6 +27,7 @@ accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityF
27
27
  ...(mode && { mode }),
28
28
  ...(prefersDark && { prefersDark }),
29
29
  ...(theme && { theme }),
30
+ ...(uiSettings && { uiSettings }),
30
31
  ...(userAttributes && { userAttributes }),
31
32
  };
32
33
  const optionalParams = Object.keys(optionalParamsMap)
@@ -51,17 +52,6 @@ accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityF
51
52
  export const getSignature = ({ secret, ...props }) => {
52
53
  return hmacSign(generateStringForSignature(props), secret);
53
54
  };
54
- /**
55
- * Creates a signature value for the /embed/sso/generate-session endpoint.
56
- *
57
- * For context, the /embed/sso/generate-session endpoint is step 1 of the
58
- * embed 2-step login flow. All requests to this endpoint require a signature
59
- * that is generated based on all other request parameters. That signature is
60
- * validated by the Omni app server to ensure the request is authentic.
61
- */
62
- export const signSessionRequest = ({ requestUrl, secret, ...props }) => {
63
- return getSignature({ secret, loginUrl: requestUrl, ...props });
64
- };
65
55
  /**
66
56
  * Creates a signature value for the /embed/sso/redeem-session endpoint.
67
57
  *
@@ -72,6 +72,7 @@ type EmbedSsoBaseProps = {
72
72
  email?: string;
73
73
  filterSearchParam?: string;
74
74
  linkAccess?: string;
75
+ uiSettings?: Record<EmbedUiSettings, boolean>;
75
76
  nonce?: string;
76
77
  port?: number;
77
78
  } & HostProps;
@@ -202,6 +203,16 @@ export declare enum EmbedEntityFolderContentRoles {
202
203
  EDITOR = "EDITOR",
203
204
  VIEWER = "VIEWER"
204
205
  }
206
+ /**
207
+ * UI settings used as keys of the uiSettings sso embed parameter.
208
+ */
209
+ export declare enum EmbedUiSettings {
210
+ /**
211
+ * When false, hides all in-app navigation elements. Note that in-app navigation
212
+ * is only visible when the embed session is in APPLICATION mode.
213
+ */
214
+ SHOW_NAVIGATION = "showNavigation"
215
+ }
205
216
  export type EmbedSsoContentProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentPathProp;
206
217
  /**
207
218
  * Consumers of this SDK will rely on these three types to embed workbooks and dashboards.
package/lib/esm/types.js CHANGED
@@ -80,3 +80,14 @@ export var EmbedEntityFolderContentRoles;
80
80
  EmbedEntityFolderContentRoles["EDITOR"] = "EDITOR";
81
81
  EmbedEntityFolderContentRoles["VIEWER"] = "VIEWER";
82
82
  })(EmbedEntityFolderContentRoles || (EmbedEntityFolderContentRoles = {}));
83
+ /**
84
+ * UI settings used as keys of the uiSettings sso embed parameter.
85
+ */
86
+ export var EmbedUiSettings;
87
+ (function (EmbedUiSettings) {
88
+ /**
89
+ * When false, hides all in-app navigation elements. Note that in-app navigation
90
+ * is only visible when the embed session is in APPLICATION mode.
91
+ */
92
+ EmbedUiSettings["SHOW_NAVIGATION"] = "showNavigation";
93
+ })(EmbedUiSettings || (EmbedUiSettings = {}));
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.7.0",
2
+ "version": "0.9.0",
3
3
  "license": "MIT",
4
4
  "name": "@omni-co/embed",
5
5
  "author": "Nate Agrin <nate@exploreomni.com>",