@omni-co/embed 0.3.14 → 0.3.16
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 +51 -3
- package/lib/cjs/embed.js +3 -1
- package/lib/cjs/signature.d.ts +5 -1
- package/lib/cjs/signature.js +19 -12
- package/lib/cjs/types.d.ts +3 -0
- package/lib/esm/embed.js +3 -1
- package/lib/esm/signature.d.ts +5 -1
- package/lib/esm/signature.js +19 -12
- package/lib/esm/types.d.ts +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ yarn add @omni-co/embed
|
|
|
17
17
|
## Basic Example
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
|
-
import { embedSsoDashboard } from "@omni-co/embed";
|
|
20
|
+
import { embedSsoDashboard, embedSsoWorkbook } from "@omni-co/embed";
|
|
21
21
|
|
|
22
22
|
// This creates a signed embed sso link for a dashboard
|
|
23
23
|
// in the omni account named Acme.
|
|
@@ -28,12 +28,21 @@ const iframeUrl = await embedSsoDashboard({
|
|
|
28
28
|
organizationName: "acme",
|
|
29
29
|
secret: "abcdefghijklmnopqrstuvwxyz123456",
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
// Alternatively you can create a signed embed sso link for a workbook
|
|
33
|
+
onst iframeUrl = await embedSsoWorkbook({
|
|
34
|
+
contentId: "miU0hL6z",
|
|
35
|
+
externalId: "wile.e@coyote.co",
|
|
36
|
+
name: "Wile E",
|
|
37
|
+
organizationName: "acme",
|
|
38
|
+
secret: "abcdefghijklmnopqrstuvwxyz123456",
|
|
39
|
+
});
|
|
31
40
|
```
|
|
32
41
|
|
|
33
42
|
## Kitchen Sink Example
|
|
34
43
|
|
|
35
44
|
```ts
|
|
36
|
-
import { embedSsoDashboard } from "@omni-co/embed";
|
|
45
|
+
import { embedSsoDashboard, embedSsoWorkbook } from "@omni-co/embed";
|
|
37
46
|
|
|
38
47
|
// This creates a signed embed sso link for a dashboard
|
|
39
48
|
// in the omni account named Acme.
|
|
@@ -52,7 +61,7 @@ const iframeUrl = await embedSsoDashboard({
|
|
|
52
61
|
|
|
53
62
|
## embedSsoDashboard
|
|
54
63
|
|
|
55
|
-
This is the type signature for the embedSsoDashboard function:
|
|
64
|
+
This is the type signature for the `embedSsoDashboard` function:
|
|
56
65
|
|
|
57
66
|
```ts
|
|
58
67
|
type EmbedSsoProps = {
|
|
@@ -102,3 +111,42 @@ type EmbedSsoProps = {
|
|
|
102
111
|
customTheme?: CustomThemeProperties;
|
|
103
112
|
};
|
|
104
113
|
```
|
|
114
|
+
|
|
115
|
+
## embedSsoWorkbook
|
|
116
|
+
|
|
117
|
+
This is the type signature for the `embedSsoWorkbook` function:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
type EmbedSsoProps = {
|
|
121
|
+
// Short GUID of the workbook. Can be obtained via the workbook's share -> embed -> iframe url or via the dashboard url (will embed the workbook associated with the dashboard id)
|
|
122
|
+
contentId: string;
|
|
123
|
+
|
|
124
|
+
// Required identifier to associate the external user with an
|
|
125
|
+
// automatically generated internal Omni user.
|
|
126
|
+
externalId: string;
|
|
127
|
+
|
|
128
|
+
// Required name of the external user.
|
|
129
|
+
name: string;
|
|
130
|
+
|
|
131
|
+
// Required Omni organization which contains the workbook.
|
|
132
|
+
organizationName: string;
|
|
133
|
+
|
|
134
|
+
// Signing secret available to Omni admins.
|
|
135
|
+
secret: string;
|
|
136
|
+
|
|
137
|
+
// Optional identifier to associate the user with an external
|
|
138
|
+
// organization or system.
|
|
139
|
+
entity?: string;
|
|
140
|
+
|
|
141
|
+
// Optional user attributes to be passed to user associated with the
|
|
142
|
+
// externalId. User attributes must be created in Omni before being
|
|
143
|
+
// defined and given a value here.
|
|
144
|
+
userAttributes?: Record<string, string | string[] | number | number[]>;
|
|
145
|
+
|
|
146
|
+
// Optional dark mode setting. Can be one of "true", "false", or "system".
|
|
147
|
+
prefersDark?: string;
|
|
148
|
+
|
|
149
|
+
// Optional theme setting. Can be one of "dawn", "vibes", "breeze" or "blank".
|
|
150
|
+
theme?: string;
|
|
151
|
+
};
|
|
152
|
+
```
|
package/lib/cjs/embed.js
CHANGED
|
@@ -31,7 +31,7 @@ const validateProps = (props) => {
|
|
|
31
31
|
};
|
|
32
32
|
const embedSsoContent = async (props) => {
|
|
33
33
|
validateProps(props);
|
|
34
|
-
let { connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, domain, externalId, filterSearchParam, linkAccess, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
|
|
34
|
+
let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, domain, externalId, filterSearchParam, linkAccess, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
|
|
35
35
|
// Handle defaults
|
|
36
36
|
nonce = nonce !== null && nonce !== void 0 ? nonce : (await (0, random_str_1.random32ByteString)());
|
|
37
37
|
domain = domain !== null && domain !== void 0 ? domain : defaultEmbedDomain;
|
|
@@ -56,6 +56,7 @@ const embedSsoContent = async (props) => {
|
|
|
56
56
|
linkAccess,
|
|
57
57
|
customTheme,
|
|
58
58
|
connectionRoles,
|
|
59
|
+
accessBoost,
|
|
59
60
|
});
|
|
60
61
|
// Build and return the signed url
|
|
61
62
|
url.searchParams.append("contentPath", contentPath);
|
|
@@ -64,6 +65,7 @@ const embedSsoContent = async (props) => {
|
|
|
64
65
|
url.searchParams.append("nonce", nonce);
|
|
65
66
|
url.searchParams.append("signature", signature);
|
|
66
67
|
userAttributes && url.searchParams.append("userAttributes", userAttributes);
|
|
68
|
+
accessBoost && url.searchParams.append("accessBoost", accessBoost.toString());
|
|
67
69
|
entity && url.searchParams.append("entity", entity);
|
|
68
70
|
prefersDark && url.searchParams.append("prefersDark", prefersDark);
|
|
69
71
|
theme && url.searchParams.append("theme", theme);
|
package/lib/cjs/signature.d.ts
CHANGED
|
@@ -28,6 +28,10 @@ type SignatureProps = {
|
|
|
28
28
|
* The secret used to sign the request
|
|
29
29
|
*/
|
|
30
30
|
secret: string;
|
|
31
|
+
/**
|
|
32
|
+
* The access boost setting for content specified in this Embed SSO URL.
|
|
33
|
+
*/
|
|
34
|
+
accessBoost?: boolean;
|
|
31
35
|
/**
|
|
32
36
|
* The connection roles to be associated with the embed user. Expected to be a stringified JSON object.
|
|
33
37
|
*/
|
|
@@ -68,6 +72,6 @@ type SignatureProps = {
|
|
|
68
72
|
};
|
|
69
73
|
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
70
74
|
export declare const TEST_ONLY: {
|
|
71
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, }: Omit<SignatureProps, "secret">) => string;
|
|
75
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, accessBoost, }: Omit<SignatureProps, "secret">) => string;
|
|
72
76
|
};
|
|
73
77
|
export {};
|
package/lib/cjs/signature.js
CHANGED
|
@@ -17,18 +17,25 @@ const generateStringForSignature = ({
|
|
|
17
17
|
// Required parameters
|
|
18
18
|
loginUrl, contentPath, externalId, name, nonce,
|
|
19
19
|
// Optional parameters
|
|
20
|
-
connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, }) => {
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, accessBoost, }) => {
|
|
21
|
+
// We create a map of optional params and convert it to an array
|
|
22
|
+
// to ensure that the order of the optional params is alphabetical and consistent.
|
|
23
|
+
const optionalParamsMap = {
|
|
24
|
+
...(accessBoost && { accessBoost: accessBoost === null || accessBoost === void 0 ? void 0 : accessBoost.toString() }),
|
|
25
|
+
...(connectionRoles && { connectionRoles }),
|
|
26
|
+
...(customTheme && { customTheme }),
|
|
27
|
+
...(entity && { entity }),
|
|
28
|
+
...(filterSearchParam && { filterSearchParam }),
|
|
29
|
+
...(linkAccess && { linkAccess }),
|
|
30
|
+
...(prefersDark && { prefersDark }),
|
|
31
|
+
...(theme && { theme }),
|
|
32
|
+
...(userAttributes && { userAttributes }),
|
|
33
|
+
};
|
|
34
|
+
const optionalParams = Object.keys(optionalParamsMap)
|
|
35
|
+
.sort() // guarantees the order of the optional params is Alphabetical
|
|
36
|
+
.map((key) => {
|
|
37
|
+
return optionalParamsMap[key];
|
|
38
|
+
});
|
|
32
39
|
return `
|
|
33
40
|
${loginUrl}
|
|
34
41
|
${contentPath}
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ type EmbedSsoBaseProps = {
|
|
|
13
13
|
port?: number;
|
|
14
14
|
};
|
|
15
15
|
type EmbedSsoDashboardOnlyProps = {
|
|
16
|
+
accessBoost?: boolean;
|
|
16
17
|
filterSearchParam?: string;
|
|
17
18
|
linkAccess?: string;
|
|
18
19
|
customTheme?: CustomThemeProperties;
|
|
@@ -43,6 +44,8 @@ export type CustomThemeProperties = {
|
|
|
43
44
|
"dashboard-tile-text-code-font-family"?: string;
|
|
44
45
|
"dashboard-key-color"?: string;
|
|
45
46
|
"dashboard-key-text-color"?: string;
|
|
47
|
+
"dashboard-control-background"?: string;
|
|
48
|
+
"dashboard-control-popover-background"?: string;
|
|
46
49
|
};
|
|
47
50
|
export declare enum EmbeddedContent {
|
|
48
51
|
Dashboard = "dashboards",
|
package/lib/esm/embed.js
CHANGED
|
@@ -28,7 +28,7 @@ const validateProps = (props) => {
|
|
|
28
28
|
};
|
|
29
29
|
const embedSsoContent = async (props) => {
|
|
30
30
|
validateProps(props);
|
|
31
|
-
let { connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, domain, externalId, filterSearchParam, linkAccess, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
|
|
31
|
+
let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, domain, externalId, filterSearchParam, linkAccess, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
|
|
32
32
|
// Handle defaults
|
|
33
33
|
nonce = nonce !== null && nonce !== void 0 ? nonce : (await random32ByteString());
|
|
34
34
|
domain = domain !== null && domain !== void 0 ? domain : defaultEmbedDomain;
|
|
@@ -53,6 +53,7 @@ const embedSsoContent = async (props) => {
|
|
|
53
53
|
linkAccess,
|
|
54
54
|
customTheme,
|
|
55
55
|
connectionRoles,
|
|
56
|
+
accessBoost,
|
|
56
57
|
});
|
|
57
58
|
// Build and return the signed url
|
|
58
59
|
url.searchParams.append("contentPath", contentPath);
|
|
@@ -61,6 +62,7 @@ const embedSsoContent = async (props) => {
|
|
|
61
62
|
url.searchParams.append("nonce", nonce);
|
|
62
63
|
url.searchParams.append("signature", signature);
|
|
63
64
|
userAttributes && url.searchParams.append("userAttributes", userAttributes);
|
|
65
|
+
accessBoost && url.searchParams.append("accessBoost", accessBoost.toString());
|
|
64
66
|
entity && url.searchParams.append("entity", entity);
|
|
65
67
|
prefersDark && url.searchParams.append("prefersDark", prefersDark);
|
|
66
68
|
theme && url.searchParams.append("theme", theme);
|
package/lib/esm/signature.d.ts
CHANGED
|
@@ -28,6 +28,10 @@ type SignatureProps = {
|
|
|
28
28
|
* The secret used to sign the request
|
|
29
29
|
*/
|
|
30
30
|
secret: string;
|
|
31
|
+
/**
|
|
32
|
+
* The access boost setting for content specified in this Embed SSO URL.
|
|
33
|
+
*/
|
|
34
|
+
accessBoost?: boolean;
|
|
31
35
|
/**
|
|
32
36
|
* The connection roles to be associated with the embed user. Expected to be a stringified JSON object.
|
|
33
37
|
*/
|
|
@@ -68,6 +72,6 @@ type SignatureProps = {
|
|
|
68
72
|
};
|
|
69
73
|
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
70
74
|
export declare const TEST_ONLY: {
|
|
71
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, }: Omit<SignatureProps, "secret">) => string;
|
|
75
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, accessBoost, }: Omit<SignatureProps, "secret">) => string;
|
|
72
76
|
};
|
|
73
77
|
export {};
|
package/lib/esm/signature.js
CHANGED
|
@@ -10,18 +10,25 @@ const generateStringForSignature = ({
|
|
|
10
10
|
// Required parameters
|
|
11
11
|
loginUrl, contentPath, externalId, name, nonce,
|
|
12
12
|
// Optional parameters
|
|
13
|
-
connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, }) => {
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, accessBoost, }) => {
|
|
14
|
+
// We create a map of optional params and convert it to an array
|
|
15
|
+
// to ensure that the order of the optional params is alphabetical and consistent.
|
|
16
|
+
const optionalParamsMap = {
|
|
17
|
+
...(accessBoost && { accessBoost: accessBoost === null || accessBoost === void 0 ? void 0 : accessBoost.toString() }),
|
|
18
|
+
...(connectionRoles && { connectionRoles }),
|
|
19
|
+
...(customTheme && { customTheme }),
|
|
20
|
+
...(entity && { entity }),
|
|
21
|
+
...(filterSearchParam && { filterSearchParam }),
|
|
22
|
+
...(linkAccess && { linkAccess }),
|
|
23
|
+
...(prefersDark && { prefersDark }),
|
|
24
|
+
...(theme && { theme }),
|
|
25
|
+
...(userAttributes && { userAttributes }),
|
|
26
|
+
};
|
|
27
|
+
const optionalParams = Object.keys(optionalParamsMap)
|
|
28
|
+
.sort() // guarantees the order of the optional params is Alphabetical
|
|
29
|
+
.map((key) => {
|
|
30
|
+
return optionalParamsMap[key];
|
|
31
|
+
});
|
|
25
32
|
return `
|
|
26
33
|
${loginUrl}
|
|
27
34
|
${contentPath}
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ type EmbedSsoBaseProps = {
|
|
|
13
13
|
port?: number;
|
|
14
14
|
};
|
|
15
15
|
type EmbedSsoDashboardOnlyProps = {
|
|
16
|
+
accessBoost?: boolean;
|
|
16
17
|
filterSearchParam?: string;
|
|
17
18
|
linkAccess?: string;
|
|
18
19
|
customTheme?: CustomThemeProperties;
|
|
@@ -43,6 +44,8 @@ export type CustomThemeProperties = {
|
|
|
43
44
|
"dashboard-tile-text-code-font-family"?: string;
|
|
44
45
|
"dashboard-key-color"?: string;
|
|
45
46
|
"dashboard-key-text-color"?: string;
|
|
47
|
+
"dashboard-control-background"?: string;
|
|
48
|
+
"dashboard-control-popover-background"?: string;
|
|
46
49
|
};
|
|
47
50
|
export declare enum EmbeddedContent {
|
|
48
51
|
Dashboard = "dashboards",
|
package/package.json
CHANGED