@omni-co/embed 0.3.0-pre.3 → 0.3.1

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 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
- import { embedSsoDashboard } from '@omni-co/embed'
19
-
20
- // This creates a signed embed sso link for a dashboard
21
- // in the omni account named Acme.
22
- const iframeUrl = await embedSsoDashboard({
23
- contentId: "miU0hL6z",
24
- externalId: "wile.e@coyote.co",
25
- name: "Wile E",
26
- organizationName: "acme",
27
- secret: "abcdefghijklmnopqrstuvwxyz123456",
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
- import { embedSsoDashboard } from '@omni-co/embed'
35
-
36
- // This creates a signed embed sso link for a dashboard
37
- // in the omni account named Acme.
38
- const iframeUrl = await embedSsoDashboard({
39
- contentId: "miU0hL6z",
40
- externalId: "wile.e@coyote.co",
41
- entity: "cartoon",
42
- name: "Wile E",
43
- organizationName: "acme",
44
- secret: "abcdefghijklmnopqrstuvwxyz123456",
45
- prefersDark: "system",
46
- theme: "vibes",
47
- userAttributes: { tool: "anvil" }
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
  ```
@@ -1,3 +1,4 @@
1
+ type UserAttributeValue = string | string[] | number | number[];
1
2
  type EmbedSsoProps = {
2
3
  contentId: string;
3
4
  externalId: string;
@@ -5,7 +6,7 @@ type EmbedSsoProps = {
5
6
  organizationName: string;
6
7
  secret: string;
7
8
  entity?: string;
8
- userAttributes?: Record<string, string>;
9
+ userAttributes?: Record<string, UserAttributeValue>;
9
10
  prefersDark?: string;
10
11
  theme?: string;
11
12
  domain?: string;
@@ -5,10 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TEST_ONLY = exports.getSignature = exports.hmacSign = void 0;
7
7
  const crypto_1 = __importDefault(require("crypto"));
8
+ const base64url_1 = __importDefault(require("base64url"));
8
9
  const hmacSign = (data, secret) => {
9
10
  const hmac = crypto_1.default.createHmac("sha256", secret);
10
11
  hmac.update(data);
11
- return hmac.digest("base64url");
12
+ const b64 = hmac.digest("base64");
13
+ return base64url_1.default.fromBase64(b64);
12
14
  };
13
15
  exports.hmacSign = hmacSign;
14
16
  const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }) => {
@@ -1,3 +1,4 @@
1
+ type UserAttributeValue = string | string[] | number | number[];
1
2
  type EmbedSsoProps = {
2
3
  contentId: string;
3
4
  externalId: string;
@@ -5,7 +6,7 @@ type EmbedSsoProps = {
5
6
  organizationName: string;
6
7
  secret: string;
7
8
  entity?: string;
8
- userAttributes?: Record<string, string>;
9
+ userAttributes?: Record<string, UserAttributeValue>;
9
10
  prefersDark?: string;
10
11
  theme?: string;
11
12
  domain?: string;
@@ -1,8 +1,10 @@
1
1
  import crypto from "crypto";
2
+ import base64url from "base64url";
2
3
  export const hmacSign = (data, secret) => {
3
4
  const hmac = crypto.createHmac("sha256", secret);
4
5
  hmac.update(data);
5
- return hmac.digest("base64url");
6
+ const b64 = hmac.digest("base64");
7
+ return base64url.fromBase64(b64);
6
8
  };
7
9
  const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }) => {
8
10
  const optionalParams = [];
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.3.0-pre.3",
2
+ "version": "0.3.1",
3
3
  "license": "MIT",
4
4
  "name": "@omni-co/embed",
5
5
  "author": "Nate Agrin <nate@exploreomni.com>",
@@ -19,6 +19,7 @@
19
19
  "test:watch": "vitest --watch"
20
20
  },
21
21
  "dependencies": {
22
+ "base64url": "^3.0.1",
22
23
  "nanoid": "^5.0.2"
23
24
  },
24
25
  "engines": {