@omni-co/embed 0.1.5 → 0.2.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
@@ -1 +1,28 @@
1
1
  # omni-embed-sdk
2
+
3
+ ## ⚠️ OmniEmbedSDK uses NPM! ⚠️
4
+
5
+ Publishing to npmjs.org was complicated with Yarn. Until that issue is resolved, please use NPM to manage this package.
6
+
7
+ ## Installation
8
+
9
+ 1. git clone the repository
10
+ 2. `npm install`
11
+ 3. `npm run test`
12
+
13
+ ## Publishing
14
+
15
+ 1. Create a new branch
16
+ 2. Edit the package.json version number appropriately
17
+ 3. Open a PR
18
+ 4. Merge the PR
19
+ 5. Nav to the Releases page in Github: https://github.com/exploreomni/embed-sdk/releases
20
+ 6. Click "Draft new Release"
21
+ 7. Click "Choose a tag" and type in the new tag name. Convention is to prefix the new version with `v`. Example: `v1.0.0`
22
+ 8. Leave target as `main`
23
+ 9. Enter a title, usually just the release version eg `v1.0.0`
24
+ 10. Add a description
25
+ 11. Ensure `Set as latest release` is ticked, if that's appropriate
26
+ 12. Click `Publish release`
27
+
28
+ 🥳 - The [github action defined here](https://github.com/exploreomni/embed-sdk/blob/main/.github/workflows/publish.yml) should publish the new release to npmjs.org.
@@ -8,6 +8,9 @@ type EmbedSsoProps = {
8
8
  port?: number;
9
9
  secret: string;
10
10
  userAttributes?: Record<string, string>;
11
+ entity?: string;
12
+ prefersDark?: string;
13
+ theme?: string;
11
14
  };
12
15
  export declare const embedSsoDashboard: (props: EmbedSsoProps) => string;
13
16
  export {};
package/lib/cjs/embed.js CHANGED
@@ -34,7 +34,7 @@ const validateProps = (props) => {
34
34
  };
35
35
  const embedSsoDashboard = (props) => {
36
36
  validateProps(props);
37
- let { contentId, domain, externalId, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, } = props;
37
+ let { contentId, domain, externalId, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
38
38
  // Handle defaults
39
39
  nonce = nonce ?? (0, random_str_1.random32ByteString)();
40
40
  domain = domain ?? defaultEmbedDomain;
@@ -52,6 +52,9 @@ const embedSsoDashboard = (props) => {
52
52
  nonce,
53
53
  secret,
54
54
  userAttributes,
55
+ entity,
56
+ prefersDark,
57
+ theme,
55
58
  });
56
59
  // Build and return the signed url
57
60
  url.searchParams.append("contentPath", contentPath);
@@ -60,6 +63,9 @@ const embedSsoDashboard = (props) => {
60
63
  url.searchParams.append("nonce", nonce);
61
64
  url.searchParams.append("signature", signature);
62
65
  userAttributes && url.searchParams.append("userAttributes", userAttributes);
66
+ entity && url.searchParams.append("entity", entity);
67
+ prefersDark && url.searchParams.append("prefersDark", prefersDark);
68
+ theme && url.searchParams.append("theme", theme);
63
69
  return url.toString();
64
70
  };
65
71
  exports.embedSsoDashboard = embedSsoDashboard;
@@ -34,9 +34,22 @@ type SignatureProps = {
34
34
  * Example: '{ "team": "Lakers" }'
35
35
  */
36
36
  userAttributes?: string;
37
+ /**
38
+ * The entity that the created embed user will belong to. Practically speaking, the embed
39
+ * user will this value assigned to its omni_user_embed_entity user attribute.
40
+ */
41
+ 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;
37
50
  };
38
51
  export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
39
52
  export declare const TEST_ONLY: {
40
- generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, }: Omit<SignatureProps, "secret">) => string;
53
+ generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }: Omit<SignatureProps, "secret">) => string;
41
54
  };
42
55
  export {};
@@ -11,16 +11,23 @@ const hmacSign = (data, secret) => {
11
11
  return hmac.digest("base64url");
12
12
  };
13
13
  exports.hmacSign = hmacSign;
14
- const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, }) => `
15
- ${loginUrl}
16
- ${contentPath}
17
- ${externalId}
18
- ${name}
19
- ${nonce}
20
- ${userAttributes || ""}
14
+ const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }) => {
15
+ const optionalParams = [];
16
+ entity && optionalParams.push(entity);
17
+ prefersDark && optionalParams.push(prefersDark);
18
+ theme && optionalParams.push(theme);
19
+ userAttributes && optionalParams.push(userAttributes);
20
+ return `
21
+ ${loginUrl}
22
+ ${contentPath}
23
+ ${externalId}
24
+ ${name}
25
+ ${nonce}
26
+ ${optionalParams.join("\n")}
21
27
  `
22
- .trim()
23
- .replace(/\n\s+/g, "\n");
28
+ .trim()
29
+ .replace(/\n\s+/g, "\n");
30
+ };
24
31
  const getSignature = ({ secret, ...props }) => {
25
32
  return (0, exports.hmacSign)(generateStringForSignature(props), secret);
26
33
  };
@@ -8,6 +8,9 @@ type EmbedSsoProps = {
8
8
  port?: number;
9
9
  secret: string;
10
10
  userAttributes?: Record<string, string>;
11
+ entity?: string;
12
+ prefersDark?: string;
13
+ theme?: string;
11
14
  };
12
15
  export declare const embedSsoDashboard: (props: EmbedSsoProps) => string;
13
16
  export {};
package/lib/esm/embed.js CHANGED
@@ -31,7 +31,7 @@ const validateProps = (props) => {
31
31
  };
32
32
  export const embedSsoDashboard = (props) => {
33
33
  validateProps(props);
34
- let { contentId, domain, externalId, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, } = props;
34
+ let { contentId, domain, externalId, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
35
35
  // Handle defaults
36
36
  nonce = nonce ?? random32ByteString();
37
37
  domain = domain ?? defaultEmbedDomain;
@@ -49,6 +49,9 @@ export const embedSsoDashboard = (props) => {
49
49
  nonce,
50
50
  secret,
51
51
  userAttributes,
52
+ entity,
53
+ prefersDark,
54
+ theme,
52
55
  });
53
56
  // Build and return the signed url
54
57
  url.searchParams.append("contentPath", contentPath);
@@ -57,5 +60,8 @@ export const embedSsoDashboard = (props) => {
57
60
  url.searchParams.append("nonce", nonce);
58
61
  url.searchParams.append("signature", signature);
59
62
  userAttributes && url.searchParams.append("userAttributes", userAttributes);
63
+ entity && url.searchParams.append("entity", entity);
64
+ prefersDark && url.searchParams.append("prefersDark", prefersDark);
65
+ theme && url.searchParams.append("theme", theme);
60
66
  return url.toString();
61
67
  };
@@ -34,9 +34,22 @@ type SignatureProps = {
34
34
  * Example: '{ "team": "Lakers" }'
35
35
  */
36
36
  userAttributes?: string;
37
+ /**
38
+ * The entity that the created embed user will belong to. Practically speaking, the embed
39
+ * user will this value assigned to its omni_user_embed_entity user attribute.
40
+ */
41
+ 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;
37
50
  };
38
51
  export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
39
52
  export declare const TEST_ONLY: {
40
- generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, }: Omit<SignatureProps, "secret">) => string;
53
+ generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }: Omit<SignatureProps, "secret">) => string;
41
54
  };
42
55
  export {};
@@ -4,16 +4,23 @@ export const hmacSign = (data, secret) => {
4
4
  hmac.update(data);
5
5
  return hmac.digest("base64url");
6
6
  };
7
- const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, }) => `
8
- ${loginUrl}
9
- ${contentPath}
10
- ${externalId}
11
- ${name}
12
- ${nonce}
13
- ${userAttributes || ""}
7
+ const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }) => {
8
+ const optionalParams = [];
9
+ entity && optionalParams.push(entity);
10
+ prefersDark && optionalParams.push(prefersDark);
11
+ theme && optionalParams.push(theme);
12
+ userAttributes && optionalParams.push(userAttributes);
13
+ return `
14
+ ${loginUrl}
15
+ ${contentPath}
16
+ ${externalId}
17
+ ${name}
18
+ ${nonce}
19
+ ${optionalParams.join("\n")}
14
20
  `
15
- .trim()
16
- .replace(/\n\s+/g, "\n");
21
+ .trim()
22
+ .replace(/\n\s+/g, "\n");
23
+ };
17
24
  export const getSignature = ({ secret, ...props }) => {
18
25
  return hmacSign(generateStringForSignature(props), secret);
19
26
  };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.5",
2
+ "version": "0.2.1",
3
3
  "license": "MIT",
4
4
  "name": "@omni-co/embed",
5
5
  "author": "Nate Agrin <nate@exploreomni.com>",