@enterprisestandard/react 0.0.3-beta.20251013.2 → 0.0.3-beta.20251020.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/dist/index.d.ts CHANGED
@@ -12,7 +12,6 @@ export type EnterpriseStandard = {
12
12
  type ESConfig = {
13
13
  ioniteUrl?: string;
14
14
  defaultInstance?: boolean;
15
- ssoUserUrl?: string;
16
15
  };
17
16
  export declare function enterpriseStandard(appId: string, appKey?: string, initConfig?: ESConfig): Promise<EnterpriseStandard>;
18
17
  export type * from './enterprise-user';
package/dist/index.js CHANGED
@@ -34,10 +34,10 @@ var jwksCache = new Map;
34
34
  function sso(config) {
35
35
  const configWithDefaults = {
36
36
  ...config,
37
- secure: config.secure !== undefined ? config.secure : true,
38
- sameSite: config.sameSite !== undefined ? config.sameSite : "Strict",
39
- cookiePrefix: config.cookiePrefix ?? `es.sso.${config.client_id}`,
40
- cookiePath: config.cookiePath ?? "/"
37
+ cookies_secure: config.cookies_secure !== undefined ? config.cookies_secure : true,
38
+ cookies_same_site: config.cookies_same_site !== undefined ? config.cookies_same_site : "Strict",
39
+ cookies_prefix: config.cookies_prefix ?? `es.sso.${config.client_id}`,
40
+ cookies_path: config.cookies_path ?? "/"
41
41
  };
42
42
  async function getUser(request) {
43
43
  if (!configWithDefaults) {
@@ -357,7 +357,7 @@ function sso(config) {
357
357
  return tokens.access_token;
358
358
  }
359
359
  function createCookie(name, value, expires) {
360
- name = `${configWithDefaults.cookiePrefix}.${name}`;
360
+ name = `${configWithDefaults.cookies_prefix}.${name}`;
361
361
  if (typeof value !== "string") {
362
362
  value = btoa(JSON.stringify(value));
363
363
  }
@@ -372,16 +372,16 @@ function sso(config) {
372
372
  if (value.length > 4000) {
373
373
  throw new Error(`Error setting cookie: ${name}. Cookie length is: ${value.length}`);
374
374
  }
375
- return `${name}=${value}; ${exp}; Path=${configWithDefaults.cookiePath}; HttpOnly;${configWithDefaults.secure ? " Secure;" : ""} SameSite=${configWithDefaults.sameSite};`;
375
+ return `${name}=${value}; ${exp}; Path=${configWithDefaults.cookies_path}; HttpOnly;${configWithDefaults.cookies_secure ? " Secure;" : ""} SameSite=${configWithDefaults.cookies_same_site};`;
376
376
  }
377
377
  function clearCookie(name) {
378
- return `${configWithDefaults.cookiePrefix}.${name}=; Max-Age=0; Path=${configWithDefaults.cookiePath}; HttpOnly;${configWithDefaults.secure ? " Secure;" : ""} SameSite=${configWithDefaults.sameSite};`;
378
+ return `${configWithDefaults.cookies_prefix}.${name}=; Max-Age=0; Path=${configWithDefaults.cookies_path}; HttpOnly;${configWithDefaults.cookies_secure ? " Secure;" : ""} SameSite=${configWithDefaults.cookies_same_site};`;
379
379
  }
380
380
  function getCookie(name, req, parse = false) {
381
381
  const header = req.headers.get("cookie");
382
382
  if (!header)
383
383
  return null;
384
- const cookie = header.split(";").find((row) => row.trim().startsWith(`${configWithDefaults.cookiePrefix}.${name}=`));
384
+ const cookie = header.split(";").find((row) => row.trim().startsWith(`${configWithDefaults.cookies_prefix}.${name}=`));
385
385
  if (!cookie)
386
386
  return null;
387
387
  const val = cookie.split("=")[1].trim();
@@ -452,8 +452,8 @@ function sso(config) {
452
452
  }
453
453
 
454
454
  // src/vault.ts
455
- function vault(url, token) {
456
- async function getFullSecret(path) {
455
+ function vault(url) {
456
+ async function getFullSecret(path, token) {
457
457
  const resp = await fetch(`${url}/${path}`, { headers: { "X-Vault-Token": token } });
458
458
  if (resp.status !== 200) {
459
459
  throw new Error(`Vault returned invalid status, ${resp.status}: '${resp.statusText}' from URL: ${url}`);
@@ -468,8 +468,8 @@ function vault(url, token) {
468
468
  return {
469
469
  url,
470
470
  getFullSecret,
471
- getSecret: async (path) => {
472
- return (await getFullSecret(path)).data;
471
+ getSecret: async (path, token) => {
472
+ return (await getFullSecret(path, token)).data;
473
473
  }
474
474
  };
475
475
  }
@@ -620,38 +620,38 @@ async function handler(request, config) {
620
620
  return sso2.handler(request, config);
621
621
  }
622
622
  // src/ui/sign-in-loading.tsx
623
- import { jsx, Fragment } from "react/jsx-runtime";
623
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
624
624
  function SignInLoading({ complete = false, children }) {
625
625
  const { isLoading } = useUser();
626
626
  if (isLoading && !complete)
627
- return /* @__PURE__ */ jsx(Fragment, {
627
+ return /* @__PURE__ */ jsxDEV(Fragment, {
628
628
  children
629
- });
629
+ }, undefined, false, undefined, this);
630
630
  return null;
631
631
  }
632
632
  // src/ui/signed-in.tsx
633
- import { jsx as jsx2, Fragment as Fragment2 } from "react/jsx-runtime";
633
+ import { jsxDEV as jsxDEV2, Fragment as Fragment2 } from "react/jsx-dev-runtime";
634
634
  function SignedIn({ children }) {
635
635
  const { user } = useUser();
636
636
  if (user)
637
- return /* @__PURE__ */ jsx2(Fragment2, {
637
+ return /* @__PURE__ */ jsxDEV2(Fragment2, {
638
638
  children
639
- });
639
+ }, undefined, false, undefined, this);
640
640
  return null;
641
641
  }
642
642
  // src/ui/signed-out.tsx
643
- import { jsx as jsx3, Fragment as Fragment3 } from "react/jsx-runtime";
643
+ import { jsxDEV as jsxDEV3, Fragment as Fragment3 } from "react/jsx-dev-runtime";
644
644
  function SignedOut({ children }) {
645
645
  const { user, isLoading } = useUser();
646
646
  if (user || isLoading)
647
647
  return null;
648
- return /* @__PURE__ */ jsx3(Fragment3, {
648
+ return /* @__PURE__ */ jsxDEV3(Fragment3, {
649
649
  children
650
- });
650
+ }, undefined, false, undefined, this);
651
651
  }
652
652
  // src/ui/sso-provider.tsx
653
653
  import { createContext, useCallback, useContext, useEffect, useState } from "react";
654
- import { jsx as jsx4 } from "react/jsx-runtime";
654
+ import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
655
655
  var CTX = createContext(undefined);
656
656
  var generateStorageKey = (tenantId) => {
657
657
  return `es-sso-user-${tenantId.replace(/[^a-zA-Z0-9]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "")}`;
@@ -786,10 +786,10 @@ function SSOProvider({
786
786
  tokenUrl,
787
787
  refreshUrl
788
788
  };
789
- return /* @__PURE__ */ jsx4(CTX.Provider, {
789
+ return /* @__PURE__ */ jsxDEV4(CTX.Provider, {
790
790
  value: contextValue,
791
791
  children
792
- });
792
+ }, undefined, false, undefined, this);
793
793
  }
794
794
  function useUser() {
795
795
  const context = useContext(CTX);
@@ -880,29 +880,33 @@ function useToken() {
880
880
  async function enterpriseStandard(appId, appKey, initConfig) {
881
881
  let vaultUrl;
882
882
  let vaultToken;
883
- let paths;
883
+ let secrets;
884
884
  const ioniteUrl = initConfig?.ioniteUrl ?? "https://ionite.com";
885
885
  if (appId === "IONITE_PUBLIC_DEMO") {
886
886
  vaultUrl = "https://vault-ionite.ionite.dev/v1/secret/data";
887
- vaultToken = "hvs.NuiBSLuFk5Ju4JDOUwTOlSlP";
888
- paths = { sso: "ionite/IONITE_PUBLIC_DEMO" };
887
+ secrets = {
888
+ sso: {
889
+ path: "public/IONITE_PUBLIC_DEMO_SSO",
890
+ token: "hvs.CAESIMaXjGqOPGikqGPWxSxjajLzhgQEMwBdf4rTQYFaCkRSGh4KHGh2cy44MzEyeEkwZE5TRnY5MTBJWUdudGFPWk8"
891
+ }
892
+ };
889
893
  } else if (appKey) {
890
894
  if (!vaultUrl || !vaultToken) {
891
895
  throw new Error("TODO something is wrong with the ionite config, handle this error");
892
896
  }
893
- paths = {};
897
+ secrets = {};
894
898
  } else {
895
899
  throw new Error("TODO tell them how to connect to ionite");
896
900
  }
897
901
  const defaultInstance2 = getDefaultInstance();
898
- const vaultClient = await vault(vaultUrl, vaultToken);
902
+ const vaultClient = await vault(vaultUrl);
899
903
  const result = {
900
904
  appId,
901
905
  ioniteUrl,
902
906
  defaultInstance: initConfig?.defaultInstance || initConfig?.defaultInstance !== false && !defaultInstance2,
903
907
  vault: vaultClient,
904
- sso: paths.sso ? sso(await vaultClient.getSecret(paths.sso)) : undefined,
905
- iam: paths.iam ? await iam(await vaultClient.getSecret(paths.iam)) : undefined
908
+ sso: secrets.sso ? sso(await vaultClient.getSecret(secrets.sso.path, secrets.sso.token)) : undefined,
909
+ iam: secrets.iam ? await iam(await vaultClient.getSecret(secrets.iam.path, secrets.iam.token)) : undefined
906
910
  };
907
911
  if (result.defaultInstance) {
908
912
  if (defaultInstance2) {
package/dist/sso.d.ts CHANGED
@@ -10,10 +10,10 @@ export type SSOConfig = {
10
10
  post_logout_redirect_uri?: string;
11
11
  silent_redirect_uri?: string;
12
12
  jwks_uri?: string;
13
- cookiePrefix?: string;
14
- cookiePath?: string;
15
- sameSite?: 'Strict' | 'Lax';
16
- secure?: boolean;
13
+ cookies_prefix?: string;
14
+ cookies_path?: string;
15
+ cookies_secure?: boolean;
16
+ cookies_same_site?: 'Strict' | 'Lax';
17
17
  };
18
18
  export type ESConfig = {
19
19
  es?: EnterpriseStandard;
package/dist/vault.d.ts CHANGED
@@ -10,8 +10,8 @@ type MetaData = {
10
10
  };
11
11
  export type Vault = {
12
12
  url: string;
13
- getFullSecret: <T>(path: string) => Promise<Secret<T>>;
14
- getSecret: <T>(path: string) => Promise<T>;
13
+ getFullSecret: <T>(path: string, token: string) => Promise<Secret<T>>;
14
+ getSecret: <T>(path: string, token: string) => Promise<T>;
15
15
  };
16
- export declare function vault(url: string, token: string): Vault;
16
+ export declare function vault(url: string): Vault;
17
17
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enterprisestandard/react",
3
- "version": "0.0.3-beta.20251013.2",
3
+ "version": "0.0.3-beta.20251020.1",
4
4
  "description": "Enterprise Standard React Components",
5
5
  "private": false,
6
6
  "main": "dist/index.js",