@omni-co/embed 0.3.0 → 0.3.2
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 +31 -30
- package/lib/cjs/embed.d.ts +3 -1
- package/lib/cjs/embed.js +4 -1
- package/lib/cjs/signature.d.ts +5 -1
- package/lib/cjs/signature.js +2 -1
- package/lib/esm/embed.d.ts +3 -1
- package/lib/esm/embed.js +4 -1
- package/lib/esm/signature.d.ts +5 -1
- package/lib/esm/signature.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
## Install
|
|
4
4
|
|
|
5
5
|
npm:
|
|
6
|
+
|
|
6
7
|
```
|
|
7
8
|
npm install @omni-co/embed
|
|
8
9
|
```
|
|
9
10
|
|
|
10
11
|
yarn:
|
|
12
|
+
|
|
11
13
|
```
|
|
12
14
|
yarn add @omni-co/embed
|
|
13
15
|
```
|
|
@@ -15,37 +17,37 @@ yarn add @omni-co/embed
|
|
|
15
17
|
## Basic Example
|
|
16
18
|
|
|
17
19
|
```ts
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
import { embedSsoDashboard } from "@omni-co/embed";
|
|
21
|
+
|
|
22
|
+
// This creates a signed embed sso link for a dashboard
|
|
23
|
+
// in the omni account named Acme.
|
|
24
|
+
const iframeUrl = await embedSsoDashboard({
|
|
25
|
+
contentId: "miU0hL6z",
|
|
26
|
+
externalId: "wile.e@coyote.co",
|
|
27
|
+
name: "Wile E",
|
|
28
|
+
organizationName: "acme",
|
|
29
|
+
secret: "abcdefghijklmnopqrstuvwxyz123456",
|
|
30
|
+
});
|
|
29
31
|
```
|
|
30
32
|
|
|
31
33
|
## Kitchen Sink Example
|
|
32
34
|
|
|
33
35
|
```ts
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
import { embedSsoDashboard } from "@omni-co/embed";
|
|
37
|
+
|
|
38
|
+
// This creates a signed embed sso link for a dashboard
|
|
39
|
+
// in the omni account named Acme.
|
|
40
|
+
const iframeUrl = await embedSsoDashboard({
|
|
41
|
+
contentId: "miU0hL6z",
|
|
42
|
+
externalId: "wile.e@coyote.co",
|
|
43
|
+
entity: "cartoon",
|
|
44
|
+
name: "Wile E",
|
|
45
|
+
organizationName: "acme",
|
|
46
|
+
secret: "abcdefghijklmnopqrstuvwxyz123456",
|
|
47
|
+
prefersDark: "system",
|
|
48
|
+
theme: "vibes",
|
|
49
|
+
userAttributes: { tool: "anvil" },
|
|
50
|
+
});
|
|
49
51
|
```
|
|
50
52
|
|
|
51
53
|
## embedSsoDashboard
|
|
@@ -57,7 +59,7 @@ type EmbedSsoDashboardProps = {
|
|
|
57
59
|
// Short GUID of the dashboard. Can be obtained via the dashboard's url.
|
|
58
60
|
contentId: string;
|
|
59
61
|
|
|
60
|
-
// Required identifier to associate the external user with an
|
|
62
|
+
// Required identifier to associate the external user with an
|
|
61
63
|
// automatically generated internal Omni user.
|
|
62
64
|
externalId: string;
|
|
63
65
|
|
|
@@ -70,14 +72,14 @@ type EmbedSsoDashboardProps = {
|
|
|
70
72
|
// Signing secret available to Omni admins.
|
|
71
73
|
secret: string;
|
|
72
74
|
|
|
73
|
-
// Optional identifier to associate the user with an external
|
|
75
|
+
// Optional identifier to associate the user with an external
|
|
74
76
|
// organization or system.
|
|
75
77
|
entity?: string;
|
|
76
78
|
|
|
77
79
|
// Optional user attributes to be passed to user associated with the
|
|
78
80
|
// externalId. User attributes must be created in Omni before being
|
|
79
81
|
// defined and given a value here.
|
|
80
|
-
userAttributes?: Record<string, string>;
|
|
82
|
+
userAttributes?: Record<string, string | string[] | number | number[]>;
|
|
81
83
|
|
|
82
84
|
// Optional dark mode setting. Can be one of "true", "false", or "system".
|
|
83
85
|
prefersDark?: string;
|
|
@@ -85,5 +87,4 @@ type EmbedSsoDashboardProps = {
|
|
|
85
87
|
// Optional theme setting. Can be one of "dawn", "vibes", "breeze" or "blank".
|
|
86
88
|
theme?: string;
|
|
87
89
|
};
|
|
88
|
-
|
|
89
90
|
```
|
package/lib/cjs/embed.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type UserAttributeValue = string | string[] | number | number[];
|
|
1
2
|
type EmbedSsoProps = {
|
|
2
3
|
contentId: string;
|
|
3
4
|
externalId: string;
|
|
@@ -5,9 +6,10 @@ type EmbedSsoProps = {
|
|
|
5
6
|
organizationName: string;
|
|
6
7
|
secret: string;
|
|
7
8
|
entity?: string;
|
|
8
|
-
userAttributes?: Record<string,
|
|
9
|
+
userAttributes?: Record<string, UserAttributeValue>;
|
|
9
10
|
prefersDark?: string;
|
|
10
11
|
theme?: string;
|
|
12
|
+
filterSearchParam?: string;
|
|
11
13
|
domain?: string;
|
|
12
14
|
nonce?: string;
|
|
13
15
|
port?: number;
|
package/lib/cjs/embed.js
CHANGED
|
@@ -34,7 +34,7 @@ const validateProps = (props) => {
|
|
|
34
34
|
};
|
|
35
35
|
const embedSsoDashboard = async (props) => {
|
|
36
36
|
validateProps(props);
|
|
37
|
-
let { contentId, domain, externalId, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
|
|
37
|
+
let { contentId, domain, externalId, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, filterSearchParam, } = props;
|
|
38
38
|
// Handle defaults
|
|
39
39
|
nonce = nonce !== null && nonce !== void 0 ? nonce : (await (0, random_str_1.random32ByteString)());
|
|
40
40
|
domain = domain !== null && domain !== void 0 ? domain : defaultEmbedDomain;
|
|
@@ -55,6 +55,7 @@ const embedSsoDashboard = async (props) => {
|
|
|
55
55
|
entity,
|
|
56
56
|
prefersDark,
|
|
57
57
|
theme,
|
|
58
|
+
filterSearchParam,
|
|
58
59
|
});
|
|
59
60
|
// Build and return the signed url
|
|
60
61
|
url.searchParams.append("contentPath", contentPath);
|
|
@@ -66,6 +67,8 @@ const embedSsoDashboard = async (props) => {
|
|
|
66
67
|
entity && url.searchParams.append("entity", entity);
|
|
67
68
|
prefersDark && url.searchParams.append("prefersDark", prefersDark);
|
|
68
69
|
theme && url.searchParams.append("theme", theme);
|
|
70
|
+
filterSearchParam &&
|
|
71
|
+
url.searchParams.append("filterSearchParam", filterSearchParam);
|
|
69
72
|
return url.toString();
|
|
70
73
|
};
|
|
71
74
|
exports.embedSsoDashboard = embedSsoDashboard;
|
package/lib/cjs/signature.d.ts
CHANGED
|
@@ -47,9 +47,13 @@ type SignatureProps = {
|
|
|
47
47
|
* The theme of the embed.
|
|
48
48
|
*/
|
|
49
49
|
theme?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Filter search parameter.
|
|
52
|
+
*/
|
|
53
|
+
filterSearchParam?: string;
|
|
50
54
|
};
|
|
51
55
|
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
52
56
|
export declare const TEST_ONLY: {
|
|
53
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }: Omit<SignatureProps, "secret">) => string;
|
|
57
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, filterSearchParam, }: Omit<SignatureProps, "secret">) => string;
|
|
54
58
|
};
|
|
55
59
|
export {};
|
package/lib/cjs/signature.js
CHANGED
|
@@ -13,9 +13,10 @@ const hmacSign = (data, secret) => {
|
|
|
13
13
|
return base64url_1.default.fromBase64(b64);
|
|
14
14
|
};
|
|
15
15
|
exports.hmacSign = hmacSign;
|
|
16
|
-
const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }) => {
|
|
16
|
+
const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, filterSearchParam, }) => {
|
|
17
17
|
const optionalParams = [];
|
|
18
18
|
entity && optionalParams.push(entity);
|
|
19
|
+
filterSearchParam && optionalParams.push(filterSearchParam);
|
|
19
20
|
prefersDark && optionalParams.push(prefersDark);
|
|
20
21
|
theme && optionalParams.push(theme);
|
|
21
22
|
userAttributes && optionalParams.push(userAttributes);
|
package/lib/esm/embed.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type UserAttributeValue = string | string[] | number | number[];
|
|
1
2
|
type EmbedSsoProps = {
|
|
2
3
|
contentId: string;
|
|
3
4
|
externalId: string;
|
|
@@ -5,9 +6,10 @@ type EmbedSsoProps = {
|
|
|
5
6
|
organizationName: string;
|
|
6
7
|
secret: string;
|
|
7
8
|
entity?: string;
|
|
8
|
-
userAttributes?: Record<string,
|
|
9
|
+
userAttributes?: Record<string, UserAttributeValue>;
|
|
9
10
|
prefersDark?: string;
|
|
10
11
|
theme?: string;
|
|
12
|
+
filterSearchParam?: string;
|
|
11
13
|
domain?: string;
|
|
12
14
|
nonce?: string;
|
|
13
15
|
port?: number;
|
package/lib/esm/embed.js
CHANGED
|
@@ -31,7 +31,7 @@ const validateProps = (props) => {
|
|
|
31
31
|
};
|
|
32
32
|
export const embedSsoDashboard = async (props) => {
|
|
33
33
|
validateProps(props);
|
|
34
|
-
let { contentId, domain, externalId, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
|
|
34
|
+
let { contentId, domain, externalId, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, filterSearchParam, } = props;
|
|
35
35
|
// Handle defaults
|
|
36
36
|
nonce = nonce !== null && nonce !== void 0 ? nonce : (await random32ByteString());
|
|
37
37
|
domain = domain !== null && domain !== void 0 ? domain : defaultEmbedDomain;
|
|
@@ -52,6 +52,7 @@ export const embedSsoDashboard = async (props) => {
|
|
|
52
52
|
entity,
|
|
53
53
|
prefersDark,
|
|
54
54
|
theme,
|
|
55
|
+
filterSearchParam,
|
|
55
56
|
});
|
|
56
57
|
// Build and return the signed url
|
|
57
58
|
url.searchParams.append("contentPath", contentPath);
|
|
@@ -63,5 +64,7 @@ export const embedSsoDashboard = async (props) => {
|
|
|
63
64
|
entity && url.searchParams.append("entity", entity);
|
|
64
65
|
prefersDark && url.searchParams.append("prefersDark", prefersDark);
|
|
65
66
|
theme && url.searchParams.append("theme", theme);
|
|
67
|
+
filterSearchParam &&
|
|
68
|
+
url.searchParams.append("filterSearchParam", filterSearchParam);
|
|
66
69
|
return url.toString();
|
|
67
70
|
};
|
package/lib/esm/signature.d.ts
CHANGED
|
@@ -47,9 +47,13 @@ type SignatureProps = {
|
|
|
47
47
|
* The theme of the embed.
|
|
48
48
|
*/
|
|
49
49
|
theme?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Filter search parameter.
|
|
52
|
+
*/
|
|
53
|
+
filterSearchParam?: string;
|
|
50
54
|
};
|
|
51
55
|
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
52
56
|
export declare const TEST_ONLY: {
|
|
53
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }: Omit<SignatureProps, "secret">) => string;
|
|
57
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, filterSearchParam, }: Omit<SignatureProps, "secret">) => string;
|
|
54
58
|
};
|
|
55
59
|
export {};
|
package/lib/esm/signature.js
CHANGED
|
@@ -6,9 +6,10 @@ export const hmacSign = (data, secret) => {
|
|
|
6
6
|
const b64 = hmac.digest("base64");
|
|
7
7
|
return base64url.fromBase64(b64);
|
|
8
8
|
};
|
|
9
|
-
const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }) => {
|
|
9
|
+
const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, filterSearchParam, }) => {
|
|
10
10
|
const optionalParams = [];
|
|
11
11
|
entity && optionalParams.push(entity);
|
|
12
|
+
filterSearchParam && optionalParams.push(filterSearchParam);
|
|
12
13
|
prefersDark && optionalParams.push(prefersDark);
|
|
13
14
|
theme && optionalParams.push(theme);
|
|
14
15
|
userAttributes && optionalParams.push(userAttributes);
|
package/package.json
CHANGED