@omni-co/embed 0.4.4 → 0.4.6-alpha.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.js +16 -9
- package/lib/cjs/signature.d.ts +9 -1
- package/lib/cjs/signature.js +3 -1
- package/lib/cjs/types.d.ts +10 -1
- package/lib/cjs/types.js +1 -3
- package/lib/esm/embed.js +16 -9
- package/lib/esm/signature.d.ts +9 -1
- package/lib/esm/signature.js +3 -1
- package/lib/esm/types.d.ts +10 -1
- package/lib/esm/types.js +1 -3
- package/package.json +1 -1
package/lib/cjs/embed.js
CHANGED
|
@@ -36,7 +36,7 @@ const validateProps = (props) => {
|
|
|
36
36
|
};
|
|
37
37
|
const embedSsoContent = async (props) => {
|
|
38
38
|
validateProps(props);
|
|
39
|
-
let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, externalId, filterSearchParam, linkAccess, mode, name, nonce, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, entityFolderContentRole, } = props;
|
|
39
|
+
let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, email, externalId, filterSearchParam, linkAccess, mode, name, nonce, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, entityFolderContentRole, groups: rawGroups, } = props;
|
|
40
40
|
let host, domain, organizationName;
|
|
41
41
|
if ("host" in props)
|
|
42
42
|
host = props.host;
|
|
@@ -49,30 +49,35 @@ const embedSsoContent = async (props) => {
|
|
|
49
49
|
const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
|
|
50
50
|
const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
|
|
51
51
|
const connectionRoles = rawConnectionRoles && JSON.stringify(rawConnectionRoles);
|
|
52
|
+
const groups = rawGroups && JSON.stringify(rawGroups);
|
|
52
53
|
// Generate the url for the embed login route
|
|
53
54
|
if (!host)
|
|
54
55
|
host = `${organizationName}.${domain !== null && domain !== void 0 ? domain : defaultEmbedDomain}`;
|
|
55
56
|
const url = new URL(embedLoginPath, `https://${host}${port ? `:${port}` : ""}`);
|
|
56
57
|
// Get a signature for the request
|
|
57
58
|
const signature = (0, signature_1.getSignature)({
|
|
59
|
+
// Required parameters
|
|
58
60
|
loginUrl: url.toString(),
|
|
59
61
|
contentPath,
|
|
60
62
|
externalId,
|
|
61
63
|
name,
|
|
62
64
|
nonce,
|
|
63
65
|
secret,
|
|
64
|
-
|
|
66
|
+
// Optional parameters
|
|
67
|
+
accessBoost,
|
|
68
|
+
connectionRoles,
|
|
69
|
+
customTheme,
|
|
70
|
+
customThemeId,
|
|
71
|
+
email,
|
|
65
72
|
entity,
|
|
66
|
-
|
|
67
|
-
theme,
|
|
73
|
+
entityFolderContentRole,
|
|
68
74
|
filterSearchParam,
|
|
75
|
+
groups,
|
|
69
76
|
linkAccess,
|
|
70
|
-
customTheme,
|
|
71
|
-
customThemeId,
|
|
72
|
-
connectionRoles,
|
|
73
|
-
accessBoost,
|
|
74
77
|
mode,
|
|
75
|
-
|
|
78
|
+
prefersDark,
|
|
79
|
+
theme,
|
|
80
|
+
userAttributes,
|
|
76
81
|
});
|
|
77
82
|
// Build and return the signed url
|
|
78
83
|
url.searchParams.append("contentPath", contentPath);
|
|
@@ -95,6 +100,8 @@ const embedSsoContent = async (props) => {
|
|
|
95
100
|
mode && url.searchParams.append("mode", mode);
|
|
96
101
|
entityFolderContentRole &&
|
|
97
102
|
url.searchParams.append("entityFolderContentRole", entityFolderContentRole);
|
|
103
|
+
groups && url.searchParams.append("groups", groups);
|
|
104
|
+
email && url.searchParams.append("email", email);
|
|
98
105
|
return url.toString();
|
|
99
106
|
};
|
|
100
107
|
const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
|
package/lib/cjs/signature.d.ts
CHANGED
|
@@ -46,6 +46,10 @@ type SignatureProps = {
|
|
|
46
46
|
* The custom theme id to be sent with the request. This Id refers to an Custom Theme created in the Omni App.
|
|
47
47
|
*/
|
|
48
48
|
customThemeId?: string;
|
|
49
|
+
/**
|
|
50
|
+
* The email of the embed user.
|
|
51
|
+
*/
|
|
52
|
+
email?: string;
|
|
49
53
|
/**
|
|
50
54
|
* An associated entity / group for the embed user.
|
|
51
55
|
*/
|
|
@@ -58,6 +62,10 @@ type SignatureProps = {
|
|
|
58
62
|
* Filter search parameter.
|
|
59
63
|
*/
|
|
60
64
|
filterSearchParam?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Stringified string array of group names.
|
|
67
|
+
*/
|
|
68
|
+
groups?: string;
|
|
61
69
|
/**
|
|
62
70
|
* String denoting level of link access.
|
|
63
71
|
*/
|
|
@@ -83,6 +91,6 @@ type SignatureProps = {
|
|
|
83
91
|
};
|
|
84
92
|
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
85
93
|
export declare const TEST_ONLY: {
|
|
86
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, entity, entityFolderContentRole, filterSearchParam, linkAccess, mode, prefersDark, theme, userAttributes, }: Omit<SignatureProps, "secret">) => string;
|
|
94
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, userAttributes, }: Omit<SignatureProps, "secret">) => string;
|
|
87
95
|
};
|
|
88
96
|
export {};
|
package/lib/cjs/signature.js
CHANGED
|
@@ -17,7 +17,7 @@ const generateStringForSignature = ({
|
|
|
17
17
|
// Required parameters
|
|
18
18
|
loginUrl, contentPath, externalId, name, nonce,
|
|
19
19
|
// Optional parameters
|
|
20
|
-
accessBoost, connectionRoles, customTheme, customThemeId, entity, entityFolderContentRole, filterSearchParam, linkAccess, mode, prefersDark, theme, userAttributes, }) => {
|
|
20
|
+
accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, userAttributes, }) => {
|
|
21
21
|
// We create a map of optional params and convert it to an array
|
|
22
22
|
// to ensure that the order of the optional params is alphabetical and consistent.
|
|
23
23
|
const optionalParamsMap = {
|
|
@@ -25,9 +25,11 @@ accessBoost, connectionRoles, customTheme, customThemeId, entity, entityFolderCo
|
|
|
25
25
|
...(connectionRoles && { connectionRoles }),
|
|
26
26
|
...(customTheme && { customTheme }),
|
|
27
27
|
...(customThemeId && { customThemeId }),
|
|
28
|
+
...(email && { email }),
|
|
28
29
|
...(entity && { entity }),
|
|
29
30
|
...(entityFolderContentRole && { entityFolderContentRole }),
|
|
30
31
|
...(filterSearchParam && { filterSearchParam }),
|
|
32
|
+
...(groups && { groups }),
|
|
31
33
|
...(linkAccess && { linkAccess }),
|
|
32
34
|
...(mode && { mode }),
|
|
33
35
|
...(prefersDark && { prefersDark }),
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -28,6 +28,14 @@ type EmbedSsoBaseProps = {
|
|
|
28
28
|
* their associated embed entity folder.
|
|
29
29
|
*/
|
|
30
30
|
entityFolderContentRole?: EmbedEntityFolderContentRoles;
|
|
31
|
+
/**
|
|
32
|
+
* Optional groups setting. An array of group names that the user will be added to.
|
|
33
|
+
*/
|
|
34
|
+
groups?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* Optional email setting for the generated embed user.
|
|
37
|
+
*/
|
|
38
|
+
email?: string;
|
|
31
39
|
nonce?: string;
|
|
32
40
|
port?: number;
|
|
33
41
|
} & ({
|
|
@@ -119,7 +127,8 @@ export declare enum EmbeddedContent {
|
|
|
119
127
|
export declare const EmbedSsoContentDiscoveryPaths: readonly ["my", "entity-folder", "root"];
|
|
120
128
|
export type EmbedSsoContentDiscoveryPath = (typeof EmbedSsoContentDiscoveryPaths)[number];
|
|
121
129
|
export declare enum EmbedConnectionRoles {
|
|
122
|
-
RESTRICTED_QUERIER = "RESTRICTED_QUERIER"
|
|
130
|
+
RESTRICTED_QUERIER = "RESTRICTED_QUERIER",
|
|
131
|
+
VIEWER = "VIEWER"
|
|
123
132
|
}
|
|
124
133
|
/**
|
|
125
134
|
* Levels of access a user can have to their associated embed entity folder.
|
package/lib/cjs/types.js
CHANGED
|
@@ -39,10 +39,8 @@ exports.EmbedSsoContentDiscoveryPaths = [
|
|
|
39
39
|
];
|
|
40
40
|
var EmbedConnectionRoles;
|
|
41
41
|
(function (EmbedConnectionRoles) {
|
|
42
|
-
// TODO: Eventually we'll want to add VIEWER. Currently though, since the sole use case of the
|
|
43
|
-
// connectionRoles parameter is personal content creation, I'm refraining from adding "VIEWER" to
|
|
44
|
-
// keep scope as limited as possible.
|
|
45
42
|
EmbedConnectionRoles["RESTRICTED_QUERIER"] = "RESTRICTED_QUERIER";
|
|
43
|
+
EmbedConnectionRoles["VIEWER"] = "VIEWER";
|
|
46
44
|
})(EmbedConnectionRoles || (exports.EmbedConnectionRoles = EmbedConnectionRoles = {}));
|
|
47
45
|
/**
|
|
48
46
|
* Levels of access a user can have to their associated embed entity folder.
|
package/lib/esm/embed.js
CHANGED
|
@@ -33,7 +33,7 @@ const validateProps = (props) => {
|
|
|
33
33
|
};
|
|
34
34
|
const embedSsoContent = async (props) => {
|
|
35
35
|
validateProps(props);
|
|
36
|
-
let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, externalId, filterSearchParam, linkAccess, mode, name, nonce, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, entityFolderContentRole, } = props;
|
|
36
|
+
let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, email, externalId, filterSearchParam, linkAccess, mode, name, nonce, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, entityFolderContentRole, groups: rawGroups, } = props;
|
|
37
37
|
let host, domain, organizationName;
|
|
38
38
|
if ("host" in props)
|
|
39
39
|
host = props.host;
|
|
@@ -46,30 +46,35 @@ const embedSsoContent = async (props) => {
|
|
|
46
46
|
const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
|
|
47
47
|
const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
|
|
48
48
|
const connectionRoles = rawConnectionRoles && JSON.stringify(rawConnectionRoles);
|
|
49
|
+
const groups = rawGroups && JSON.stringify(rawGroups);
|
|
49
50
|
// Generate the url for the embed login route
|
|
50
51
|
if (!host)
|
|
51
52
|
host = `${organizationName}.${domain !== null && domain !== void 0 ? domain : defaultEmbedDomain}`;
|
|
52
53
|
const url = new URL(embedLoginPath, `https://${host}${port ? `:${port}` : ""}`);
|
|
53
54
|
// Get a signature for the request
|
|
54
55
|
const signature = getSignature({
|
|
56
|
+
// Required parameters
|
|
55
57
|
loginUrl: url.toString(),
|
|
56
58
|
contentPath,
|
|
57
59
|
externalId,
|
|
58
60
|
name,
|
|
59
61
|
nonce,
|
|
60
62
|
secret,
|
|
61
|
-
|
|
63
|
+
// Optional parameters
|
|
64
|
+
accessBoost,
|
|
65
|
+
connectionRoles,
|
|
66
|
+
customTheme,
|
|
67
|
+
customThemeId,
|
|
68
|
+
email,
|
|
62
69
|
entity,
|
|
63
|
-
|
|
64
|
-
theme,
|
|
70
|
+
entityFolderContentRole,
|
|
65
71
|
filterSearchParam,
|
|
72
|
+
groups,
|
|
66
73
|
linkAccess,
|
|
67
|
-
customTheme,
|
|
68
|
-
customThemeId,
|
|
69
|
-
connectionRoles,
|
|
70
|
-
accessBoost,
|
|
71
74
|
mode,
|
|
72
|
-
|
|
75
|
+
prefersDark,
|
|
76
|
+
theme,
|
|
77
|
+
userAttributes,
|
|
73
78
|
});
|
|
74
79
|
// Build and return the signed url
|
|
75
80
|
url.searchParams.append("contentPath", contentPath);
|
|
@@ -92,6 +97,8 @@ const embedSsoContent = async (props) => {
|
|
|
92
97
|
mode && url.searchParams.append("mode", mode);
|
|
93
98
|
entityFolderContentRole &&
|
|
94
99
|
url.searchParams.append("entityFolderContentRole", entityFolderContentRole);
|
|
100
|
+
groups && url.searchParams.append("groups", groups);
|
|
101
|
+
email && url.searchParams.append("email", email);
|
|
95
102
|
return url.toString();
|
|
96
103
|
};
|
|
97
104
|
const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
|
package/lib/esm/signature.d.ts
CHANGED
|
@@ -46,6 +46,10 @@ type SignatureProps = {
|
|
|
46
46
|
* The custom theme id to be sent with the request. This Id refers to an Custom Theme created in the Omni App.
|
|
47
47
|
*/
|
|
48
48
|
customThemeId?: string;
|
|
49
|
+
/**
|
|
50
|
+
* The email of the embed user.
|
|
51
|
+
*/
|
|
52
|
+
email?: string;
|
|
49
53
|
/**
|
|
50
54
|
* An associated entity / group for the embed user.
|
|
51
55
|
*/
|
|
@@ -58,6 +62,10 @@ type SignatureProps = {
|
|
|
58
62
|
* Filter search parameter.
|
|
59
63
|
*/
|
|
60
64
|
filterSearchParam?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Stringified string array of group names.
|
|
67
|
+
*/
|
|
68
|
+
groups?: string;
|
|
61
69
|
/**
|
|
62
70
|
* String denoting level of link access.
|
|
63
71
|
*/
|
|
@@ -83,6 +91,6 @@ type SignatureProps = {
|
|
|
83
91
|
};
|
|
84
92
|
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
85
93
|
export declare const TEST_ONLY: {
|
|
86
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, entity, entityFolderContentRole, filterSearchParam, linkAccess, mode, prefersDark, theme, userAttributes, }: Omit<SignatureProps, "secret">) => string;
|
|
94
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, userAttributes, }: Omit<SignatureProps, "secret">) => string;
|
|
87
95
|
};
|
|
88
96
|
export {};
|
package/lib/esm/signature.js
CHANGED
|
@@ -10,7 +10,7 @@ const generateStringForSignature = ({
|
|
|
10
10
|
// Required parameters
|
|
11
11
|
loginUrl, contentPath, externalId, name, nonce,
|
|
12
12
|
// Optional parameters
|
|
13
|
-
accessBoost, connectionRoles, customTheme, customThemeId, entity, entityFolderContentRole, filterSearchParam, linkAccess, mode, prefersDark, theme, userAttributes, }) => {
|
|
13
|
+
accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, userAttributes, }) => {
|
|
14
14
|
// We create a map of optional params and convert it to an array
|
|
15
15
|
// to ensure that the order of the optional params is alphabetical and consistent.
|
|
16
16
|
const optionalParamsMap = {
|
|
@@ -18,9 +18,11 @@ accessBoost, connectionRoles, customTheme, customThemeId, entity, entityFolderCo
|
|
|
18
18
|
...(connectionRoles && { connectionRoles }),
|
|
19
19
|
...(customTheme && { customTheme }),
|
|
20
20
|
...(customThemeId && { customThemeId }),
|
|
21
|
+
...(email && { email }),
|
|
21
22
|
...(entity && { entity }),
|
|
22
23
|
...(entityFolderContentRole && { entityFolderContentRole }),
|
|
23
24
|
...(filterSearchParam && { filterSearchParam }),
|
|
25
|
+
...(groups && { groups }),
|
|
24
26
|
...(linkAccess && { linkAccess }),
|
|
25
27
|
...(mode && { mode }),
|
|
26
28
|
...(prefersDark && { prefersDark }),
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -28,6 +28,14 @@ type EmbedSsoBaseProps = {
|
|
|
28
28
|
* their associated embed entity folder.
|
|
29
29
|
*/
|
|
30
30
|
entityFolderContentRole?: EmbedEntityFolderContentRoles;
|
|
31
|
+
/**
|
|
32
|
+
* Optional groups setting. An array of group names that the user will be added to.
|
|
33
|
+
*/
|
|
34
|
+
groups?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* Optional email setting for the generated embed user.
|
|
37
|
+
*/
|
|
38
|
+
email?: string;
|
|
31
39
|
nonce?: string;
|
|
32
40
|
port?: number;
|
|
33
41
|
} & ({
|
|
@@ -119,7 +127,8 @@ export declare enum EmbeddedContent {
|
|
|
119
127
|
export declare const EmbedSsoContentDiscoveryPaths: readonly ["my", "entity-folder", "root"];
|
|
120
128
|
export type EmbedSsoContentDiscoveryPath = (typeof EmbedSsoContentDiscoveryPaths)[number];
|
|
121
129
|
export declare enum EmbedConnectionRoles {
|
|
122
|
-
RESTRICTED_QUERIER = "RESTRICTED_QUERIER"
|
|
130
|
+
RESTRICTED_QUERIER = "RESTRICTED_QUERIER",
|
|
131
|
+
VIEWER = "VIEWER"
|
|
123
132
|
}
|
|
124
133
|
/**
|
|
125
134
|
* Levels of access a user can have to their associated embed entity folder.
|
package/lib/esm/types.js
CHANGED
|
@@ -36,10 +36,8 @@ export const EmbedSsoContentDiscoveryPaths = [
|
|
|
36
36
|
];
|
|
37
37
|
export var EmbedConnectionRoles;
|
|
38
38
|
(function (EmbedConnectionRoles) {
|
|
39
|
-
// TODO: Eventually we'll want to add VIEWER. Currently though, since the sole use case of the
|
|
40
|
-
// connectionRoles parameter is personal content creation, I'm refraining from adding "VIEWER" to
|
|
41
|
-
// keep scope as limited as possible.
|
|
42
39
|
EmbedConnectionRoles["RESTRICTED_QUERIER"] = "RESTRICTED_QUERIER";
|
|
40
|
+
EmbedConnectionRoles["VIEWER"] = "VIEWER";
|
|
43
41
|
})(EmbedConnectionRoles || (EmbedConnectionRoles = {}));
|
|
44
42
|
/**
|
|
45
43
|
* Levels of access a user can have to their associated embed entity folder.
|
package/package.json
CHANGED