@omni-co/embed 0.2.0 → 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.
@@ -9,6 +9,8 @@ type EmbedSsoProps = {
9
9
  secret: string;
10
10
  userAttributes?: Record<string, string>;
11
11
  entity?: string;
12
+ prefersDark?: string;
13
+ theme?: string;
12
14
  };
13
15
  export declare const embedSsoDashboard: (props: EmbedSsoProps) => string;
14
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, entity, } = 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;
@@ -53,6 +53,8 @@ const embedSsoDashboard = (props) => {
53
53
  secret,
54
54
  userAttributes,
55
55
  entity,
56
+ prefersDark,
57
+ theme,
56
58
  });
57
59
  // Build and return the signed url
58
60
  url.searchParams.append("contentPath", contentPath);
@@ -62,6 +64,8 @@ const embedSsoDashboard = (props) => {
62
64
  url.searchParams.append("signature", signature);
63
65
  userAttributes && url.searchParams.append("userAttributes", userAttributes);
64
66
  entity && url.searchParams.append("entity", entity);
67
+ prefersDark && url.searchParams.append("prefersDark", prefersDark);
68
+ theme && url.searchParams.append("theme", theme);
65
69
  return url.toString();
66
70
  };
67
71
  exports.embedSsoDashboard = embedSsoDashboard;
@@ -39,9 +39,17 @@ type SignatureProps = {
39
39
  * user will this value assigned to its omni_user_embed_entity user attribute.
40
40
  */
41
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;
42
50
  };
43
51
  export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
44
52
  export declare const TEST_ONLY: {
45
- generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, }: Omit<SignatureProps, "secret">) => string;
53
+ generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }: Omit<SignatureProps, "secret">) => string;
46
54
  };
47
55
  export {};
@@ -11,9 +11,11 @@ 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, entity, }) => {
14
+ const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }) => {
15
15
  const optionalParams = [];
16
16
  entity && optionalParams.push(entity);
17
+ prefersDark && optionalParams.push(prefersDark);
18
+ theme && optionalParams.push(theme);
17
19
  userAttributes && optionalParams.push(userAttributes);
18
20
  return `
19
21
  ${loginUrl}
@@ -9,6 +9,8 @@ type EmbedSsoProps = {
9
9
  secret: string;
10
10
  userAttributes?: Record<string, string>;
11
11
  entity?: string;
12
+ prefersDark?: string;
13
+ theme?: string;
12
14
  };
13
15
  export declare const embedSsoDashboard: (props: EmbedSsoProps) => string;
14
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, entity, } = 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;
@@ -50,6 +50,8 @@ export const embedSsoDashboard = (props) => {
50
50
  secret,
51
51
  userAttributes,
52
52
  entity,
53
+ prefersDark,
54
+ theme,
53
55
  });
54
56
  // Build and return the signed url
55
57
  url.searchParams.append("contentPath", contentPath);
@@ -59,5 +61,7 @@ export const embedSsoDashboard = (props) => {
59
61
  url.searchParams.append("signature", signature);
60
62
  userAttributes && url.searchParams.append("userAttributes", userAttributes);
61
63
  entity && url.searchParams.append("entity", entity);
64
+ prefersDark && url.searchParams.append("prefersDark", prefersDark);
65
+ theme && url.searchParams.append("theme", theme);
62
66
  return url.toString();
63
67
  };
@@ -39,9 +39,17 @@ type SignatureProps = {
39
39
  * user will this value assigned to its omni_user_embed_entity user attribute.
40
40
  */
41
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;
42
50
  };
43
51
  export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
44
52
  export declare const TEST_ONLY: {
45
- generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, }: Omit<SignatureProps, "secret">) => string;
53
+ generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }: Omit<SignatureProps, "secret">) => string;
46
54
  };
47
55
  export {};
@@ -4,9 +4,11 @@ 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, entity, }) => {
7
+ const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, }) => {
8
8
  const optionalParams = [];
9
9
  entity && optionalParams.push(entity);
10
+ prefersDark && optionalParams.push(prefersDark);
11
+ theme && optionalParams.push(theme);
10
12
  userAttributes && optionalParams.push(userAttributes);
11
13
  return `
12
14
  ${loginUrl}
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.0",
2
+ "version": "0.2.1",
3
3
  "license": "MIT",
4
4
  "name": "@omni-co/embed",
5
5
  "author": "Nate Agrin <nate@exploreomni.com>",