@omni-co/embed 0.3.5 → 0.3.7
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 +5 -0
- package/lib/cjs/embed.js +4 -1
- package/lib/cjs/signature.d.ts +7 -1
- package/lib/cjs/signature.js +2 -1
- package/lib/esm/embed.d.ts +5 -0
- package/lib/esm/embed.js +4 -1
- package/lib/esm/signature.d.ts +7 -1
- package/lib/esm/signature.js +2 -1
- package/package.json +1 -1
package/lib/cjs/embed.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
type UserAttributeValue = string | string[] | number | number[];
|
|
2
|
+
export type CustomThemeProperties = {
|
|
3
|
+
"dashboard-background"?: string;
|
|
4
|
+
"dashboard-tile-background"?: string;
|
|
5
|
+
};
|
|
2
6
|
type EmbedSsoProps = {
|
|
3
7
|
contentId: string;
|
|
4
8
|
externalId: string;
|
|
@@ -11,6 +15,7 @@ type EmbedSsoProps = {
|
|
|
11
15
|
theme?: string;
|
|
12
16
|
filterSearchParam?: string;
|
|
13
17
|
linkAccess?: string;
|
|
18
|
+
customTheme?: CustomThemeProperties;
|
|
14
19
|
domain?: string;
|
|
15
20
|
nonce?: string;
|
|
16
21
|
port?: number;
|
package/lib/cjs/embed.js
CHANGED
|
@@ -34,11 +34,12 @@ 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,
|
|
37
|
+
let { contentId, customTheme: rawCustomTheme, domain, externalId, filterSearchParam, linkAccess, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = 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;
|
|
41
41
|
const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
|
|
42
|
+
const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
|
|
42
43
|
// Generate the url for the embed login route
|
|
43
44
|
const url = new URL(embedLoginRoute, `https://${organizationName.toLocaleLowerCase()}.${domain}${port ? `:${port}` : ""}`);
|
|
44
45
|
// Generate the content path
|
|
@@ -57,6 +58,7 @@ const embedSsoDashboard = async (props) => {
|
|
|
57
58
|
theme,
|
|
58
59
|
filterSearchParam,
|
|
59
60
|
linkAccess,
|
|
61
|
+
customTheme,
|
|
60
62
|
});
|
|
61
63
|
// Build and return the signed url
|
|
62
64
|
url.searchParams.append("contentPath", contentPath);
|
|
@@ -71,6 +73,7 @@ const embedSsoDashboard = async (props) => {
|
|
|
71
73
|
filterSearchParam &&
|
|
72
74
|
url.searchParams.append("filterSearchParam", filterSearchParam);
|
|
73
75
|
linkAccess && url.searchParams.append("linkAccess", linkAccess);
|
|
76
|
+
customTheme && url.searchParams.append("customTheme", customTheme);
|
|
74
77
|
return url.toString();
|
|
75
78
|
};
|
|
76
79
|
exports.embedSsoDashboard = embedSsoDashboard;
|
package/lib/cjs/signature.d.ts
CHANGED
|
@@ -55,9 +55,15 @@ type SignatureProps = {
|
|
|
55
55
|
* String denoting level of link access.
|
|
56
56
|
*/
|
|
57
57
|
linkAccess?: string;
|
|
58
|
+
/**
|
|
59
|
+
* The custom theme to be sent with the request. Expected to be a stringified JSON object.
|
|
60
|
+
*
|
|
61
|
+
* Example: '{ "dashboard-background-color": "hotpink" }'
|
|
62
|
+
*/
|
|
63
|
+
customTheme?: string;
|
|
58
64
|
};
|
|
59
65
|
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
60
66
|
export declare const TEST_ONLY: {
|
|
61
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, filterSearchParam, linkAccess, }: Omit<SignatureProps, "secret">) => string;
|
|
67
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, filterSearchParam, linkAccess, customTheme, }: Omit<SignatureProps, "secret">) => string;
|
|
62
68
|
};
|
|
63
69
|
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, filterSearchParam, linkAccess, }) => {
|
|
16
|
+
const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, filterSearchParam, linkAccess, customTheme, }) => {
|
|
17
17
|
const optionalParams = [];
|
|
18
18
|
entity && optionalParams.push(entity);
|
|
19
|
+
customTheme && optionalParams.push(customTheme);
|
|
19
20
|
filterSearchParam && optionalParams.push(filterSearchParam);
|
|
20
21
|
linkAccess && optionalParams.push(linkAccess);
|
|
21
22
|
prefersDark && optionalParams.push(prefersDark);
|
package/lib/esm/embed.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
type UserAttributeValue = string | string[] | number | number[];
|
|
2
|
+
export type CustomThemeProperties = {
|
|
3
|
+
"dashboard-background"?: string;
|
|
4
|
+
"dashboard-tile-background"?: string;
|
|
5
|
+
};
|
|
2
6
|
type EmbedSsoProps = {
|
|
3
7
|
contentId: string;
|
|
4
8
|
externalId: string;
|
|
@@ -11,6 +15,7 @@ type EmbedSsoProps = {
|
|
|
11
15
|
theme?: string;
|
|
12
16
|
filterSearchParam?: string;
|
|
13
17
|
linkAccess?: string;
|
|
18
|
+
customTheme?: CustomThemeProperties;
|
|
14
19
|
domain?: string;
|
|
15
20
|
nonce?: string;
|
|
16
21
|
port?: number;
|
package/lib/esm/embed.js
CHANGED
|
@@ -31,11 +31,12 @@ 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,
|
|
34
|
+
let { contentId, customTheme: rawCustomTheme, domain, externalId, filterSearchParam, linkAccess, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = 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;
|
|
38
38
|
const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
|
|
39
|
+
const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
|
|
39
40
|
// Generate the url for the embed login route
|
|
40
41
|
const url = new URL(embedLoginRoute, `https://${organizationName.toLocaleLowerCase()}.${domain}${port ? `:${port}` : ""}`);
|
|
41
42
|
// Generate the content path
|
|
@@ -54,6 +55,7 @@ export const embedSsoDashboard = async (props) => {
|
|
|
54
55
|
theme,
|
|
55
56
|
filterSearchParam,
|
|
56
57
|
linkAccess,
|
|
58
|
+
customTheme,
|
|
57
59
|
});
|
|
58
60
|
// Build and return the signed url
|
|
59
61
|
url.searchParams.append("contentPath", contentPath);
|
|
@@ -68,5 +70,6 @@ export const embedSsoDashboard = async (props) => {
|
|
|
68
70
|
filterSearchParam &&
|
|
69
71
|
url.searchParams.append("filterSearchParam", filterSearchParam);
|
|
70
72
|
linkAccess && url.searchParams.append("linkAccess", linkAccess);
|
|
73
|
+
customTheme && url.searchParams.append("customTheme", customTheme);
|
|
71
74
|
return url.toString();
|
|
72
75
|
};
|
package/lib/esm/signature.d.ts
CHANGED
|
@@ -55,9 +55,15 @@ type SignatureProps = {
|
|
|
55
55
|
* String denoting level of link access.
|
|
56
56
|
*/
|
|
57
57
|
linkAccess?: string;
|
|
58
|
+
/**
|
|
59
|
+
* The custom theme to be sent with the request. Expected to be a stringified JSON object.
|
|
60
|
+
*
|
|
61
|
+
* Example: '{ "dashboard-background-color": "hotpink" }'
|
|
62
|
+
*/
|
|
63
|
+
customTheme?: string;
|
|
58
64
|
};
|
|
59
65
|
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
60
66
|
export declare const TEST_ONLY: {
|
|
61
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, filterSearchParam, linkAccess, }: Omit<SignatureProps, "secret">) => string;
|
|
67
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, filterSearchParam, linkAccess, customTheme, }: Omit<SignatureProps, "secret">) => string;
|
|
62
68
|
};
|
|
63
69
|
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, filterSearchParam, linkAccess, }) => {
|
|
9
|
+
const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, entity, prefersDark, theme, filterSearchParam, linkAccess, customTheme, }) => {
|
|
10
10
|
const optionalParams = [];
|
|
11
11
|
entity && optionalParams.push(entity);
|
|
12
|
+
customTheme && optionalParams.push(customTheme);
|
|
12
13
|
filterSearchParam && optionalParams.push(filterSearchParam);
|
|
13
14
|
linkAccess && optionalParams.push(linkAccess);
|
|
14
15
|
prefersDark && optionalParams.push(prefersDark);
|
package/package.json
CHANGED