@omni-co/embed 0.3.13 → 0.3.15
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 +7 -1
- package/lib/cjs/signature.d.ts +23 -15
- package/lib/cjs/signature.js +23 -9
- package/lib/cjs/types.d.ts +9 -2
- package/lib/cjs/types.js +8 -1
- package/lib/esm/embed.js +7 -1
- package/lib/esm/signature.d.ts +23 -15
- package/lib/esm/signature.js +23 -9
- package/lib/esm/types.d.ts +9 -2
- package/lib/esm/types.js +7 -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,12 +31,13 @@ const validateProps = (props) => {
|
|
|
31
31
|
};
|
|
32
32
|
const embedSsoContent = async (props) => {
|
|
33
33
|
validateProps(props);
|
|
34
|
-
let { 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;
|
|
38
38
|
const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
|
|
39
39
|
const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
|
|
40
|
+
const connectionRoles = rawConnectionRoles && JSON.stringify(rawConnectionRoles);
|
|
40
41
|
// Generate the url for the embed login route
|
|
41
42
|
const url = new URL(embedLoginPath, `https://${organizationName.toLocaleLowerCase()}.${domain}${port ? `:${port}` : ""}`);
|
|
42
43
|
// Get a signature for the request
|
|
@@ -54,6 +55,8 @@ const embedSsoContent = async (props) => {
|
|
|
54
55
|
filterSearchParam,
|
|
55
56
|
linkAccess,
|
|
56
57
|
customTheme,
|
|
58
|
+
connectionRoles,
|
|
59
|
+
accessBoost,
|
|
57
60
|
});
|
|
58
61
|
// Build and return the signed url
|
|
59
62
|
url.searchParams.append("contentPath", contentPath);
|
|
@@ -62,6 +65,7 @@ const embedSsoContent = async (props) => {
|
|
|
62
65
|
url.searchParams.append("nonce", nonce);
|
|
63
66
|
url.searchParams.append("signature", signature);
|
|
64
67
|
userAttributes && url.searchParams.append("userAttributes", userAttributes);
|
|
68
|
+
accessBoost && url.searchParams.append("accessBoost", accessBoost.toString());
|
|
65
69
|
entity && url.searchParams.append("entity", entity);
|
|
66
70
|
prefersDark && url.searchParams.append("prefersDark", prefersDark);
|
|
67
71
|
theme && url.searchParams.append("theme", theme);
|
|
@@ -69,6 +73,8 @@ const embedSsoContent = async (props) => {
|
|
|
69
73
|
url.searchParams.append("filterSearchParam", filterSearchParam);
|
|
70
74
|
linkAccess && url.searchParams.append("linkAccess", linkAccess);
|
|
71
75
|
customTheme && url.searchParams.append("customTheme", customTheme);
|
|
76
|
+
connectionRoles &&
|
|
77
|
+
url.searchParams.append("connectionRoles", connectionRoles);
|
|
72
78
|
return url.toString();
|
|
73
79
|
};
|
|
74
80
|
const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
|
package/lib/cjs/signature.d.ts
CHANGED
|
@@ -29,24 +29,24 @@ type SignatureProps = {
|
|
|
29
29
|
*/
|
|
30
30
|
secret: string;
|
|
31
31
|
/**
|
|
32
|
-
* The
|
|
33
|
-
*
|
|
34
|
-
* Example: '{ "team": "Lakers" }'
|
|
32
|
+
* The access boost setting for content specified in this Embed SSO URL.
|
|
35
33
|
*/
|
|
36
|
-
|
|
34
|
+
accessBoost?: boolean;
|
|
37
35
|
/**
|
|
38
|
-
* The
|
|
39
|
-
* user will this value assigned to its omni_user_embed_entity user attribute.
|
|
36
|
+
* The connection roles to be associated with the embed user. Expected to be a stringified JSON object.
|
|
40
37
|
*/
|
|
41
|
-
|
|
38
|
+
connectionRoles?: string;
|
|
42
39
|
/**
|
|
43
|
-
*
|
|
40
|
+
* The custom theme to be sent with the request. Expected to be a stringified JSON object.
|
|
41
|
+
*
|
|
42
|
+
* Example: '{ "dashboard-background-color": "hotpink" }'
|
|
44
43
|
*/
|
|
45
|
-
|
|
44
|
+
customTheme?: string;
|
|
46
45
|
/**
|
|
47
|
-
* The
|
|
46
|
+
* The entity that the created embed user will belong to. Practically speaking, the embed
|
|
47
|
+
* user will this value assigned to its omni_user_embed_entity user attribute.
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
entity?: string;
|
|
50
50
|
/**
|
|
51
51
|
* Filter search parameter.
|
|
52
52
|
*/
|
|
@@ -56,14 +56,22 @@ type SignatureProps = {
|
|
|
56
56
|
*/
|
|
57
57
|
linkAccess?: string;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* Whether the user prefers light, dark, or system theme.
|
|
60
|
+
*/
|
|
61
|
+
prefersDark?: string;
|
|
62
|
+
/**
|
|
63
|
+
* The theme of the embed.
|
|
64
|
+
*/
|
|
65
|
+
theme?: string;
|
|
66
|
+
/**
|
|
67
|
+
* The user attributes to be sent with the request. Expected to be a stringified JSON object.
|
|
60
68
|
*
|
|
61
|
-
* Example: '{ "
|
|
69
|
+
* Example: '{ "team": "Lakers" }'
|
|
62
70
|
*/
|
|
63
|
-
|
|
71
|
+
userAttributes?: string;
|
|
64
72
|
};
|
|
65
73
|
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
66
74
|
export declare const TEST_ONLY: {
|
|
67
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce,
|
|
75
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, accessBoost, }: Omit<SignatureProps, "secret">) => string;
|
|
68
76
|
};
|
|
69
77
|
export {};
|
package/lib/cjs/signature.js
CHANGED
|
@@ -13,15 +13,29 @@ const hmacSign = (data, secret) => {
|
|
|
13
13
|
return base64url_1.default.fromBase64(b64);
|
|
14
14
|
};
|
|
15
15
|
exports.hmacSign = hmacSign;
|
|
16
|
-
const generateStringForSignature = ({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
const generateStringForSignature = ({
|
|
17
|
+
// Required parameters
|
|
18
|
+
loginUrl, contentPath, externalId, name, nonce,
|
|
19
|
+
// Optional parameters
|
|
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
|
+
});
|
|
25
39
|
return `
|
|
26
40
|
${loginUrl}
|
|
27
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;
|
|
@@ -23,6 +24,9 @@ type EmbedContentIdProp = {
|
|
|
23
24
|
type EmbedContentPathProp = {
|
|
24
25
|
contentPath: string;
|
|
25
26
|
};
|
|
27
|
+
type EmbedConnectionRolesProp = {
|
|
28
|
+
connectionRoles: Record<string, EmbedConnectionRoles>;
|
|
29
|
+
};
|
|
26
30
|
export type CustomThemeProperties = {
|
|
27
31
|
"dashboard-background"?: string;
|
|
28
32
|
"dashboard-tile-background"?: string;
|
|
@@ -47,13 +51,16 @@ export declare enum EmbeddedContent {
|
|
|
47
51
|
}
|
|
48
52
|
export declare const EmbedSsoContentDiscoveryPaths: readonly ["my"];
|
|
49
53
|
export type EmbedSsoContentDiscoveryPath = (typeof EmbedSsoContentDiscoveryPaths)[number];
|
|
50
|
-
export
|
|
54
|
+
export declare enum EmbedConnectionRoles {
|
|
55
|
+
RESTRICTED_QUERIER = "RESTRICTED_QUERIER"
|
|
56
|
+
}
|
|
57
|
+
export type EmbedSsoContentProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentPathProp & Partial<EmbedConnectionRolesProp>;
|
|
51
58
|
/**
|
|
52
59
|
* Consumers of this SDK will rely on these three types to embed workbooks and dashboards.
|
|
53
60
|
*/
|
|
54
61
|
export type EmbedSsoDashboardProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentIdProp;
|
|
55
62
|
export type EmbedSsoWorkbookProps = EmbedSsoBaseProps & EmbedContentIdProp;
|
|
56
|
-
export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
|
|
63
|
+
export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & EmbedConnectionRolesProp & {
|
|
57
64
|
/**
|
|
58
65
|
* Path name of the content discovery page to embed.
|
|
59
66
|
*/
|
package/lib/cjs/types.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EmbedSsoContentDiscoveryPaths = exports.EmbeddedContent = void 0;
|
|
3
|
+
exports.EmbedConnectionRoles = exports.EmbedSsoContentDiscoveryPaths = exports.EmbeddedContent = void 0;
|
|
4
4
|
var EmbeddedContent;
|
|
5
5
|
(function (EmbeddedContent) {
|
|
6
6
|
EmbeddedContent["Dashboard"] = "dashboards";
|
|
7
7
|
EmbeddedContent["Workbook"] = "w";
|
|
8
8
|
})(EmbeddedContent || (exports.EmbeddedContent = EmbeddedContent = {}));
|
|
9
9
|
exports.EmbedSsoContentDiscoveryPaths = ["my"];
|
|
10
|
+
var EmbedConnectionRoles;
|
|
11
|
+
(function (EmbedConnectionRoles) {
|
|
12
|
+
// TODO: Eventually we'll want to add VIEWER. Currently though, since the sole use case of the
|
|
13
|
+
// connectionRoles parameter is personal content creation, I'm refraining from adding "VIEWER" to
|
|
14
|
+
// keep scope as limited as possible.
|
|
15
|
+
EmbedConnectionRoles["RESTRICTED_QUERIER"] = "RESTRICTED_QUERIER";
|
|
16
|
+
})(EmbedConnectionRoles || (exports.EmbedConnectionRoles = EmbedConnectionRoles = {}));
|
package/lib/esm/embed.js
CHANGED
|
@@ -28,12 +28,13 @@ const validateProps = (props) => {
|
|
|
28
28
|
};
|
|
29
29
|
const embedSsoContent = async (props) => {
|
|
30
30
|
validateProps(props);
|
|
31
|
-
let { 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;
|
|
35
35
|
const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
|
|
36
36
|
const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
|
|
37
|
+
const connectionRoles = rawConnectionRoles && JSON.stringify(rawConnectionRoles);
|
|
37
38
|
// Generate the url for the embed login route
|
|
38
39
|
const url = new URL(embedLoginPath, `https://${organizationName.toLocaleLowerCase()}.${domain}${port ? `:${port}` : ""}`);
|
|
39
40
|
// Get a signature for the request
|
|
@@ -51,6 +52,8 @@ const embedSsoContent = async (props) => {
|
|
|
51
52
|
filterSearchParam,
|
|
52
53
|
linkAccess,
|
|
53
54
|
customTheme,
|
|
55
|
+
connectionRoles,
|
|
56
|
+
accessBoost,
|
|
54
57
|
});
|
|
55
58
|
// Build and return the signed url
|
|
56
59
|
url.searchParams.append("contentPath", contentPath);
|
|
@@ -59,6 +62,7 @@ const embedSsoContent = async (props) => {
|
|
|
59
62
|
url.searchParams.append("nonce", nonce);
|
|
60
63
|
url.searchParams.append("signature", signature);
|
|
61
64
|
userAttributes && url.searchParams.append("userAttributes", userAttributes);
|
|
65
|
+
accessBoost && url.searchParams.append("accessBoost", accessBoost.toString());
|
|
62
66
|
entity && url.searchParams.append("entity", entity);
|
|
63
67
|
prefersDark && url.searchParams.append("prefersDark", prefersDark);
|
|
64
68
|
theme && url.searchParams.append("theme", theme);
|
|
@@ -66,6 +70,8 @@ const embedSsoContent = async (props) => {
|
|
|
66
70
|
url.searchParams.append("filterSearchParam", filterSearchParam);
|
|
67
71
|
linkAccess && url.searchParams.append("linkAccess", linkAccess);
|
|
68
72
|
customTheme && url.searchParams.append("customTheme", customTheme);
|
|
73
|
+
connectionRoles &&
|
|
74
|
+
url.searchParams.append("connectionRoles", connectionRoles);
|
|
69
75
|
return url.toString();
|
|
70
76
|
};
|
|
71
77
|
const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
|
package/lib/esm/signature.d.ts
CHANGED
|
@@ -29,24 +29,24 @@ type SignatureProps = {
|
|
|
29
29
|
*/
|
|
30
30
|
secret: string;
|
|
31
31
|
/**
|
|
32
|
-
* The
|
|
33
|
-
*
|
|
34
|
-
* Example: '{ "team": "Lakers" }'
|
|
32
|
+
* The access boost setting for content specified in this Embed SSO URL.
|
|
35
33
|
*/
|
|
36
|
-
|
|
34
|
+
accessBoost?: boolean;
|
|
37
35
|
/**
|
|
38
|
-
* The
|
|
39
|
-
* user will this value assigned to its omni_user_embed_entity user attribute.
|
|
36
|
+
* The connection roles to be associated with the embed user. Expected to be a stringified JSON object.
|
|
40
37
|
*/
|
|
41
|
-
|
|
38
|
+
connectionRoles?: string;
|
|
42
39
|
/**
|
|
43
|
-
*
|
|
40
|
+
* The custom theme to be sent with the request. Expected to be a stringified JSON object.
|
|
41
|
+
*
|
|
42
|
+
* Example: '{ "dashboard-background-color": "hotpink" }'
|
|
44
43
|
*/
|
|
45
|
-
|
|
44
|
+
customTheme?: string;
|
|
46
45
|
/**
|
|
47
|
-
* The
|
|
46
|
+
* The entity that the created embed user will belong to. Practically speaking, the embed
|
|
47
|
+
* user will this value assigned to its omni_user_embed_entity user attribute.
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
entity?: string;
|
|
50
50
|
/**
|
|
51
51
|
* Filter search parameter.
|
|
52
52
|
*/
|
|
@@ -56,14 +56,22 @@ type SignatureProps = {
|
|
|
56
56
|
*/
|
|
57
57
|
linkAccess?: string;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* Whether the user prefers light, dark, or system theme.
|
|
60
|
+
*/
|
|
61
|
+
prefersDark?: string;
|
|
62
|
+
/**
|
|
63
|
+
* The theme of the embed.
|
|
64
|
+
*/
|
|
65
|
+
theme?: string;
|
|
66
|
+
/**
|
|
67
|
+
* The user attributes to be sent with the request. Expected to be a stringified JSON object.
|
|
60
68
|
*
|
|
61
|
-
* Example: '{ "
|
|
69
|
+
* Example: '{ "team": "Lakers" }'
|
|
62
70
|
*/
|
|
63
|
-
|
|
71
|
+
userAttributes?: string;
|
|
64
72
|
};
|
|
65
73
|
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
66
74
|
export declare const TEST_ONLY: {
|
|
67
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce,
|
|
75
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, accessBoost, }: Omit<SignatureProps, "secret">) => string;
|
|
68
76
|
};
|
|
69
77
|
export {};
|
package/lib/esm/signature.js
CHANGED
|
@@ -6,15 +6,29 @@ export const hmacSign = (data, secret) => {
|
|
|
6
6
|
const b64 = hmac.digest("base64");
|
|
7
7
|
return base64url.fromBase64(b64);
|
|
8
8
|
};
|
|
9
|
-
const generateStringForSignature = ({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
const generateStringForSignature = ({
|
|
10
|
+
// Required parameters
|
|
11
|
+
loginUrl, contentPath, externalId, name, nonce,
|
|
12
|
+
// Optional parameters
|
|
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
|
+
});
|
|
18
32
|
return `
|
|
19
33
|
${loginUrl}
|
|
20
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;
|
|
@@ -23,6 +24,9 @@ type EmbedContentIdProp = {
|
|
|
23
24
|
type EmbedContentPathProp = {
|
|
24
25
|
contentPath: string;
|
|
25
26
|
};
|
|
27
|
+
type EmbedConnectionRolesProp = {
|
|
28
|
+
connectionRoles: Record<string, EmbedConnectionRoles>;
|
|
29
|
+
};
|
|
26
30
|
export type CustomThemeProperties = {
|
|
27
31
|
"dashboard-background"?: string;
|
|
28
32
|
"dashboard-tile-background"?: string;
|
|
@@ -47,13 +51,16 @@ export declare enum EmbeddedContent {
|
|
|
47
51
|
}
|
|
48
52
|
export declare const EmbedSsoContentDiscoveryPaths: readonly ["my"];
|
|
49
53
|
export type EmbedSsoContentDiscoveryPath = (typeof EmbedSsoContentDiscoveryPaths)[number];
|
|
50
|
-
export
|
|
54
|
+
export declare enum EmbedConnectionRoles {
|
|
55
|
+
RESTRICTED_QUERIER = "RESTRICTED_QUERIER"
|
|
56
|
+
}
|
|
57
|
+
export type EmbedSsoContentProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentPathProp & Partial<EmbedConnectionRolesProp>;
|
|
51
58
|
/**
|
|
52
59
|
* Consumers of this SDK will rely on these three types to embed workbooks and dashboards.
|
|
53
60
|
*/
|
|
54
61
|
export type EmbedSsoDashboardProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentIdProp;
|
|
55
62
|
export type EmbedSsoWorkbookProps = EmbedSsoBaseProps & EmbedContentIdProp;
|
|
56
|
-
export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
|
|
63
|
+
export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & EmbedConnectionRolesProp & {
|
|
57
64
|
/**
|
|
58
65
|
* Path name of the content discovery page to embed.
|
|
59
66
|
*/
|
package/lib/esm/types.js
CHANGED
|
@@ -4,3 +4,10 @@ export var EmbeddedContent;
|
|
|
4
4
|
EmbeddedContent["Workbook"] = "w";
|
|
5
5
|
})(EmbeddedContent || (EmbeddedContent = {}));
|
|
6
6
|
export const EmbedSsoContentDiscoveryPaths = ["my"];
|
|
7
|
+
export var EmbedConnectionRoles;
|
|
8
|
+
(function (EmbedConnectionRoles) {
|
|
9
|
+
// TODO: Eventually we'll want to add VIEWER. Currently though, since the sole use case of the
|
|
10
|
+
// connectionRoles parameter is personal content creation, I'm refraining from adding "VIEWER" to
|
|
11
|
+
// keep scope as limited as possible.
|
|
12
|
+
EmbedConnectionRoles["RESTRICTED_QUERIER"] = "RESTRICTED_QUERIER";
|
|
13
|
+
})(EmbedConnectionRoles || (EmbedConnectionRoles = {}));
|
package/package.json
CHANGED