@omni-co/embed 0.3.13 → 0.3.14
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 +5 -1
- package/lib/cjs/signature.d.ts +19 -15
- package/lib/cjs/signature.js +9 -2
- package/lib/cjs/types.d.ts +8 -2
- package/lib/cjs/types.js +8 -1
- package/lib/esm/embed.js +5 -1
- package/lib/esm/signature.d.ts +19 -15
- package/lib/esm/signature.js +9 -2
- package/lib/esm/types.d.ts +8 -2
- package/lib/esm/types.js +7 -0
- package/package.json +1 -1
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 { 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,7 @@ const embedSsoContent = async (props) => {
|
|
|
54
55
|
filterSearchParam,
|
|
55
56
|
linkAccess,
|
|
56
57
|
customTheme,
|
|
58
|
+
connectionRoles,
|
|
57
59
|
});
|
|
58
60
|
// Build and return the signed url
|
|
59
61
|
url.searchParams.append("contentPath", contentPath);
|
|
@@ -69,6 +71,8 @@ const embedSsoContent = async (props) => {
|
|
|
69
71
|
url.searchParams.append("filterSearchParam", filterSearchParam);
|
|
70
72
|
linkAccess && url.searchParams.append("linkAccess", linkAccess);
|
|
71
73
|
customTheme && url.searchParams.append("customTheme", customTheme);
|
|
74
|
+
connectionRoles &&
|
|
75
|
+
url.searchParams.append("connectionRoles", connectionRoles);
|
|
72
76
|
return url.toString();
|
|
73
77
|
};
|
|
74
78
|
const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
|
package/lib/cjs/signature.d.ts
CHANGED
|
@@ -29,24 +29,20 @@ type SignatureProps = {
|
|
|
29
29
|
*/
|
|
30
30
|
secret: string;
|
|
31
31
|
/**
|
|
32
|
-
* The
|
|
32
|
+
* The connection roles to be associated with the embed user. Expected to be a stringified JSON object.
|
|
33
|
+
*/
|
|
34
|
+
connectionRoles?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The custom theme to be sent with the request. Expected to be a stringified JSON object.
|
|
33
37
|
*
|
|
34
|
-
* Example: '{ "
|
|
38
|
+
* Example: '{ "dashboard-background-color": "hotpink" }'
|
|
35
39
|
*/
|
|
36
|
-
|
|
40
|
+
customTheme?: string;
|
|
37
41
|
/**
|
|
38
42
|
* The entity that the created embed user will belong to. Practically speaking, the embed
|
|
39
43
|
* user will this value assigned to its omni_user_embed_entity user attribute.
|
|
40
44
|
*/
|
|
41
45
|
entity?: string;
|
|
42
|
-
/**
|
|
43
|
-
* Whether the user prefers light, dark, or system theme.
|
|
44
|
-
*/
|
|
45
|
-
prefersDark?: string;
|
|
46
|
-
/**
|
|
47
|
-
* The theme of the embed.
|
|
48
|
-
*/
|
|
49
|
-
theme?: string;
|
|
50
46
|
/**
|
|
51
47
|
* Filter search parameter.
|
|
52
48
|
*/
|
|
@@ -56,14 +52,22 @@ type SignatureProps = {
|
|
|
56
52
|
*/
|
|
57
53
|
linkAccess?: string;
|
|
58
54
|
/**
|
|
59
|
-
*
|
|
55
|
+
* Whether the user prefers light, dark, or system theme.
|
|
56
|
+
*/
|
|
57
|
+
prefersDark?: string;
|
|
58
|
+
/**
|
|
59
|
+
* The theme of the embed.
|
|
60
|
+
*/
|
|
61
|
+
theme?: string;
|
|
62
|
+
/**
|
|
63
|
+
* The user attributes to be sent with the request. Expected to be a stringified JSON object.
|
|
60
64
|
*
|
|
61
|
-
* Example: '{ "
|
|
65
|
+
* Example: '{ "team": "Lakers" }'
|
|
62
66
|
*/
|
|
63
|
-
|
|
67
|
+
userAttributes?: string;
|
|
64
68
|
};
|
|
65
69
|
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
66
70
|
export declare const TEST_ONLY: {
|
|
67
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce,
|
|
71
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, }: Omit<SignatureProps, "secret">) => string;
|
|
68
72
|
};
|
|
69
73
|
export {};
|
package/lib/cjs/signature.js
CHANGED
|
@@ -13,10 +13,17 @@ const hmacSign = (data, secret) => {
|
|
|
13
13
|
return base64url_1.default.fromBase64(b64);
|
|
14
14
|
};
|
|
15
15
|
exports.hmacSign = hmacSign;
|
|
16
|
-
const generateStringForSignature = ({
|
|
16
|
+
const generateStringForSignature = ({
|
|
17
|
+
// Required parameters
|
|
18
|
+
loginUrl, contentPath, externalId, name, nonce,
|
|
19
|
+
// Optional parameters
|
|
20
|
+
connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, }) => {
|
|
17
21
|
const optionalParams = [];
|
|
18
|
-
|
|
22
|
+
// Optional parameters should be pushed into the optionalParams array in ALPHABETICAL order
|
|
23
|
+
// for customers producing embed login URLs.
|
|
24
|
+
connectionRoles && optionalParams.push(connectionRoles);
|
|
19
25
|
customTheme && optionalParams.push(customTheme);
|
|
26
|
+
entity && optionalParams.push(entity);
|
|
20
27
|
filterSearchParam && optionalParams.push(filterSearchParam);
|
|
21
28
|
linkAccess && optionalParams.push(linkAccess);
|
|
22
29
|
prefersDark && optionalParams.push(prefersDark);
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ type EmbedContentIdProp = {
|
|
|
23
23
|
type EmbedContentPathProp = {
|
|
24
24
|
contentPath: string;
|
|
25
25
|
};
|
|
26
|
+
type EmbedConnectionRolesProp = {
|
|
27
|
+
connectionRoles: Record<string, EmbedConnectionRoles>;
|
|
28
|
+
};
|
|
26
29
|
export type CustomThemeProperties = {
|
|
27
30
|
"dashboard-background"?: string;
|
|
28
31
|
"dashboard-tile-background"?: string;
|
|
@@ -47,13 +50,16 @@ export declare enum EmbeddedContent {
|
|
|
47
50
|
}
|
|
48
51
|
export declare const EmbedSsoContentDiscoveryPaths: readonly ["my"];
|
|
49
52
|
export type EmbedSsoContentDiscoveryPath = (typeof EmbedSsoContentDiscoveryPaths)[number];
|
|
50
|
-
export
|
|
53
|
+
export declare enum EmbedConnectionRoles {
|
|
54
|
+
RESTRICTED_QUERIER = "RESTRICTED_QUERIER"
|
|
55
|
+
}
|
|
56
|
+
export type EmbedSsoContentProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentPathProp & Partial<EmbedConnectionRolesProp>;
|
|
51
57
|
/**
|
|
52
58
|
* Consumers of this SDK will rely on these three types to embed workbooks and dashboards.
|
|
53
59
|
*/
|
|
54
60
|
export type EmbedSsoDashboardProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentIdProp;
|
|
55
61
|
export type EmbedSsoWorkbookProps = EmbedSsoBaseProps & EmbedContentIdProp;
|
|
56
|
-
export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
|
|
62
|
+
export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & EmbedConnectionRolesProp & {
|
|
57
63
|
/**
|
|
58
64
|
* Path name of the content discovery page to embed.
|
|
59
65
|
*/
|
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 { 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,7 @@ const embedSsoContent = async (props) => {
|
|
|
51
52
|
filterSearchParam,
|
|
52
53
|
linkAccess,
|
|
53
54
|
customTheme,
|
|
55
|
+
connectionRoles,
|
|
54
56
|
});
|
|
55
57
|
// Build and return the signed url
|
|
56
58
|
url.searchParams.append("contentPath", contentPath);
|
|
@@ -66,6 +68,8 @@ const embedSsoContent = async (props) => {
|
|
|
66
68
|
url.searchParams.append("filterSearchParam", filterSearchParam);
|
|
67
69
|
linkAccess && url.searchParams.append("linkAccess", linkAccess);
|
|
68
70
|
customTheme && url.searchParams.append("customTheme", customTheme);
|
|
71
|
+
connectionRoles &&
|
|
72
|
+
url.searchParams.append("connectionRoles", connectionRoles);
|
|
69
73
|
return url.toString();
|
|
70
74
|
};
|
|
71
75
|
const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
|
package/lib/esm/signature.d.ts
CHANGED
|
@@ -29,24 +29,20 @@ type SignatureProps = {
|
|
|
29
29
|
*/
|
|
30
30
|
secret: string;
|
|
31
31
|
/**
|
|
32
|
-
* The
|
|
32
|
+
* The connection roles to be associated with the embed user. Expected to be a stringified JSON object.
|
|
33
|
+
*/
|
|
34
|
+
connectionRoles?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The custom theme to be sent with the request. Expected to be a stringified JSON object.
|
|
33
37
|
*
|
|
34
|
-
* Example: '{ "
|
|
38
|
+
* Example: '{ "dashboard-background-color": "hotpink" }'
|
|
35
39
|
*/
|
|
36
|
-
|
|
40
|
+
customTheme?: string;
|
|
37
41
|
/**
|
|
38
42
|
* The entity that the created embed user will belong to. Practically speaking, the embed
|
|
39
43
|
* user will this value assigned to its omni_user_embed_entity user attribute.
|
|
40
44
|
*/
|
|
41
45
|
entity?: string;
|
|
42
|
-
/**
|
|
43
|
-
* Whether the user prefers light, dark, or system theme.
|
|
44
|
-
*/
|
|
45
|
-
prefersDark?: string;
|
|
46
|
-
/**
|
|
47
|
-
* The theme of the embed.
|
|
48
|
-
*/
|
|
49
|
-
theme?: string;
|
|
50
46
|
/**
|
|
51
47
|
* Filter search parameter.
|
|
52
48
|
*/
|
|
@@ -56,14 +52,22 @@ type SignatureProps = {
|
|
|
56
52
|
*/
|
|
57
53
|
linkAccess?: string;
|
|
58
54
|
/**
|
|
59
|
-
*
|
|
55
|
+
* Whether the user prefers light, dark, or system theme.
|
|
56
|
+
*/
|
|
57
|
+
prefersDark?: string;
|
|
58
|
+
/**
|
|
59
|
+
* The theme of the embed.
|
|
60
|
+
*/
|
|
61
|
+
theme?: string;
|
|
62
|
+
/**
|
|
63
|
+
* The user attributes to be sent with the request. Expected to be a stringified JSON object.
|
|
60
64
|
*
|
|
61
|
-
* Example: '{ "
|
|
65
|
+
* Example: '{ "team": "Lakers" }'
|
|
62
66
|
*/
|
|
63
|
-
|
|
67
|
+
userAttributes?: string;
|
|
64
68
|
};
|
|
65
69
|
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
66
70
|
export declare const TEST_ONLY: {
|
|
67
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce,
|
|
71
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, }: Omit<SignatureProps, "secret">) => string;
|
|
68
72
|
};
|
|
69
73
|
export {};
|
package/lib/esm/signature.js
CHANGED
|
@@ -6,10 +6,17 @@ export const hmacSign = (data, secret) => {
|
|
|
6
6
|
const b64 = hmac.digest("base64");
|
|
7
7
|
return base64url.fromBase64(b64);
|
|
8
8
|
};
|
|
9
|
-
const generateStringForSignature = ({
|
|
9
|
+
const generateStringForSignature = ({
|
|
10
|
+
// Required parameters
|
|
11
|
+
loginUrl, contentPath, externalId, name, nonce,
|
|
12
|
+
// Optional parameters
|
|
13
|
+
connectionRoles, customTheme, entity, filterSearchParam, linkAccess, prefersDark, theme, userAttributes, }) => {
|
|
10
14
|
const optionalParams = [];
|
|
11
|
-
|
|
15
|
+
// Optional parameters should be pushed into the optionalParams array in ALPHABETICAL order
|
|
16
|
+
// for customers producing embed login URLs.
|
|
17
|
+
connectionRoles && optionalParams.push(connectionRoles);
|
|
12
18
|
customTheme && optionalParams.push(customTheme);
|
|
19
|
+
entity && optionalParams.push(entity);
|
|
13
20
|
filterSearchParam && optionalParams.push(filterSearchParam);
|
|
14
21
|
linkAccess && optionalParams.push(linkAccess);
|
|
15
22
|
prefersDark && optionalParams.push(prefersDark);
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ type EmbedContentIdProp = {
|
|
|
23
23
|
type EmbedContentPathProp = {
|
|
24
24
|
contentPath: string;
|
|
25
25
|
};
|
|
26
|
+
type EmbedConnectionRolesProp = {
|
|
27
|
+
connectionRoles: Record<string, EmbedConnectionRoles>;
|
|
28
|
+
};
|
|
26
29
|
export type CustomThemeProperties = {
|
|
27
30
|
"dashboard-background"?: string;
|
|
28
31
|
"dashboard-tile-background"?: string;
|
|
@@ -47,13 +50,16 @@ export declare enum EmbeddedContent {
|
|
|
47
50
|
}
|
|
48
51
|
export declare const EmbedSsoContentDiscoveryPaths: readonly ["my"];
|
|
49
52
|
export type EmbedSsoContentDiscoveryPath = (typeof EmbedSsoContentDiscoveryPaths)[number];
|
|
50
|
-
export
|
|
53
|
+
export declare enum EmbedConnectionRoles {
|
|
54
|
+
RESTRICTED_QUERIER = "RESTRICTED_QUERIER"
|
|
55
|
+
}
|
|
56
|
+
export type EmbedSsoContentProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentPathProp & Partial<EmbedConnectionRolesProp>;
|
|
51
57
|
/**
|
|
52
58
|
* Consumers of this SDK will rely on these three types to embed workbooks and dashboards.
|
|
53
59
|
*/
|
|
54
60
|
export type EmbedSsoDashboardProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentIdProp;
|
|
55
61
|
export type EmbedSsoWorkbookProps = EmbedSsoBaseProps & EmbedContentIdProp;
|
|
56
|
-
export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
|
|
62
|
+
export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & EmbedConnectionRolesProp & {
|
|
57
63
|
/**
|
|
58
64
|
* Path name of the content discovery page to embed.
|
|
59
65
|
*/
|
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