@omni-co/embed 0.17.0 → 0.19.0
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 +134 -134
- package/lib/cjs/embed.d.ts +1 -1
- package/lib/cjs/embed.js +61 -63
- package/lib/cjs/index.d.ts +4 -4
- package/lib/cjs/omni_internal_browser.d.ts +2 -2
- package/lib/cjs/random-str.server.js +2 -2
- package/lib/cjs/signature.d.ts +8 -2
- package/lib/cjs/signature.js +9 -8
- package/lib/cjs/types.d.ts +4 -15
- package/lib/cjs/types.js +0 -1
- package/lib/esm/embed.d.ts +1 -1
- package/lib/esm/embed.js +64 -66
- package/lib/esm/index.d.ts +4 -4
- package/lib/esm/index.js +4 -4
- package/lib/esm/omni_internal_browser.d.ts +2 -2
- package/lib/esm/omni_internal_browser.js +2 -2
- package/lib/esm/random-str.server.js +3 -3
- package/lib/esm/signature.d.ts +8 -2
- package/lib/esm/signature.js +10 -9
- package/lib/esm/types.d.ts +4 -15
- package/lib/esm/types.js +1 -1
- package/lib/omni_internal_browser/omni_internal_browser.d.ts +2 -2
- package/lib/omni_internal_browser/omni_internal_browser.js +2 -2
- package/lib/omni_internal_browser/types.d.ts +4 -15
- package/lib/omni_internal_browser/types.js +1 -1
- package/package.json +15 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import crypto from
|
|
1
|
+
import crypto from 'crypto';
|
|
2
2
|
/**
|
|
3
3
|
* Generates a random 32 byte, human readable string.
|
|
4
4
|
* Based on math at https://zelark.github.io/nano-id-cc/
|
|
@@ -7,8 +7,8 @@ import crypto from "crypto";
|
|
|
7
7
|
* of at least one collision.
|
|
8
8
|
*/
|
|
9
9
|
export const random32ByteString = async () => {
|
|
10
|
-
const humanReadableByteSpace =
|
|
11
|
-
let randomString =
|
|
10
|
+
const humanReadableByteSpace = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
11
|
+
let randomString = '';
|
|
12
12
|
for (let i = 0; i < 32; i++) {
|
|
13
13
|
// Generate a random number between 0 and humanReadableByteSpace.length - 1
|
|
14
14
|
// and return the corresponding character from humanReadableByteSpace.
|
package/lib/esm/signature.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RedeemSessionExclusiveProps } from
|
|
1
|
+
import { RedeemSessionExclusiveProps } from './types.js';
|
|
2
2
|
export declare const hmacSign: (data: string, secret: string) => string;
|
|
3
3
|
type SignatureProps = {
|
|
4
4
|
/**
|
|
@@ -109,6 +109,12 @@ type SignatureProps = {
|
|
|
109
109
|
* The theme of the embed.
|
|
110
110
|
*/
|
|
111
111
|
theme?: string;
|
|
112
|
+
/**
|
|
113
|
+
* IANA timezone override applied to the embed session's query execution.
|
|
114
|
+
*
|
|
115
|
+
* Example: "America/New_York"
|
|
116
|
+
*/
|
|
117
|
+
timezone?: string;
|
|
112
118
|
/**
|
|
113
119
|
* The UI settings for the embedded content.
|
|
114
120
|
*/
|
|
@@ -140,6 +146,6 @@ type SignSessionRedemptionProps = Pick<SignatureProps, RedeemSessionExclusivePro
|
|
|
140
146
|
*/
|
|
141
147
|
export declare const signSessionRedemption: ({ requestUrl, nonce, sessionId, secret, branch, prefersDark, theme, }: SignSessionRedemptionProps) => string;
|
|
142
148
|
export declare const TEST_ONLY: {
|
|
143
|
-
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, branch, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, modelRoles, prefersDark, preserveEntityFolderContentRole, theme, uiSettings, userAttributes, }: Omit<SignatureProps, "secret">) => string;
|
|
149
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, branch, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, modelRoles, prefersDark, preserveEntityFolderContentRole, theme, timezone, uiSettings, userAttributes, }: Omit<SignatureProps, "secret">) => string;
|
|
144
150
|
};
|
|
145
151
|
export {};
|
package/lib/esm/signature.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import crypto from
|
|
1
|
+
import crypto from 'crypto';
|
|
2
2
|
export const hmacSign = (data, secret) => {
|
|
3
|
-
const hmac = crypto.createHmac(
|
|
3
|
+
const hmac = crypto.createHmac('sha256', secret);
|
|
4
4
|
hmac.update(data);
|
|
5
|
-
return hmac.digest(
|
|
5
|
+
return hmac.digest('base64url');
|
|
6
6
|
};
|
|
7
7
|
const generateStringForSignature = ({
|
|
8
8
|
// Required parameters
|
|
9
9
|
loginUrl, contentPath, externalId, name, nonce,
|
|
10
10
|
// Optional parameters
|
|
11
|
-
accessBoost, branch, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, modelRoles, prefersDark, preserveEntityFolderContentRole, theme, uiSettings, userAttributes, }) => {
|
|
11
|
+
accessBoost, branch, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, modelRoles, prefersDark, preserveEntityFolderContentRole, theme, timezone, uiSettings, userAttributes, }) => {
|
|
12
12
|
// We create a map of optional params and convert it to an array
|
|
13
13
|
// to ensure that the order of the optional params is alphabetical and consistent.
|
|
14
14
|
const optionalParamsMap = {
|
|
15
|
-
...(accessBoost !== undefined && { accessBoost: accessBoost.toString() }),
|
|
15
|
+
...(accessBoost !== undefined && { accessBoost: accessBoost.toString() }), // need to support accessBoost=false
|
|
16
16
|
...(branch && { branch }),
|
|
17
17
|
...(connectionRoles && { connectionRoles }),
|
|
18
18
|
...(customTheme && { customTheme }),
|
|
@@ -33,6 +33,7 @@ accessBoost, branch, connectionRoles, customTheme, customThemeId, email, entity,
|
|
|
33
33
|
preserveEntityFolderContentRole: preserveEntityFolderContentRole.toString(),
|
|
34
34
|
}),
|
|
35
35
|
...(theme && { theme }),
|
|
36
|
+
...(timezone && { timezone }),
|
|
36
37
|
...(uiSettings && { uiSettings }),
|
|
37
38
|
...(userAttributes && { userAttributes }),
|
|
38
39
|
};
|
|
@@ -47,10 +48,10 @@ accessBoost, branch, connectionRoles, customTheme, customThemeId, email, entity,
|
|
|
47
48
|
${externalId}
|
|
48
49
|
${name}
|
|
49
50
|
${nonce}
|
|
50
|
-
${optionalParams.join(
|
|
51
|
+
${optionalParams.join('\n')}
|
|
51
52
|
`
|
|
52
53
|
.trim()
|
|
53
|
-
.replace(/\n\s+/g,
|
|
54
|
+
.replace(/\n\s+/g, '\n');
|
|
54
55
|
};
|
|
55
56
|
/**
|
|
56
57
|
* Creates a signature value for the /embed/login endpoint.
|
|
@@ -81,10 +82,10 @@ export const signSessionRedemption = ({ requestUrl, nonce, sessionId, secret, br
|
|
|
81
82
|
${requestUrl}
|
|
82
83
|
${nonce}
|
|
83
84
|
${sessionId}
|
|
84
|
-
${optionalParams.join(
|
|
85
|
+
${optionalParams.join('\n')}
|
|
85
86
|
`
|
|
86
87
|
.trim()
|
|
87
|
-
.replace(/\n\s+/g,
|
|
88
|
+
.replace(/\n\s+/g, '\n');
|
|
88
89
|
return hmacSign(signatureString, secret);
|
|
89
90
|
};
|
|
90
91
|
export const TEST_ONLY = {
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomThemeProperty, EmbedEntityFolderContentRoles, EmbedSessionMode, EmbedUiSettings } from
|
|
1
|
+
import type { CustomThemeProperty, EmbedEntityFolderContentRoles, EmbedSessionMode, EmbedUiSettings } from './constants.js';
|
|
2
2
|
type UserAttributeValue = string | string[] | number | number[];
|
|
3
3
|
type HostProps = ({
|
|
4
4
|
host?: never;
|
|
@@ -39,6 +39,7 @@ type EmbedSsoBaseProps = {
|
|
|
39
39
|
userAttributes?: Record<string, UserAttributeValue>;
|
|
40
40
|
prefersDark?: string;
|
|
41
41
|
theme?: string;
|
|
42
|
+
timezone?: string;
|
|
42
43
|
customTheme?: CustomThemeProperties;
|
|
43
44
|
customThemeId?: string;
|
|
44
45
|
/**
|
|
@@ -187,20 +188,8 @@ export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
|
|
|
187
188
|
* Path name of the content discovery page to embed.
|
|
188
189
|
*/
|
|
189
190
|
path: string;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
* Required connection roles object. Object keys should be connection IDs from the embedded Omni instance.
|
|
193
|
-
* Object values should be connection roles (base roles or custom role names).
|
|
194
|
-
*/
|
|
195
|
-
connectionRoles: Record<string, string>;
|
|
196
|
-
} | {
|
|
197
|
-
/**
|
|
198
|
-
* Required model roles object. Object keys should be model IDs from the embedded Omni instance.
|
|
199
|
-
* Object values should be model roles (base roles or custom role names).
|
|
200
|
-
*/
|
|
201
|
-
modelRoles: Record<string, string>;
|
|
202
|
-
});
|
|
203
|
-
export type RedeemSessionExclusiveProps = "branch" | "nonce" | "prefersDark" | "secret" | "theme";
|
|
191
|
+
};
|
|
192
|
+
export type RedeemSessionExclusiveProps = 'branch' | 'nonce' | 'prefersDark' | 'secret' | 'theme';
|
|
204
193
|
export type CreateSessionTokenProps = Omit<EmbedSsoContentProps, RedeemSessionExclusiveProps> & {
|
|
205
194
|
apiKey: string;
|
|
206
195
|
} & HostProps;
|
package/lib/esm/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomThemeProperty, EmbedEntityFolderContentRoles, EmbedSessionMode, EmbedUiSettings } from
|
|
1
|
+
import type { CustomThemeProperty, EmbedEntityFolderContentRoles, EmbedSessionMode, EmbedUiSettings } from './constants.js';
|
|
2
2
|
type UserAttributeValue = string | string[] | number | number[];
|
|
3
3
|
type HostProps = ({
|
|
4
4
|
host?: never;
|
|
@@ -39,6 +39,7 @@ type EmbedSsoBaseProps = {
|
|
|
39
39
|
userAttributes?: Record<string, UserAttributeValue>;
|
|
40
40
|
prefersDark?: string;
|
|
41
41
|
theme?: string;
|
|
42
|
+
timezone?: string;
|
|
42
43
|
customTheme?: CustomThemeProperties;
|
|
43
44
|
customThemeId?: string;
|
|
44
45
|
/**
|
|
@@ -187,20 +188,8 @@ export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
|
|
|
187
188
|
* Path name of the content discovery page to embed.
|
|
188
189
|
*/
|
|
189
190
|
path: string;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
* Required connection roles object. Object keys should be connection IDs from the embedded Omni instance.
|
|
193
|
-
* Object values should be connection roles (base roles or custom role names).
|
|
194
|
-
*/
|
|
195
|
-
connectionRoles: Record<string, string>;
|
|
196
|
-
} | {
|
|
197
|
-
/**
|
|
198
|
-
* Required model roles object. Object keys should be model IDs from the embedded Omni instance.
|
|
199
|
-
* Object values should be model roles (base roles or custom role names).
|
|
200
|
-
*/
|
|
201
|
-
modelRoles: Record<string, string>;
|
|
202
|
-
});
|
|
203
|
-
export type RedeemSessionExclusiveProps = "branch" | "nonce" | "prefersDark" | "secret" | "theme";
|
|
191
|
+
};
|
|
192
|
+
export type RedeemSessionExclusiveProps = 'branch' | 'nonce' | 'prefersDark' | 'secret' | 'theme';
|
|
204
193
|
export type CreateSessionTokenProps = Omit<EmbedSsoContentProps, RedeemSessionExclusiveProps> & {
|
|
205
194
|
apiKey: string;
|
|
206
195
|
} & HostProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.19.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "@omni-co/embed",
|
|
5
5
|
"author": "Nate Agrin <nate@exploreomni.com>",
|
|
@@ -7,10 +7,16 @@
|
|
|
7
7
|
"lib/**/*"
|
|
8
8
|
],
|
|
9
9
|
"devDependencies": {
|
|
10
|
+
"@eslint/js": "^10.0.1",
|
|
10
11
|
"@types/node": "^20.8.9",
|
|
12
|
+
"eslint": "^10.3.0",
|
|
13
|
+
"eslint-config-prettier": "^10.1.8",
|
|
14
|
+
"globals": "^17.6.0",
|
|
15
|
+
"prettier": "^3.8.3",
|
|
11
16
|
"semantic-release": "^25.0.2",
|
|
12
17
|
"typescript": "^5.2.2",
|
|
13
|
-
"
|
|
18
|
+
"typescript-eslint": "^8.59.3",
|
|
19
|
+
"vitest": "^4.1.6"
|
|
14
20
|
},
|
|
15
21
|
"scripts": {
|
|
16
22
|
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:omni_internal_browser",
|
|
@@ -18,9 +24,15 @@
|
|
|
18
24
|
"build:cjs": "tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./lib/cjs/package.json",
|
|
19
25
|
"build:omni_internal_browser": "tsc -p tsconfig.omni_internal_browser.json && echo '{\"type\": \"module\"}' > ./lib/omni_internal_browser/package.json",
|
|
20
26
|
"clean": "rm -rf lib",
|
|
27
|
+
"eslint": "eslint .",
|
|
28
|
+
"eslint:fix": "eslint . --fix",
|
|
29
|
+
"fix": "npm run eslint:fix && npm run prettier:fix",
|
|
30
|
+
"lint": "npm run eslint && npm run prettier",
|
|
21
31
|
"lint:ts": "tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"prettier": "prettier --check .",
|
|
33
|
+
"prettier:fix": "prettier --write .",
|
|
22
34
|
"prepublishOnly": "npm run build",
|
|
23
|
-
"test": "vitest",
|
|
35
|
+
"test": "vitest run",
|
|
24
36
|
"test:watch": "vitest --watch"
|
|
25
37
|
},
|
|
26
38
|
"engines": {
|