@open-mercato/enterprise 0.4.6-develop-c2b70de148 → 0.4.6-develop-38209f5fc2

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.
@@ -39,12 +39,16 @@ function SsoLoginWidget({ context }) {
39
39
  }, [context.searchParams, context.setError, translate]);
40
40
  const checkHrd = useCallback(async (email) => {
41
41
  if (!email || !email.includes("@")) {
42
+ context.setAuthOverridePending?.(false);
42
43
  context.setAuthOverride(null);
43
44
  setSsoActive(false);
44
45
  lastCheckedEmail.current = "";
45
46
  return;
46
47
  }
47
- if (email === lastCheckedEmail.current) return;
48
+ if (email === lastCheckedEmail.current) {
49
+ context.setAuthOverridePending?.(false);
50
+ return;
51
+ }
48
52
  lastCheckedEmail.current = email;
49
53
  try {
50
54
  const body = { email };
@@ -76,6 +80,8 @@ function SsoLoginWidget({ context }) {
76
80
  } catch {
77
81
  setSsoActive(false);
78
82
  context.setAuthOverride(null);
83
+ } finally {
84
+ context.setAuthOverridePending?.(false);
79
85
  }
80
86
  }, [context, translate]);
81
87
  useEffect(() => {
@@ -83,13 +89,15 @@ function SsoLoginWidget({ context }) {
83
89
  clearTimeout(debounceTimer.current);
84
90
  }
85
91
  if (!context.email) {
92
+ context.setAuthOverridePending?.(false);
86
93
  setSsoActive(false);
87
94
  context.setAuthOverride(null);
88
95
  lastCheckedEmail.current = "";
89
96
  return;
90
97
  }
91
98
  debounceTimer.current = setTimeout(() => {
92
- checkHrd(context.email);
99
+ context.setAuthOverridePending?.(true);
100
+ void checkHrd(context.email);
93
101
  }, HRD_DEBOUNCE_MS);
94
102
  return () => {
95
103
  if (debounceTimer.current) {
@@ -97,6 +105,9 @@ function SsoLoginWidget({ context }) {
97
105
  }
98
106
  };
99
107
  }, [context.email, checkHrd]);
108
+ useEffect(() => () => {
109
+ context.setAuthOverridePending?.(false);
110
+ }, [context]);
100
111
  if (!ssoActive) return null;
101
112
  return /* @__PURE__ */ jsx("div", { className: "rounded-md border border-blue-200 bg-blue-50 px-3 py-2 text-center text-xs text-blue-800", children: translate("sso.login.ssoEnabled", "SSO is enabled for this account") });
102
113
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/modules/sso/widgets/injection/login-sso/widget.client.tsx"],
4
- "sourcesContent": ["\"use client\"\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport type { InjectionWidgetComponentProps } from '@open-mercato/shared/modules/widgets/injection'\nimport type { LoginFormWidgetContext } from '@open-mercato/core/modules/auth/frontend/login-injection'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { translateWithFallback } from '@open-mercato/shared/lib/i18n/translate'\n\nconst SSO_ERROR_CODES = [\n 'sso_failed',\n 'sso_missing_config',\n 'sso_email_not_verified',\n 'sso_state_missing',\n 'sso_idp_error',\n 'sso_missing_params',\n] as const\n\nconst HRD_DEBOUNCE_MS = 300\n\ntype HrdResponse = {\n hasSso: boolean\n configId?: string\n protocol?: string\n}\n\nexport default function SsoLoginWidget({ context }: InjectionWidgetComponentProps<LoginFormWidgetContext>) {\n const t = useT()\n const translate = useCallback(\n (key: string, fallback: string) => translateWithFallback(t, key, fallback),\n [t],\n )\n const [ssoActive, setSsoActive] = useState(false)\n const lastCheckedEmail = useRef('')\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null)\n\n useEffect(() => {\n const errorParam = context.searchParams.get('error')\n if (!errorParam) return\n\n const errorMessages: Record<string, string> = {\n sso_failed: translate('sso.login.errors.failed', 'SSO login failed. Please try again.'),\n sso_missing_config: translate('sso.login.errors.missingConfig', 'SSO is not configured for this account.'),\n sso_email_not_verified: translate('sso.login.errors.emailNotVerified', 'Your email address is not verified by the identity provider. Please verify your email and try again.'),\n sso_state_missing: translate('sso.login.errors.stateMissing', 'SSO session expired. Please try again.'),\n sso_idp_error: translate('sso.login.errors.idpError', 'The identity provider returned an error. Please try again or contact your administrator.'),\n sso_missing_params: translate('sso.login.errors.missingParams', 'SSO callback was incomplete. Please try again.'),\n }\n\n if (SSO_ERROR_CODES.includes(errorParam as typeof SSO_ERROR_CODES[number])) {\n context.setError(errorMessages[errorParam] ?? errorMessages.sso_failed)\n }\n }, [context.searchParams, context.setError, translate])\n\n const checkHrd = useCallback(async (email: string) => {\n if (!email || !email.includes('@')) {\n context.setAuthOverride(null)\n setSsoActive(false)\n lastCheckedEmail.current = ''\n return\n }\n\n if (email === lastCheckedEmail.current) return\n lastCheckedEmail.current = email\n\n try {\n const body: Record<string, string> = { email }\n if (context.tenantId) {\n body.tenantId = context.tenantId\n }\n\n const res = await apiCall<HrdResponse>(\n '/api/sso/hrd',\n { method: 'POST', body: JSON.stringify(body), headers: { 'Content-Type': 'application/json' } },\n )\n\n if (res.result?.hasSso && res.result.configId) {\n const configId = res.result.configId\n setSsoActive(true)\n context.setAuthOverride({\n providerId: 'sso',\n providerLabel: translate('sso.login.continueWithSso', 'Continue with SSO'),\n onSubmit: () => {\n const returnUrl = context.searchParams.get('returnUrl') || '/backend'\n window.location.href = `/api/sso/initiate?configId=${encodeURIComponent(configId)}&returnUrl=${encodeURIComponent(returnUrl)}`\n },\n hidePassword: true,\n hideRememberMe: true,\n hideForgotPassword: true,\n })\n } else {\n setSsoActive(false)\n context.setAuthOverride(null)\n }\n } catch {\n setSsoActive(false)\n context.setAuthOverride(null)\n }\n }, [context, translate])\n\n useEffect(() => {\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current)\n }\n\n if (!context.email) {\n setSsoActive(false)\n context.setAuthOverride(null)\n lastCheckedEmail.current = ''\n return\n }\n\n debounceTimer.current = setTimeout(() => {\n checkHrd(context.email)\n }, HRD_DEBOUNCE_MS)\n\n return () => {\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current)\n }\n }\n }, [context.email, checkHrd])\n\n if (!ssoActive) return null\n\n return (\n <div className=\"rounded-md border border-blue-200 bg-blue-50 px-3 py-2 text-center text-xs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M;AACvC,eAAS,QAAQ,KAAK;AAAA,IACxB,GAAG,eAAe;AAElB,WAAO,MAAM;AACX,UAAI,cAAc,SAAS;AACzB,qBAAa,cAAc,OAAO;AAAA,MACpC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,OAAO,QAAQ,CAAC;AAE5B,MAAI,CAAC,UAAW,QAAO;AAEvB,SACE,oBAAC,SAAI,WAAU,4FACZ,oBAAU,wBAAwB,iCAAiC,GACtE;AAEJ;",
4
+ "sourcesContent": ["\"use client\"\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport type { InjectionWidgetComponentProps } from '@open-mercato/shared/modules/widgets/injection'\nimport type { LoginFormWidgetContext } from '@open-mercato/core/modules/auth/frontend/login-injection'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { translateWithFallback } from '@open-mercato/shared/lib/i18n/translate'\n\nconst SSO_ERROR_CODES = [\n 'sso_failed',\n 'sso_missing_config',\n 'sso_email_not_verified',\n 'sso_state_missing',\n 'sso_idp_error',\n 'sso_missing_params',\n] as const\n\nconst HRD_DEBOUNCE_MS = 300\n\ntype HrdResponse = {\n hasSso: boolean\n configId?: string\n protocol?: string\n}\n\nexport default function SsoLoginWidget({ context }: InjectionWidgetComponentProps<LoginFormWidgetContext>) {\n const t = useT()\n const translate = useCallback(\n (key: string, fallback: string) => translateWithFallback(t, key, fallback),\n [t],\n )\n const [ssoActive, setSsoActive] = useState(false)\n const lastCheckedEmail = useRef('')\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null)\n\n useEffect(() => {\n const errorParam = context.searchParams.get('error')\n if (!errorParam) return\n\n const errorMessages: Record<string, string> = {\n sso_failed: translate('sso.login.errors.failed', 'SSO login failed. Please try again.'),\n sso_missing_config: translate('sso.login.errors.missingConfig', 'SSO is not configured for this account.'),\n sso_email_not_verified: translate('sso.login.errors.emailNotVerified', 'Your email address is not verified by the identity provider. Please verify your email and try again.'),\n sso_state_missing: translate('sso.login.errors.stateMissing', 'SSO session expired. Please try again.'),\n sso_idp_error: translate('sso.login.errors.idpError', 'The identity provider returned an error. Please try again or contact your administrator.'),\n sso_missing_params: translate('sso.login.errors.missingParams', 'SSO callback was incomplete. Please try again.'),\n }\n\n if (SSO_ERROR_CODES.includes(errorParam as typeof SSO_ERROR_CODES[number])) {\n context.setError(errorMessages[errorParam] ?? errorMessages.sso_failed)\n }\n }, [context.searchParams, context.setError, translate])\n\n const checkHrd = useCallback(async (email: string) => {\n if (!email || !email.includes('@')) {\n context.setAuthOverridePending?.(false)\n context.setAuthOverride(null)\n setSsoActive(false)\n lastCheckedEmail.current = ''\n return\n }\n\n if (email === lastCheckedEmail.current) {\n context.setAuthOverridePending?.(false)\n return\n }\n lastCheckedEmail.current = email\n\n try {\n const body: Record<string, string> = { email }\n if (context.tenantId) {\n body.tenantId = context.tenantId\n }\n\n const res = await apiCall<HrdResponse>(\n '/api/sso/hrd',\n { method: 'POST', body: JSON.stringify(body), headers: { 'Content-Type': 'application/json' } },\n )\n\n if (res.result?.hasSso && res.result.configId) {\n const configId = res.result.configId\n setSsoActive(true)\n context.setAuthOverride({\n providerId: 'sso',\n providerLabel: translate('sso.login.continueWithSso', 'Continue with SSO'),\n onSubmit: () => {\n const returnUrl = context.searchParams.get('returnUrl') || '/backend'\n window.location.href = `/api/sso/initiate?configId=${encodeURIComponent(configId)}&returnUrl=${encodeURIComponent(returnUrl)}`\n },\n hidePassword: true,\n hideRememberMe: true,\n hideForgotPassword: true,\n })\n } else {\n setSsoActive(false)\n context.setAuthOverride(null)\n }\n } catch {\n setSsoActive(false)\n context.setAuthOverride(null)\n } finally {\n context.setAuthOverridePending?.(false)\n }\n }, [context, translate])\n\n useEffect(() => {\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current)\n }\n\n if (!context.email) {\n context.setAuthOverridePending?.(false)\n setSsoActive(false)\n context.setAuthOverride(null)\n lastCheckedEmail.current = ''\n return\n }\n\n debounceTimer.current = setTimeout(() => {\n context.setAuthOverridePending?.(true)\n void checkHrd(context.email)\n }, HRD_DEBOUNCE_MS)\n\n return () => {\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current)\n }\n }\n }, [context.email, checkHrd])\n\n useEffect(() => () => {\n context.setAuthOverridePending?.(false)\n }, [context])\n\n if (!ssoActive) return null\n\n return (\n <div className=\"rounded-md border border-blue-200 bg-blue-50 px-3 py-2 text-center text-xs text-blue-800\">\n {translate('sso.login.ssoEnabled', 'SSO is enabled for this account')}\n </div>\n )\n}\n"],
5
+ "mappings": ";AAyII;AAxIJ,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAGzD,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,6BAA6B;AAEtC,MAAM,kBAAkB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,kBAAkB;AAQT,SAAR,eAAgC,EAAE,QAAQ,GAA0D;AACzG,QAAM,IAAI,KAAK;AACf,QAAM,YAAY;AAAA,IAChB,CAAC,KAAa,aAAqB,sBAAsB,GAAG,KAAK,QAAQ;AAAA,IACzE,CAAC,CAAC;AAAA,EACJ;AACA,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,mBAAmB,OAAO,EAAE;AAClC,QAAM,gBAAgB,OAA6C,IAAI;AAEvE,YAAU,MAAM;AACd,UAAM,aAAa,QAAQ,aAAa,IAAI,OAAO;AACnD,QAAI,CAAC,WAAY;AAEjB,UAAM,gBAAwC;AAAA,MAC5C,YAAY,UAAU,2BAA2B,qCAAqC;AAAA,MACtF,oBAAoB,UAAU,kCAAkC,yCAAyC;AAAA,MACzG,wBAAwB,UAAU,qCAAqC,sGAAsG;AAAA,MAC7K,mBAAmB,UAAU,iCAAiC,wCAAwC;AAAA,MACtG,eAAe,UAAU,6BAA6B,0FAA0F;AAAA,MAChJ,oBAAoB,UAAU,kCAAkC,gDAAg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AC9B;AAAA,IACF,QAAQ;AACN,mBAAa,KAAK;AAClB,cAAQ,gBAAgB,IAAI;AAAA,IAC9B,UAAE;AACA,cAAQ,yBAAyB,KAAK;AAAA,IACxC;AAAA,EACF,GAAG,CAAC,SAAS,SAAS,CAAC;AAEvB,YAAU,MAAM;AACd,QAAI,cAAc,SAAS;AACzB,mBAAa,cAAc,OAAO;AAAA,IACpC;AAEA,QAAI,CAAC,QAAQ,OAAO;AAClB,cAAQ,yBAAyB,KAAK;AACtC,mBAAa,KAAK;AAClB,cAAQ,gBAAgB,IAAI;AAC5B,uBAAiB,UAAU;AAC3B;AAAA,IACF;AAEA,kBAAc,UAAU,WAAW,MAAM;AACvC,cAAQ,yBAAyB,IAAI;AACrC,WAAK,SAAS,QAAQ,KAAK;AAAA,IAC7B,GAAG,eAAe;AAElB,WAAO,MAAM;AACX,UAAI,cAAc,SAAS;AACzB,qBAAa,cAAc,OAAO;AAAA,MACpC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,OAAO,QAAQ,CAAC;AAE5B,YAAU,MAAM,MAAM;AACpB,YAAQ,yBAAyB,KAAK;AAAA,EACxC,GAAG,CAAC,OAAO,CAAC;AAEZ,MAAI,CAAC,UAAW,QAAO;AAEvB,SACE,oBAAC,SAAI,WAAU,4FACZ,oBAAU,wBAAwB,iCAAiC,GACtE;AAEJ;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/enterprise",
3
- "version": "0.4.6-develop-c2b70de148",
3
+ "version": "0.4.6-develop-38209f5fc2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -64,9 +64,9 @@
64
64
  }
65
65
  },
66
66
  "dependencies": {
67
- "@open-mercato/core": "0.4.6-develop-c2b70de148",
68
- "@open-mercato/shared": "0.4.6-develop-c2b70de148",
69
- "@open-mercato/ui": "0.4.6-develop-c2b70de148",
67
+ "@open-mercato/core": "0.4.6-develop-38209f5fc2",
68
+ "@open-mercato/shared": "0.4.6-develop-38209f5fc2",
69
+ "@open-mercato/ui": "0.4.6-develop-38209f5fc2",
70
70
  "openid-client": "^6.3.3"
71
71
  },
72
72
  "devDependencies": {
@@ -53,13 +53,17 @@ export default function SsoLoginWidget({ context }: InjectionWidgetComponentProp
53
53
 
54
54
  const checkHrd = useCallback(async (email: string) => {
55
55
  if (!email || !email.includes('@')) {
56
+ context.setAuthOverridePending?.(false)
56
57
  context.setAuthOverride(null)
57
58
  setSsoActive(false)
58
59
  lastCheckedEmail.current = ''
59
60
  return
60
61
  }
61
62
 
62
- if (email === lastCheckedEmail.current) return
63
+ if (email === lastCheckedEmail.current) {
64
+ context.setAuthOverridePending?.(false)
65
+ return
66
+ }
63
67
  lastCheckedEmail.current = email
64
68
 
65
69
  try {
@@ -94,6 +98,8 @@ export default function SsoLoginWidget({ context }: InjectionWidgetComponentProp
94
98
  } catch {
95
99
  setSsoActive(false)
96
100
  context.setAuthOverride(null)
101
+ } finally {
102
+ context.setAuthOverridePending?.(false)
97
103
  }
98
104
  }, [context, translate])
99
105
 
@@ -103,6 +109,7 @@ export default function SsoLoginWidget({ context }: InjectionWidgetComponentProp
103
109
  }
104
110
 
105
111
  if (!context.email) {
112
+ context.setAuthOverridePending?.(false)
106
113
  setSsoActive(false)
107
114
  context.setAuthOverride(null)
108
115
  lastCheckedEmail.current = ''
@@ -110,7 +117,8 @@ export default function SsoLoginWidget({ context }: InjectionWidgetComponentProp
110
117
  }
111
118
 
112
119
  debounceTimer.current = setTimeout(() => {
113
- checkHrd(context.email)
120
+ context.setAuthOverridePending?.(true)
121
+ void checkHrd(context.email)
114
122
  }, HRD_DEBOUNCE_MS)
115
123
 
116
124
  return () => {
@@ -120,6 +128,10 @@ export default function SsoLoginWidget({ context }: InjectionWidgetComponentProp
120
128
  }
121
129
  }, [context.email, checkHrd])
122
130
 
131
+ useEffect(() => () => {
132
+ context.setAuthOverridePending?.(false)
133
+ }, [context])
134
+
123
135
  if (!ssoActive) return null
124
136
 
125
137
  return (