@omni-co/embed 0.16.0 → 0.17.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/lib/cjs/embed.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.redeemSessionToken = exports.createSessionToken = exports.embedSsoContentDiscovery = exports.embedSsoWorkbook = exports.embedSsoDashboard = void 0;
4
- const random_str_js_1 = require("./random-str.js");
4
+ const random_str_server_js_1 = require("./random-str.server.js");
5
5
  const signature_js_1 = require("./signature.js");
6
6
  const constants_js_1 = require("./constants.js");
7
7
  const defaultEmbedDomain = "embed-omniapp.co";
@@ -56,7 +56,7 @@ const embedSsoContent = async (props) => {
56
56
  validateProps(props);
57
57
  let { accessBoost, branch, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, domain, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, externalId, filterSearchParam, groups: rawGroups, host, linkAccess, mode, modelRoles: rawModelRoles, name, nonce, organizationName, preserveEntityFolderContentRole, prefersDark, port, secret, theme, uiSettings: rawUiSettings, userAttributes: rawUserAttributes, } = props;
58
58
  // Handle defaults
59
- nonce = nonce ?? (await (0, random_str_js_1.random32ByteString)());
59
+ nonce = nonce ?? (await (0, random_str_server_js_1.random32ByteString)());
60
60
  const uiSettings = rawUiSettings && JSON.stringify(rawUiSettings);
61
61
  const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
62
62
  const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
@@ -219,7 +219,7 @@ theme, }) => {
219
219
  port,
220
220
  requestPath: redeemSsoEmbedSessionPath,
221
221
  });
222
- const nonce = propsNonce ?? (await (0, random_str_js_1.random32ByteString)());
222
+ const nonce = propsNonce ?? (await (0, random_str_server_js_1.random32ByteString)());
223
223
  const signature = (0, signature_js_1.signSessionRedemption)({
224
224
  requestUrl: redeemRequestUrl.toString(),
225
225
  nonce,
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generates a random 32 byte, human readable string.
3
+ * Based on math at https://zelark.github.io/nano-id-cc/
4
+ * at 1000 Ids/s it would take more than 1 quadrillion years or
5
+ * 8,730,800,738,924,245T IDs, in order to have a 1% probability
6
+ * of at least one collision.
7
+ */
8
+ export declare const random32ByteString: () => Promise<string>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.random32ByteString = void 0;
7
+ const crypto_1 = __importDefault(require("crypto"));
8
+ /**
9
+ * Generates a random 32 byte, human readable string.
10
+ * Based on math at https://zelark.github.io/nano-id-cc/
11
+ * at 1000 Ids/s it would take more than 1 quadrillion years or
12
+ * 8,730,800,738,924,245T IDs, in order to have a 1% probability
13
+ * of at least one collision.
14
+ */
15
+ const random32ByteString = async () => {
16
+ const humanReadableByteSpace = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
17
+ let randomString = "";
18
+ for (let i = 0; i < 32; i++) {
19
+ // Generate a random number between 0 and humanReadableByteSpace.length - 1
20
+ // and return the corresponding character from humanReadableByteSpace.
21
+ const randomIndex = crypto_1.default.randomInt(0, humanReadableByteSpace.length);
22
+ randomString += humanReadableByteSpace[randomIndex];
23
+ }
24
+ return randomString;
25
+ };
26
+ exports.random32ByteString = random32ByteString;
package/lib/esm/embed.js CHANGED
@@ -1,4 +1,4 @@
1
- import { random32ByteString } from "./random-str.js";
1
+ import { random32ByteString } from "./random-str.server.js";
2
2
  import { getSignature, signSessionRedemption } from "./signature.js";
3
3
  import { EmbeddedContent } from "./constants.js";
4
4
  const defaultEmbedDomain = "embed-omniapp.co";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generates a random 32 byte, human readable string.
3
+ * Based on math at https://zelark.github.io/nano-id-cc/
4
+ * at 1000 Ids/s it would take more than 1 quadrillion years or
5
+ * 8,730,800,738,924,245T IDs, in order to have a 1% probability
6
+ * of at least one collision.
7
+ */
8
+ export declare const random32ByteString: () => Promise<string>;
@@ -0,0 +1,19 @@
1
+ import crypto from "crypto";
2
+ /**
3
+ * Generates a random 32 byte, human readable string.
4
+ * Based on math at https://zelark.github.io/nano-id-cc/
5
+ * at 1000 Ids/s it would take more than 1 quadrillion years or
6
+ * 8,730,800,738,924,245T IDs, in order to have a 1% probability
7
+ * of at least one collision.
8
+ */
9
+ export const random32ByteString = async () => {
10
+ const humanReadableByteSpace = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
11
+ let randomString = "";
12
+ for (let i = 0; i < 32; i++) {
13
+ // Generate a random number between 0 and humanReadableByteSpace.length - 1
14
+ // and return the corresponding character from humanReadableByteSpace.
15
+ const randomIndex = crypto.randomInt(0, humanReadableByteSpace.length);
16
+ randomString += humanReadableByteSpace[randomIndex];
17
+ }
18
+ return randomString;
19
+ };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.16.0",
2
+ "version": "0.17.0",
3
3
  "license": "MIT",
4
4
  "name": "@omni-co/embed",
5
5
  "author": "Nate Agrin <nate@exploreomni.com>",
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "devDependencies": {
10
10
  "@types/node": "^20.8.9",
11
- "semantic-release": "^24.2.1",
11
+ "semantic-release": "^25.0.2",
12
12
  "typescript": "^5.2.2",
13
13
  "vitest": "^0.34.6"
14
14
  },
@@ -23,9 +23,6 @@
23
23
  "test": "vitest",
24
24
  "test:watch": "vitest --watch"
25
25
  },
26
- "dependencies": {
27
- "nanoid": "3.3.7"
28
- },
29
26
  "engines": {
30
27
  "node": ">=18"
31
28
  },
@@ -46,5 +43,6 @@
46
43
  "./lib/cjs/index.js": "./lib/cjs/index.js",
47
44
  "./lib/esm": "./lib/esm/index.js",
48
45
  "./lib/cjs": "./lib/cjs/index.js"
49
- }
46
+ },
47
+ "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
50
48
  }
@@ -1 +0,0 @@
1
- export declare const random32ByteString: () => Promise<string>;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.random32ByteString = void 0;
4
- const nanoid_1 = require("nanoid");
5
- const humanReadableByteSpace = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
6
- // Generates a random 32 byte, human readable string.
7
- // Based on math at https://zelark.github.io/nano-id-cc/
8
- // at 1000 Ids/s it would take more than 1 quadrillion years or
9
- // 8,730,800,738,924,245T IDs, in order to have a 1% probability
10
- // of at least one collision.
11
- const random32ByteString = async () => {
12
- return (0, nanoid_1.customAlphabet)(humanReadableByteSpace, 32)();
13
- };
14
- exports.random32ByteString = random32ByteString;
@@ -1 +0,0 @@
1
- export declare const random32ByteString: () => Promise<string>;
@@ -1,10 +0,0 @@
1
- import { customAlphabet } from "nanoid";
2
- const humanReadableByteSpace = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
3
- // Generates a random 32 byte, human readable string.
4
- // Based on math at https://zelark.github.io/nano-id-cc/
5
- // at 1000 Ids/s it would take more than 1 quadrillion years or
6
- // 8,730,800,738,924,245T IDs, in order to have a 1% probability
7
- // of at least one collision.
8
- export const random32ByteString = async () => {
9
- return customAlphabet(humanReadableByteSpace, 32)();
10
- };