@omni-co/embed 0.2.3 → 0.3.0-pre.2

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.
@@ -12,5 +12,5 @@ type EmbedSsoProps = {
12
12
  nonce?: string;
13
13
  port?: number;
14
14
  };
15
- export declare const embedSsoDashboard: (props: EmbedSsoProps) => string;
15
+ export declare const embedSsoDashboard: (props: EmbedSsoProps) => Promise<string>;
16
16
  export {};
package/lib/cjs/embed.js CHANGED
@@ -32,12 +32,12 @@ const validateProps = (props) => {
32
32
  }
33
33
  }
34
34
  };
35
- const embedSsoDashboard = (props) => {
35
+ const embedSsoDashboard = async (props) => {
36
36
  validateProps(props);
37
37
  let { contentId, domain, externalId, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
38
38
  // Handle defaults
39
- nonce = nonce ?? (0, random_str_1.random32ByteString)();
40
- domain = domain ?? defaultEmbedDomain;
39
+ nonce = nonce !== null && nonce !== void 0 ? nonce : (await (0, random_str_1.random32ByteString)());
40
+ domain = domain !== null && domain !== void 0 ? domain : defaultEmbedDomain;
41
41
  const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
42
42
  // Generate the url for the embed login route
43
43
  const url = new URL(embedLoginRoute, `https://${organizationName.toLocaleLowerCase()}.${domain}${port ? `:${port}` : ""}`);
@@ -1 +1 @@
1
- export declare const random32ByteString: (size?: number | undefined) => string;
1
+ export declare const random32ByteString: () => Promise<string>;
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.random32ByteString = void 0;
4
- const nanoid_1 = require("nanoid");
4
+ const nanoid = import("nanoid");
5
5
  const humanReadableByteSpace = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
6
6
  // Generates a random 32 byte, human readable string.
7
7
  // Based on math at https://zelark.github.io/nano-id-cc/
8
8
  // at 1000 Ids/s it would take more than 1 quadrillion years or
9
9
  // 8,730,800,738,924,245T IDs, in order to have a 1% probability
10
10
  // of at least one collision.
11
- exports.random32ByteString = (0, nanoid_1.customAlphabet)(humanReadableByteSpace, 32);
11
+ const random32ByteString = async () => {
12
+ const { customAlphabet } = await nanoid;
13
+ return customAlphabet(humanReadableByteSpace, 32)();
14
+ };
15
+ exports.random32ByteString = random32ByteString;
@@ -12,5 +12,5 @@ type EmbedSsoProps = {
12
12
  nonce?: string;
13
13
  port?: number;
14
14
  };
15
- export declare const embedSsoDashboard: (props: EmbedSsoProps) => string;
15
+ export declare const embedSsoDashboard: (props: EmbedSsoProps) => Promise<string>;
16
16
  export {};
package/lib/esm/embed.js CHANGED
@@ -29,12 +29,12 @@ const validateProps = (props) => {
29
29
  }
30
30
  }
31
31
  };
32
- export const embedSsoDashboard = (props) => {
32
+ export const embedSsoDashboard = async (props) => {
33
33
  validateProps(props);
34
34
  let { contentId, domain, externalId, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
35
35
  // Handle defaults
36
- nonce = nonce ?? random32ByteString();
37
- domain = domain ?? defaultEmbedDomain;
36
+ nonce = nonce !== null && nonce !== void 0 ? nonce : (await random32ByteString());
37
+ domain = domain !== null && domain !== void 0 ? domain : defaultEmbedDomain;
38
38
  const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
39
39
  // Generate the url for the embed login route
40
40
  const url = new URL(embedLoginRoute, `https://${organizationName.toLocaleLowerCase()}.${domain}${port ? `:${port}` : ""}`);
@@ -1 +1 @@
1
- export declare const random32ByteString: (size?: number | undefined) => string;
1
+ export declare const random32ByteString: () => Promise<string>;
@@ -1,8 +1,11 @@
1
- import { customAlphabet } from "nanoid";
1
+ const nanoid = import("nanoid");
2
2
  const humanReadableByteSpace = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
3
3
  // Generates a random 32 byte, human readable string.
4
4
  // Based on math at https://zelark.github.io/nano-id-cc/
5
5
  // at 1000 Ids/s it would take more than 1 quadrillion years or
6
6
  // 8,730,800,738,924,245T IDs, in order to have a 1% probability
7
7
  // of at least one collision.
8
- export const random32ByteString = customAlphabet(humanReadableByteSpace, 32);
8
+ export const random32ByteString = async () => {
9
+ const { customAlphabet } = await nanoid;
10
+ return customAlphabet(humanReadableByteSpace, 32)();
11
+ };
package/package.json CHANGED
@@ -1,10 +1,8 @@
1
1
  {
2
- "version": "0.2.3",
2
+ "version": "0.3.0-pre.2",
3
3
  "license": "MIT",
4
4
  "name": "@omni-co/embed",
5
5
  "author": "Nate Agrin <nate@exploreomni.com>",
6
- "main": "lib/cjs/index.js",
7
- "module": "lib/esm/index.js",
8
6
  "files": [
9
7
  "lib/**/*"
10
8
  ],
@@ -22,5 +20,20 @@
22
20
  },
23
21
  "dependencies": {
24
22
  "nanoid": "^5.0.2"
23
+ },
24
+ "engines": {
25
+ "node": ">=16"
26
+ },
27
+ "engineStrict": true,
28
+ "types": "./lib/esm/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "import": "./lib/esm/index.js",
32
+ "require": "./lib/cjs/index.js"
33
+ },
34
+ "./lib/esm/index.js": "./lib/esm/index.js",
35
+ "./lib/cjs/index.js": "./lib/cjs/index.js",
36
+ "./lib/esm": "./lib/esm/index.js",
37
+ "./lib/cjs": "./lib/cjs/index.js"
25
38
  }
26
39
  }