@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.
- package/lib/cjs/embed.d.ts +2 -0
- package/lib/cjs/embed.js +5 -1
- package/lib/cjs/signature.d.ts +9 -1
- package/lib/cjs/signature.js +3 -1
- package/lib/esm/embed.d.ts +2 -0
- package/lib/esm/embed.js +5 -1
- package/lib/esm/signature.d.ts +9 -1
- package/lib/esm/signature.js +3 -1
- package/package.json +1 -1
package/lib/cjs/embed.d.ts
CHANGED
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;
|
package/lib/cjs/signature.d.ts
CHANGED
|
@@ -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 {};
|
package/lib/cjs/signature.js
CHANGED
|
@@ -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}
|
package/lib/esm/embed.d.ts
CHANGED
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
|
};
|
package/lib/esm/signature.d.ts
CHANGED
|
@@ -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 {};
|
package/lib/esm/signature.js
CHANGED
|
@@ -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