wcz-layout 9.7.0 → 10.0.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.
Files changed (93) hide show
  1. package/dist/AggregatedCell-BtKC5-m6.mjs +497 -0
  2. package/dist/AggregatedCell-BtKC5-m6.mjs.map +1 -0
  3. package/dist/Approval-C-hF4jbT.mjs.map +1 -1
  4. package/dist/DialogsContext-DLqA8RJ_.mjs.map +1 -1
  5. package/dist/Email-BzQQkbe9.mjs.map +1 -1
  6. package/dist/FileMeta-DDqUju1Y.mjs.map +1 -1
  7. package/dist/LayoutTable-4DLs-NI-.d.mts +752 -0
  8. package/dist/{QueryClientParam-Cbb0MIKg.d.mts → QueryClientParam-JcH0mJWl.d.mts} +2 -2
  9. package/dist/RouterListItemButton-ULMlaQh6.mjs.map +1 -1
  10. package/dist/{User-1gKoYJvW.d.mts → User-D4__w1I1.d.mts} +4 -2
  11. package/dist/approval-DFExxyAJ.mjs +84 -0
  12. package/dist/approval-DFExxyAJ.mjs.map +1 -0
  13. package/dist/auth.d.mts +21 -11
  14. package/dist/auth.mjs +43 -26
  15. package/dist/auth.mjs.map +1 -1
  16. package/dist/components.d.mts +22 -30
  17. package/dist/components.mjs +786 -139
  18. package/dist/components.mjs.map +1 -1
  19. package/dist/createApi-CLYWCzR2.mjs +27 -0
  20. package/dist/createApi-CLYWCzR2.mjs.map +1 -0
  21. package/dist/data/client.d.mts +702 -1152
  22. package/dist/data/client.mjs +4 -3
  23. package/dist/data/client.mjs.map +1 -1
  24. package/dist/data/server.d.mts +3 -3
  25. package/dist/data/server.mjs +4 -2
  26. package/dist/data/server.mjs.map +1 -1
  27. package/dist/{file-BWcNzq55.mjs → file-CZwQfvTU.mjs} +5 -24
  28. package/dist/file-CZwQfvTU.mjs.map +1 -0
  29. package/dist/{file-DimNsRly.mjs → file-aSQto2rw.mjs} +6 -7
  30. package/dist/file-aSQto2rw.mjs.map +1 -0
  31. package/dist/hooks.d.mts +7 -46
  32. package/dist/hooks.mjs +2578 -239
  33. package/dist/hooks.mjs.map +1 -1
  34. package/dist/index.d.mts +28 -9
  35. package/dist/index.mjs +1248 -500
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/middleware.d.mts +20 -19
  38. package/dist/middleware.mjs +47 -2
  39. package/dist/middleware.mjs.map +1 -1
  40. package/dist/models.d.mts +17 -10
  41. package/dist/models.mjs.map +1 -1
  42. package/dist/{peoplesoft-CskGsqd6.d.mts → peoplesoft-BY_75WTS.d.mts} +2 -2
  43. package/dist/{peoplesoft-DTPGpN2h.mjs → peoplesoft-CQnc01Hc.mjs} +24 -81
  44. package/dist/peoplesoft-CQnc01Hc.mjs.map +1 -0
  45. package/dist/providers-Dbl95AxR.mjs +74 -0
  46. package/dist/providers-Dbl95AxR.mjs.map +1 -0
  47. package/dist/tokens-D8CVIFTb.mjs +143 -0
  48. package/dist/tokens-D8CVIFTb.mjs.map +1 -0
  49. package/dist/{utils-5x4uNxsX.d.mts → utils-Bhi0KiBx.d.mts} +18 -6
  50. package/dist/{utils-DjdexspV.mjs → utils-KaM5VMTJ.mjs} +64 -42
  51. package/dist/utils-KaM5VMTJ.mjs.map +1 -0
  52. package/dist/utils.d.mts +2 -2
  53. package/dist/utils.mjs +2 -2
  54. package/dist/vite.d.mts +1 -2
  55. package/dist/vite.mjs +3 -3
  56. package/dist/vite.mjs.map +1 -1
  57. package/package.json +23 -23
  58. package/skills/client-db/SKILL.md +104 -96
  59. package/skills/db-schema/SKILL.md +46 -33
  60. package/skills/dialogs/SKILL.md +21 -27
  61. package/skills/forms/SKILL.md +60 -39
  62. package/skills/general/SKILL.md +56 -25
  63. package/skills/general/references/exports.md +106 -0
  64. package/skills/migrations/SKILL.md +53 -2
  65. package/skills/migrations/versions/migrate-v9-to-v10.md +581 -0
  66. package/skills/routing/SKILL.md +50 -60
  67. package/skills/server-functions/SKILL.md +36 -56
  68. package/skills/services/SKILL.md +7 -4
  69. package/skills/services/docs/approval.md +2 -2
  70. package/skills/services/docs/peoplesoft.md +1 -1
  71. package/skills/start/SKILL.md +9 -5
  72. package/skills/start/steps/05-database-setup.md +52 -52
  73. package/skills/start/steps/06-entra-setup.md +1 -1
  74. package/skills/start/steps/07-vault-setup.md +5 -12
  75. package/skills/table/SKILL.md +275 -0
  76. package/skills/unslop/SKILL.md +80 -0
  77. package/dist/NotificationContext-CgwUOeW0.mjs +0 -7
  78. package/dist/NotificationContext-CgwUOeW0.mjs.map +0 -1
  79. package/dist/authMiddleware-DPly0b_T.mjs +0 -48
  80. package/dist/authMiddleware-DPly0b_T.mjs.map +0 -1
  81. package/dist/entra-CJSyeQsx.mjs +0 -109
  82. package/dist/entra-CJSyeQsx.mjs.map +0 -1
  83. package/dist/file-BWcNzq55.mjs.map +0 -1
  84. package/dist/file-DimNsRly.mjs.map +0 -1
  85. package/dist/msalServer-DLwA7_ta.mjs +0 -30
  86. package/dist/msalServer-DLwA7_ta.mjs.map +0 -1
  87. package/dist/peoplesoft-DTPGpN2h.mjs.map +0 -1
  88. package/dist/useDialogs-BUzVrTSP.mjs +0 -248
  89. package/dist/useDialogs-BUzVrTSP.mjs.map +0 -1
  90. package/dist/user-Dzv0N9fj.d.mts +0 -16
  91. package/dist/utils-DjdexspV.mjs.map +0 -1
  92. package/skills/data-grid/SKILL.md +0 -142
  93. package/skills/migrations/versions/migrate-v9-to-v10.tsx +0 -9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens-D8CVIFTb.mjs","names":["createHash","randomBytes","randomUUID","Provider","SessionExpiredError","Error","TokenResponse","access_token","refresh_token","id_token","expires_in","base64url","bytes","Buffer","toString","createPkce","verifier","challenge","update","digest","createState","isSessionDead","error","suberror","requestToken","provider","body","Record","Promise","credentials","from","clientId","clientSecret","response","fetch","tokenEndpoint","method","headers","authorization","URLSearchParams","client_id","payload","json","ok","message","error_description","status","id","buildAuthUrl","opts","redirectUri","state","url","URL","authorizeEndpoint","search","response_type","redirect_uri","scope","loginScopes","join","code_challenge","code_challenge_method","exchangeCode","code","codeVerifier","grant_type","code_verifier","refreshTokens","refreshToken","clientCredentials","createServerOnlyFn","scopes","definedScopes","Scope","ProviderId","SessionExpiredError","clientCredentials","refreshTokens","getProvider","getAppSession","ScopeKey","resolveScope","key","provider","entry","scope","undefined","Error","getAccessToken","scopeKey","Promise","session","providerId","refreshToken","data","result","refresh_token","update","access_token","error","clear","Response","json","message","status","appTokens","Map","token","expiresAt","getAppToken","cached","get","Date","now","defaultScope","slice","lastIndexOf","set","expires_in"],"sources":["../src/lib/auth/oidc.ts","../src/lib/auth/tokens.ts"],"sourcesContent":["import { createHash, randomBytes, randomUUID } from \"node:crypto\";\nimport type { Provider } from \"./providers\";\n\n/**\n * The whole OAuth2/OIDC surface this app needs, as plain form POSTs. Both Entra\n * and Cognito are ordinary OIDC servers, so a second provider is a config object\n * (see `providers.ts`) rather than a second integration.\n */\n\n/** The refresh token is expired/revoked — the user must sign in interactively. */\nexport class SessionExpiredError extends Error {}\n\nexport interface TokenResponse {\n access_token: string;\n refresh_token?: string;\n id_token?: string;\n expires_in: number;\n}\n\nconst base64url = (bytes: Buffer): string => bytes.toString(\"base64url\");\n\n/** PKCE verifier + S256 challenge for the authorization-code flow. */\nexport const createPkce = (): { verifier: string; challenge: string } => {\n const verifier = base64url(randomBytes(32));\n return { verifier, challenge: base64url(createHash(\"sha256\").update(verifier).digest()) };\n};\n\nexport const createState = (): string => randomUUID();\n\n/**\n * Revocation, inactivity expiry and Conditional Access sign-in frequency all\n * surface as `invalid_grant` or `interaction_required` — the session is dead and\n * only an interactive login helps. Missing consent (Entra AADSTS65001) looks the\n * same but is a configuration bug, so it is left to surface as-is.\n */\nconst isSessionDead = (error: { error?: string; suberror?: string }): boolean =>\n (error.error === \"invalid_grant\" || error.error === \"interaction_required\") &&\n error.suberror !== \"consent_required\";\n\nasync function requestToken(\n provider: Provider,\n body: Record<string, string>,\n): Promise<TokenResponse> {\n const credentials = Buffer.from(`${provider.clientId}:${provider.clientSecret}`).toString(\n \"base64\",\n );\n const response = await fetch(provider.tokenEndpoint, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/x-www-form-urlencoded\",\n // Both providers accept client_secret_basic; it keeps the secret out of the body.\n authorization: `Basic ${credentials}`,\n },\n body: new URLSearchParams({ client_id: provider.clientId, ...body }),\n });\n\n const payload = (await response.json()) as TokenResponse &\n Record<\"error\" | \"error_description\" | \"suberror\", string | undefined>;\n if (response.ok) return payload;\n\n const message = payload.error_description ?? payload.error ?? `HTTP ${response.status}`;\n if (isSessionDead(payload)) throw new SessionExpiredError(message);\n throw new Error(`[${provider.id}] ${message}`);\n}\n\n/** First leg of the auth-code flow: the URL to redirect the browser to. */\nexport function buildAuthUrl(\n provider: Provider,\n opts: { redirectUri: string; state: string; challenge: string },\n): string {\n const url = new URL(provider.authorizeEndpoint);\n url.search = new URLSearchParams({\n client_id: provider.clientId,\n response_type: \"code\",\n redirect_uri: opts.redirectUri,\n state: opts.state,\n scope: provider.loginScopes.join(\" \"),\n code_challenge: opts.challenge,\n code_challenge_method: \"S256\",\n }).toString();\n return url.toString();\n}\n\n/** Second leg: exchange the code for tokens. The refresh token is in the body. */\nexport const exchangeCode = (\n provider: Provider,\n opts: { code: string; redirectUri: string; codeVerifier: string },\n): Promise<TokenResponse> =>\n requestToken(provider, {\n grant_type: \"authorization_code\",\n code: opts.code,\n redirect_uri: opts.redirectUri,\n code_verifier: opts.codeVerifier,\n });\n\n/**\n * Delegated token for `scope`. Entra mints a token for any resource from its\n * multi-resource refresh token; Cognito can only narrow within the scopes already\n * registered on the app client, and ignores the rest.\n */\nexport const refreshTokens = (\n provider: Provider,\n opts: { refreshToken: string; scope: string },\n): Promise<TokenResponse> =>\n requestToken(provider, {\n grant_type: \"refresh_token\",\n refresh_token: opts.refreshToken,\n scope: opts.scope,\n });\n\n/** App-only token: no user context, for background jobs. */\nexport const clientCredentials = (\n provider: Provider,\n opts: { scope: string },\n): Promise<TokenResponse> =>\n requestToken(provider, { grant_type: \"client_credentials\", scope: opts.scope });\n","import { createServerOnlyFn } from \"@tanstack/react-start\";\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\nimport type { Scope } from \"~/models/Scopes\";\nimport type { ProviderId } from \"~/models/User\";\nimport { SessionExpiredError, clientCredentials, refreshTokens } from \"./oidc\";\nimport { getProvider } from \"./providers\";\nimport { getAppSession } from \"./session\";\n\nexport type ScopeKey = keyof typeof definedScopes;\n\n/**\n * A scope entry is either a bare string (Entra) or `{ entra, aws }`. Throwing on a\n * missing entry fails at the call site instead of sending a token the API rejects.\n */\nexport const resolveScope = (key: ScopeKey, provider: ProviderId): string => {\n const entry: Scope = definedScopes[key];\n const scope =\n typeof entry === \"string\" ? (provider === \"entra\" ? entry : undefined) : entry[provider];\n\n if (!scope) throw new Error(`No \"${key}\" scope is configured for the \"${provider}\" provider.`);\n return scope;\n};\n\n/**\n * Delegated access token for the signed-in user, minted from the session refresh\n * token. Providers that rotate the refresh token return a new one, which is\n * persisted back. Server-only — stripped from the client bundle.\n */\nexport const getAccessToken = createServerOnlyFn(async (scopeKey: ScopeKey): Promise<string> => {\n const session = await getAppSession();\n const { provider: providerId, refreshToken } = session.data;\n if (!providerId || !refreshToken) throw new Error(\"No active session. User not signed in.\");\n\n try {\n const result = await refreshTokens(getProvider(providerId), {\n refreshToken,\n scope: resolveScope(scopeKey, providerId),\n });\n if (result.refresh_token && result.refresh_token !== refreshToken)\n await session.update({ refreshToken: result.refresh_token });\n return result.access_token;\n } catch (error) {\n // Revoked/expired refresh token: clear the dead session and answer 401 so the\n // client can redirect to /login, instead of surfacing a 500.\n if (error instanceof SessionExpiredError) {\n await session.clear();\n throw Response.json(\n { message: \"Unauthorized: Session expired, sign in again\" },\n { status: 401 },\n );\n }\n throw error;\n }\n});\n\n// MSAL used to cache these in memory; without it, a small TTL map keeps parity.\nconst appTokens = new Map<ScopeKey, { token: string; expiresAt: number }>();\n\n/**\n * Client-credentials (app-only) token, for background jobs with no user.\n * Entra-only: the AWS population signs in interactively, so a Cognito app client\n * for M2M has no caller yet (and Cognito bills M2M per token request).\n */\nexport const getAppToken = createServerOnlyFn(async (scopeKey: ScopeKey): Promise<string> => {\n const cached = appTokens.get(scopeKey);\n if (cached && cached.expiresAt > Date.now()) return cached.token;\n\n // Entra client credentials only accept `<resource>/.default`, not user scopes.\n const scope = resolveScope(scopeKey, \"entra\");\n const defaultScope = `${scope.slice(0, scope.lastIndexOf(\"/\"))}/.default`;\n\n const result = await clientCredentials(getProvider(\"entra\"), { scope: defaultScope });\n appTokens.set(scopeKey, {\n token: result.access_token,\n expiresAt: Date.now() + (result.expires_in - 60) * 1000,\n });\n return result.access_token;\n});\n"],"mappings":";;;;;;;;;;;;AAUA,IAAaI,sBAAb,cAAyCC,MAAM,CAAA;AAS/C,MAAMM,aAAaC,UAA0BA,MAAME,SAAS,WAAW;;AAGvE,MAAaC,mBAA4D;CACvE,MAAMC,WAAWL,UAAUV,YAAY,EAAE,CAAC;CAC1C,OAAO;EAAEe;EAAUC,WAAWN,UAAUX,WAAW,QAAQ,CAAC,CAACkB,OAAOF,QAAQ,CAAC,CAACG,OAAO,CAAC;CAAE;AAC1F;AAEA,MAAaC,oBAA4BlB,WAAW;;;;;;;AAQpD,MAAMmB,iBAAiBC,WACpBA,MAAMA,UAAU,mBAAmBA,MAAMA,UAAU,2BACpDA,MAAMC,aAAa;AAErB,eAAeC,aACbC,UACAC,MACwB;CACxB,MAAMG,cAAchB,OAAOiB,KAAK,GAAGL,SAASM,SAAQ,GAAIN,SAASO,cAAc,CAAC,CAAClB,SAC/E,QACF;CACA,MAAMmB,WAAW,MAAMC,MAAMT,SAASU,eAAe;EACnDC,QAAQ;EACRC,SAAS;GACP,gBAAgB;GAEhBC,eAAe,SAAST;EAC1B;EACAH,MAAM,IAAIa,gBAAgB;GAAEC,WAAWf,SAASM;GAAU,GAAGL;EAAK,CAAC;CACrE,CAAC;CAED,MAAMe,UAAW,MAAMR,SAASS,KAAK;CAErC,IAAIT,SAASU,IAAI,OAAOF;CAEx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
2
- import { t as User } from "./User-1gKoYJvW.mjs";
1
+ import { n as User } from "./User-D4__w1I1.mjs";
2
+ import { t as QueryClientParam } from "./QueryClientParam-JcH0mJWl.mjs";
3
3
  import { permissions } from "virtual:wcz-layout";
4
4
  import { ParsedLocation } from "@tanstack/react-router";
5
5
  import "@tanstack/react-form";
@@ -50,14 +50,26 @@ declare const rootRouteHead: (options?: RootRouteHeadOptions) => {
50
50
  href: string;
51
51
  })[];
52
52
  };
53
- declare const requirePermission: (permissionKey: keyof typeof permissions) => ({ location, context }: {
53
+ type GuardArgs = {
54
54
  location: ParsedLocation;
55
55
  context: QueryClientParam;
56
- }) => Promise<{
56
+ };
57
+ /**
58
+ * Route guard for `beforeLoad`. Routes are public by default; add this to close one.
59
+ *
60
+ * - `requireAuth()` — signed in with any provider. The only gate a population
61
+ * without permission groups (e.g. AWS users) can pass.
62
+ * - `requireAuth("admin")` — signed in *and* in a group listed under that key.
63
+ *
64
+ * `reloadDocument` is required: `/auth/login` is a component-less server route and
65
+ * must be reached with a full-document navigation. It starts the login directly when
66
+ * only one provider is registered, otherwise it forwards to the `/login` chooser.
67
+ */
68
+ declare const requireAuth: (permissionKey?: keyof typeof permissions) => ({ location, context }: GuardArgs) => Promise<{
57
69
  user: User;
58
70
  }>;
59
71
  type FormOmittedProps = "name" | "value" | "onChange" | "onBlur" | "error" | "helperText" | "renderInput" | "type" | "aria-label";
60
72
  declare const hasPermission: (user: User | null, key: keyof typeof permissions) => boolean;
61
73
  //#endregion
62
- export { hasPermission as a, WISTRON_SECONDARY_COLOR as i, Platform as n, requirePermission as o, WISTRON_PRIMARY_COLOR as r, rootRouteHead as s, FormOmittedProps as t };
63
- //# sourceMappingURL=utils-5x4uNxsX.d.mts.map
74
+ export { hasPermission as a, WISTRON_SECONDARY_COLOR as i, Platform as n, requireAuth as o, WISTRON_PRIMARY_COLOR as r, rootRouteHead as s, FormOmittedProps as t };
75
+ //# sourceMappingURL=utils-Bhi0KiBx.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { queryOptions } from "@tanstack/react-query";
2
- import { manifest, permissions, scopes } from "virtual:wcz-layout";
2
+ import { manifest, permissions } from "virtual:wcz-layout";
3
3
  import { z as z$1 } from "zod";
4
4
  import { redirect } from "@tanstack/react-router";
5
- import { createServerFn, createServerOnlyFn } from "@tanstack/react-start";
5
+ import { createServerFn } from "@tanstack/react-start";
6
6
  import { createEnv } from "@t3-oss/env-core";
7
7
  //#region src/lib/auth/offline.ts
8
8
  /**
@@ -12,8 +12,8 @@ import { createEnv } from "@t3-oss/env-core";
12
12
  * while the server is unreachable. Server requests remain independently
13
13
  * authorized. At-rest protection is the device's OS login and disk encryption.
14
14
  */
15
- const OFFLINE_USER_KEY = "wcz-auth-user";
16
- const OFFLINE_PHOTO_KEY = "wcz-auth-photo";
15
+ const OFFLINE_USER_KEY = "auth-user";
16
+ const OFFLINE_PHOTO_KEY = "auth-photo";
17
17
  /** One shift — matches Intune's default offline grace period. */
18
18
  const GRACE_PERIOD = 432e5;
19
19
  const recall = (key) => {
@@ -66,14 +66,14 @@ const clearSessionSnapshot = () => {
66
66
  if (typeof localStorage === "undefined") return;
67
67
  localStorage.removeItem(OFFLINE_USER_KEY);
68
68
  localStorage.removeItem(OFFLINE_PHOTO_KEY);
69
- localStorage.setItem("wcz-auth-logout", String(Date.now()));
69
+ localStorage.setItem("auth-logout", String(Date.now()));
70
70
  };
71
71
  if (typeof window !== "undefined") window.addEventListener("storage", (event) => {
72
- if (event.key === "wcz-auth-logout") location.href = "/auth/logout";
72
+ if (event.key === "auth-logout") location.href = "/auth/logout";
73
73
  });
74
74
  createEnv({
75
75
  clientPrefix: "VITE_",
76
- client: { VITE_MUI_LICENSE_KEY: z$1.string() },
76
+ client: {},
77
77
  runtimeEnv: import.meta.env,
78
78
  emptyStringAsUndefined: true
79
79
  });
@@ -82,6 +82,10 @@ const serverEnv = createEnv({
82
82
  ENTRA_CLIENT_ID: z$1.string().min(1),
83
83
  ENTRA_TENANT_ID: z$1.string().min(1),
84
84
  ENTRA_CLIENT_SECRET: z$1.string().min(1),
85
+ AWS_ISSUER: z$1.url().optional(),
86
+ AWS_DOMAIN: z$1.url().optional(),
87
+ AWS_CLIENT_ID: z$1.string().min(1).optional(),
88
+ AWS_CLIENT_SECRET: z$1.string().min(1).optional(),
85
89
  SESSION_SECRET: z$1.string().min(32),
86
90
  FILE_BASE_URL: z$1.string().min(1).optional(),
87
91
  APPROVAL_BASE_URL: z$1.string().min(1).optional(),
@@ -112,6 +116,23 @@ const getAppSession = async () => {
112
116
  const getSessionUser = createServerFn({ method: "GET" }).handler(async () => {
113
117
  return (await getAppSession()).data.user ?? null;
114
118
  });
119
+ /** The identity providers the server offers, for the login page. */
120
+ const getLoginProviders = createServerFn({ method: "GET" }).handler(async () => {
121
+ const { providers } = await import("./providers-Dbl95AxR.mjs").then((n) => n.i);
122
+ return providers.map(({ id, label }) => ({
123
+ id,
124
+ label
125
+ }));
126
+ });
127
+ /**
128
+ * Feeds `LoginForm`. Server config, not per-user, so it is safe to prime on the
129
+ * server — the `/login` route's loader does that to avoid a flash of empty card.
130
+ */
131
+ const loginProvidersQueryOptions = queryOptions({
132
+ queryKey: ["auth", "providers"],
133
+ queryFn: () => getLoginProviders(),
134
+ staleTime: "static"
135
+ });
115
136
  /**
116
137
  * Client-side query for the signed-in user. Shared between `getUser` (route
117
138
  * `beforeLoad`) and the always-mounted observer in `LayoutProvider` — the
@@ -130,32 +151,6 @@ const getUser = ({ queryClient }) => {
130
151
  if (import.meta.env.SSR) return getSessionUser();
131
152
  return queryClient.ensureQueryData(userQueryOptions);
132
153
  };
133
- /**
134
- * Server-only token acquisition: a delegated access token for the given API
135
- * scope, minted from the user's session refresh token. Entra rotates the refresh
136
- * token on each use, so the rotated token is persisted back to the session. Use
137
- * inside server functions and middleware — it is stripped from the client bundle
138
- * and throws if called there.
139
- */
140
- const getAccessToken = createServerOnlyFn(async (scopeKey) => {
141
- const session = await getAppSession();
142
- if (!session.data.refreshToken) throw new Error("No active session. User not signed in.");
143
- const { acquireDelegatedToken, SessionExpiredError } = await import("./entra-CJSyeQsx.mjs");
144
- try {
145
- const { accessToken, refreshToken } = await acquireDelegatedToken({
146
- refreshToken: session.data.refreshToken,
147
- scopes: scopes[scopeKey]
148
- });
149
- if (refreshToken !== session.data.refreshToken) await session.update({ refreshToken });
150
- return accessToken;
151
- } catch (error) {
152
- if (error instanceof SessionExpiredError) {
153
- await session.clear();
154
- throw Response.json({ message: "Unauthorized: Session expired, sign in again" }, { status: 401 });
155
- }
156
- throw error;
157
- }
158
- });
159
154
  //#endregion
160
155
  //#region src/lib/utils.ts
161
156
  const WISTRON_PRIMARY_COLOR = "#00506E";
@@ -226,17 +221,31 @@ const rootRouteHead = (options) => ({
226
221
  }
227
222
  ]
228
223
  });
229
- const requirePermission = (permissionKey) => {
224
+ /**
225
+ * Route guard for `beforeLoad`. Routes are public by default; add this to close one.
226
+ *
227
+ * - `requireAuth()` — signed in with any provider. The only gate a population
228
+ * without permission groups (e.g. AWS users) can pass.
229
+ * - `requireAuth("admin")` — signed in *and* in a group listed under that key.
230
+ *
231
+ * `reloadDocument` is required: `/auth/login` is a component-less server route and
232
+ * must be reached with a full-document navigation. It starts the login directly when
233
+ * only one provider is registered, otherwise it forwards to the `/login` chooser.
234
+ */
235
+ const requireAuth = (permissionKey) => {
230
236
  return async ({ location, context }) => {
231
237
  const user = await getUser({ queryClient: context.queryClient });
232
238
  if (!user) throw redirect({
233
239
  href: `/auth/login?returnTo=${encodeURIComponent(location.href)}`,
234
240
  reloadDocument: true
235
241
  });
236
- if (!hasPermission(user, permissionKey)) throw new Error("You do not have permission to access this page.");
242
+ if (permissionKey && !hasPermission(user, permissionKey)) throw new Error("You do not have permission to access this page.");
237
243
  return { user };
238
244
  };
239
245
  };
246
+ const NON_PRODUCTION = /(?:^|[.-])(?:dev|qas|uat|test)(?:[.-]|$)/i;
247
+ /** True only for a dev/qas/uat/test domain — localhost and production are not. */
248
+ const isTestEnv = (origin) => NON_PRODUCTION.test((origin ?? "").split(".").slice(1).join("."));
240
249
  const getFieldStatus = (field) => {
241
250
  const { meta } = field.state;
242
251
  return {
@@ -245,17 +254,30 @@ const getFieldStatus = (field) => {
245
254
  helperText: meta.errors[0]?.message
246
255
  };
247
256
  };
257
+ /**
258
+ * Only same-origin paths are allowed, so `returnTo` cannot become an open
259
+ * redirect. Backslash counts as a separator too: browsers normalize `/\evil`
260
+ * to the protocol-relative `//evil`.
261
+ */
262
+ const sanitizeReturnTo = (value) => value && /^\/(?![/\\])/.test(value) ? value : "/";
263
+ const foldForSearch = (value) => String(value ?? "").toLowerCase().normalize("NFD").replaceAll(/[\u{300}-\u{36F}]/gu, "").normalize("NFC");
248
264
  const permissionGroups = new Set(Object.values(permissions).flat());
249
- const buildUser = (payload) => ({
250
- name: payload.name?.split("/")[0],
251
- email: payload.preferred_username?.toLowerCase(),
265
+ /**
266
+ * Maps id/access-token claims to the serializable `User`. Groups are trimmed to
267
+ * those named in `permissions.ts` — an unfiltered group list would blow the
268
+ * cookie. Cognito's claim names differ, so both are read.
269
+ */
270
+ const buildUser = (payload, provider) => ({
271
+ provider,
272
+ name: (payload.name ?? payload["cognito:username"] ?? "").split("/")[0],
273
+ email: (payload.preferred_username ?? payload.email ?? "").toLowerCase(),
252
274
  department: payload.department?.toUpperCase() || "",
253
- employeeId: payload.employeeId?.toUpperCase() || "",
275
+ employeeId: (payload.employeeId ?? payload["cognito:username"] ?? "").toUpperCase(),
254
276
  companyName: payload.companyName || "",
255
- groups: payload.groups?.filter((group) => permissionGroups.has(group)) ?? []
277
+ groups: (payload.groups ?? payload["cognito:groups"])?.filter((group) => permissionGroups.has(group)) ?? []
256
278
  });
257
279
  const hasPermission = (user, key) => user ? permissions[key].some((group) => user.groups.includes(group)) : false;
258
280
  //#endregion
259
- export { withOfflineFallback as _, getFieldStatus as a, rootRouteHead as c, getUser as d, userQueryOptions as f, clearSessionSnapshot as g, OFFLINE_PHOTO_KEY as h, buildUser as i, getAccessToken as l, serverEnv as m, WISTRON_PRIMARY_COLOR as n, hasPermission as o, getAppSession as p, WISTRON_SECONDARY_COLOR as r, requirePermission as s, Platform as t, getSessionUser as u };
281
+ export { serverEnv as _, foldForSearch as a, withOfflineFallback as b, isTestEnv as c, sanitizeReturnTo as d, getSessionUser as f, getAppSession as g, userQueryOptions as h, buildUser as i, requireAuth as l, loginProvidersQueryOptions as m, WISTRON_PRIMARY_COLOR as n, getFieldStatus as o, getUser as p, WISTRON_SECONDARY_COLOR as r, hasPermission as s, Platform as t, rootRouteHead as u, OFFLINE_PHOTO_KEY as v, clearSessionSnapshot as y };
260
282
 
261
- //# sourceMappingURL=utils-DjdexspV.mjs.map
283
+ //# sourceMappingURL=utils-KaM5VMTJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-KaM5VMTJ.mjs","names":["OFFLINE_USER_KEY","OFFLINE_PHOTO_KEY","GRACE_PERIOD","Cached","value","T","savedAt","recall","key","localStorage","raw","getItem","JSON","parse","Date","now","removeItem","remember","undefined","setItem","stringify","isOfflineFailure","error","navigator","onLine","TypeError","withOfflineFallback","fetchFresh","Promise","fresh","clearSessionSnapshot","String","window","addEventListener","event","location","href","createEnv","z","clientEnv","clientPrefix","client","runtimeEnv","import","meta","env","emptyStringAsUndefined","serverEnv","server","ENTRA_CLIENT_ID","string","min","ENTRA_TENANT_ID","ENTRA_CLIENT_SECRET","AWS_ISSUER","url","optional","AWS_DOMAIN","AWS_CLIENT_ID","AWS_CLIENT_SECRET","SESSION_SECRET","FILE_BASE_URL","APPROVAL_BASE_URL","PEOPLESOFT_BASE_URL","EMAIL_BASE_URL","AI_BASE_URL","AI_SUBSCRIPTION_KEY","process","useSession","serverEnv","ProviderId","User","AppSessionData","provider","refreshToken","user","pkceVerifier","state","returnTo","AppSession","Awaited","ReturnType","getAppSession","Promise","getSession","name","password","SESSION_SECRET","queryOptions","createServerFn","QueryClientParam","ProviderId","User","OFFLINE_USER_KEY","withOfflineFallback","getAppSession","getSessionUser","method","handler","Promise","session","data","user","getLoginProviders","Array","id","label","providers","map","loginProvidersQueryOptions","queryKey","queryFn","staleTime","userQueryOptions","Infinity","networkMode","refetchOnReconnect","getUser","queryClient","import","meta","env","SSR","ensureQueryData","AnyFieldApi","redirect","ParsedLocation","manifest","permissions","QueryClientParam","TokenPayload","ProviderId","User","getUser","WISTRON_PRIMARY_COLOR","WISTRON_SECONDARY_COLOR","Platform","isAndroid","test","userAgent","isIOS","isWindows","isMacOS","navigator","RootRouteHeadOptions","rootRouteHead","options","meta","charSet","name","content","title","links","rel","sizes","href","type","GuardArgs","location","context","requireAuth","permissionKey","user","queryClient","encodeURIComponent","reloadDocument","hasPermission","Error","NON_PRODUCTION","isTestEnv","origin","split","slice","join","FormOmittedProps","getFieldStatus","field","state","isTouched","hasError","errors","length","helperText","message","sanitizeReturnTo","value","toKebabCase","str","replaceAll","toLowerCase","foldForSearch","String","normalize","permissionGroups","Set","Object","values","flat","buildUser","payload","provider","email","preferred_username","department","toUpperCase","employeeId","companyName","groups","filter","group","has","key","some","includes"],"sources":["../src/lib/auth/offline.ts","../src/env.ts","../src/lib/auth/session.ts","../src/lib/auth/user.ts","../src/lib/utils.ts"],"sourcesContent":["/**\n * Offline fallback for identity. The refresh token never leaves the sealed\n * httpOnly cookie — what is cached here is only the display snapshot (user\n * claims and avatar) so the UI and offline route permissions can still work\n * while the server is unreachable. Server requests remain independently\n * authorized. At-rest protection is the device's OS login and disk encryption.\n */\n\nexport const OFFLINE_USER_KEY = \"auth-user\";\nexport const OFFLINE_PHOTO_KEY = \"auth-photo\";\n\n/** One shift — matches Intune's default offline grace period. */\nconst GRACE_PERIOD = 12 * 60 * 60 * 1000;\n\ntype Cached<T> = { value: T; savedAt: number };\n\nconst recall = <T>(key: string): T | null => {\n if (typeof localStorage === \"undefined\") return null;\n try {\n const raw = localStorage.getItem(key);\n if (!raw) return null;\n const { value, savedAt } = JSON.parse(raw) as Cached<T>;\n if (Date.now() - savedAt > GRACE_PERIOD) {\n localStorage.removeItem(key);\n return null;\n }\n return value;\n } catch {\n localStorage.removeItem(key);\n return null;\n }\n};\n\nconst remember = (key: string, value: unknown): void => {\n if (typeof localStorage === \"undefined\") return;\n try {\n if (value === null || value === undefined) localStorage.removeItem(key);\n else localStorage.setItem(key, JSON.stringify({ value, savedAt: Date.now() }));\n } catch {\n // Storage full or blocked — the offline fallback is best-effort.\n }\n};\n\nconst isOfflineFailure = (error: unknown): boolean =>\n (typeof navigator !== \"undefined\" && !navigator.onLine) || error instanceof TypeError;\n\n/**\n * Answers from the server when reachable, remembering the result; when the call\n * has a transport failure, replays the last result instead, for up to\n * {@link GRACE_PERIOD} since it was last confirmed.\n *\n * Cached values are untrusted client state. Server authorization must never\n * depend on them.\n */\nexport const withOfflineFallback = async <T>(\n key: string,\n fetchFresh: () => Promise<T>,\n): Promise<T | null> => {\n try {\n const fresh = await fetchFresh();\n remember(key, fresh);\n return fresh;\n } catch (error) {\n if (!isOfflineFailure(error)) throw error;\n return recall<T>(key);\n }\n};\n\n/** Drops the cached identity. Call on logout, before leaving the page. */\nexport const clearSessionSnapshot = (): void => {\n if (typeof localStorage === \"undefined\") return;\n localStorage.removeItem(OFFLINE_USER_KEY);\n localStorage.removeItem(OFFLINE_PHOTO_KEY);\n localStorage.setItem(\"auth-logout\", String(Date.now()));\n};\n\nif (typeof window !== \"undefined\")\n window.addEventListener(\"storage\", (event) => {\n if (event.key === \"auth-logout\") location.href = \"/auth/logout\";\n });\n","import { createEnv } from \"@t3-oss/env-core\";\nimport { z } from \"zod\";\n\nexport const clientEnv = createEnv({\n clientPrefix: \"VITE_\",\n client: {},\n runtimeEnv: import.meta.env,\n emptyStringAsUndefined: true,\n});\n\nexport const serverEnv = createEnv({\n server: {\n ENTRA_CLIENT_ID: z.string().min(1),\n ENTRA_TENANT_ID: z.string().min(1),\n ENTRA_CLIENT_SECRET: z.string().min(1),\n AWS_ISSUER: z.url().optional(),\n AWS_DOMAIN: z.url().optional(),\n AWS_CLIENT_ID: z.string().min(1).optional(),\n AWS_CLIENT_SECRET: z.string().min(1).optional(),\n SESSION_SECRET: z.string().min(32),\n FILE_BASE_URL: z.string().min(1).optional(),\n APPROVAL_BASE_URL: z.string().min(1).optional(),\n PEOPLESOFT_BASE_URL: z.string().min(1).optional(),\n EMAIL_BASE_URL: z.string().min(1).optional(),\n AI_BASE_URL: z.string().min(1).optional(),\n AI_SUBSCRIPTION_KEY: z.string().min(1).optional(),\n },\n runtimeEnv: process.env,\n emptyStringAsUndefined: true,\n});\n","import type { useSession } from \"@tanstack/react-start/server\";\r\nimport { serverEnv } from \"~/env\";\r\nimport type { ProviderId, User } from \"~/models/User\";\r\n\r\nexport interface AppSessionData {\r\n /** Which identity provider signed this user in. */\r\n provider?: ProviderId;\r\n /** The only token persisted; delegated access tokens are minted from it. */\r\n refreshToken?: string;\r\n user?: User;\r\n /** Transient, only between /auth/login and /auth/callback. */\r\n pkceVerifier?: string;\r\n state?: string;\r\n returnTo?: string;\r\n}\r\n\r\n/** `SessionManager` is not re-exported upstream, so name it through `useSession`. */\r\nexport type AppSession = Awaited<ReturnType<typeof useSession<AppSessionData>>>;\r\n\r\nexport const getAppSession = async (): Promise<AppSession> => {\r\n // Dynamic import: `@tanstack/react-start/server` is the server entry and drags\r\n // in the SSR renderer (`react-dom/server`). Keep it out of the client graph —\r\n // this helper is only ever called server-side, and all callers already await it.\r\n // Aliased off the `use*` name so it isn't mistaken for a React hook (it's a\r\n // server session helper, not a hook).\r\n const { useSession: getSession } = await import(\"@tanstack/react-start/server\");\r\n\r\n return getSession<AppSessionData>({\r\n name: \"session\",\r\n password: serverEnv.SESSION_SECRET,\r\n });\r\n};\r\n","import { queryOptions } from \"@tanstack/react-query\";\nimport { createServerFn } from \"@tanstack/react-start\";\nimport type { QueryClientParam } from \"~/models/QueryClientParam\";\nimport type { ProviderId, User } from \"~/models/User\";\nimport { OFFLINE_USER_KEY, withOfflineFallback } from \"./offline\";\nimport { getAppSession } from \"./session\";\n\n/**\n * Reads the signed-in user from the session cookie, or null. As a server function\n * it runs in-process when called on the server (SSR, middleware) and as an RPC\n * when called from the client — so it doubles as the client `queryFn`.\n */\nexport const getSessionUser = createServerFn({ method: \"GET\" }).handler(\n async (): Promise<User | null> => {\n const session = await getAppSession();\n return session.data.user ?? null;\n },\n);\n\n/** The identity providers the server offers, for the login page. */\nexport const getLoginProviders = createServerFn({ method: \"GET\" }).handler(\n async (): Promise<Array<{ id: ProviderId; label: string }>> => {\n // Dynamic import: `providers` reads `serverEnv` and must not reach the client.\n const { providers } = await import(\"./providers\");\n return providers.map(({ id, label }) => ({ id, label }));\n },\n);\n\n/**\n * Feeds `LoginForm`. Server config, not per-user, so it is safe to prime on the\n * server — the `/login` route's loader does that to avoid a flash of empty card.\n */\nexport const loginProvidersQueryOptions = queryOptions({\n queryKey: [\"auth\", \"providers\"],\n queryFn: () => getLoginProviders(),\n staleTime: \"static\",\n});\n\n/**\n * Client-side query for the signed-in user. Shared between `getUser` (route\n * `beforeLoad`) and the always-mounted observer in `LayoutProvider` — the\n * observer is what seeds the offline snapshot on the very first page load\n * (`beforeLoad` does not re-run after SSR hydration) and what makes\n * `refetchOnReconnect` fire once connectivity returns.\n */\nexport const userQueryOptions = queryOptions({\n queryKey: [\"auth\", \"user\"],\n queryFn: () => withOfflineFallback(OFFLINE_USER_KEY, () => getSessionUser()),\n staleTime: Infinity,\n // Default \"online\" pauses the query (never calling queryFn) once the browser\n // reports no connection — which is exactly when the fallback is needed.\n networkMode: \"offlineFirst\",\n // Back online: re-confirm the session and re-stamp the snapshot's grace period.\n refetchOnReconnect: \"always\",\n});\n\nexport const getUser = ({ queryClient }: QueryClientParam): Promise<User | null> => {\n if (import.meta.env.SSR) return getSessionUser();\n\n return queryClient.ensureQueryData(userQueryOptions);\n};\n","import type { AnyFieldApi } from \"@tanstack/react-form\";\nimport { redirect } from \"@tanstack/react-router\";\nimport type { ParsedLocation } from \"@tanstack/react-router\";\nimport { manifest, permissions } from \"virtual:wcz-layout\";\nimport type { QueryClientParam } from \"~/models/QueryClientParam\";\nimport type { TokenPayload } from \"~/models/TokenPayload\";\nimport type { ProviderId, User } from \"~/models/User\";\nimport { getUser } from \"./auth/user\";\n\nexport const WISTRON_PRIMARY_COLOR = \"#00506E\";\nexport const WISTRON_SECONDARY_COLOR = \"#64DC00\";\n\nexport class Platform {\n static get isAndroid() {\n return /android/i.test(this.userAgent);\n }\n static get isIOS() {\n return /iPad|iPhone|iPod/.test(this.userAgent);\n }\n static get isWindows() {\n return /windows/i.test(this.userAgent);\n }\n static get isMacOS() {\n return /Macintosh|MacIntel|MacPPC|Mac68K/.test(this.userAgent);\n }\n\n private static get userAgent() {\n return typeof navigator === \"undefined\" ? \"\" : navigator.userAgent;\n }\n}\n\ninterface RootRouteHeadOptions {\n manifest?: string;\n}\n\nexport const rootRouteHead = (options?: RootRouteHeadOptions) => ({\n meta: [\n { charSet: \"utf-8\" },\n { name: \"viewport\", content: \"width=device-width, initial-scale=1\" },\n { title: manifest.name },\n { name: \"og:type\", content: \"website\" },\n { name: \"og:title\", content: manifest.name },\n { name: \"og:image\", content: \"/favicon-32x32.png\" },\n ],\n links: [\n { rel: \"apple-touch-icon\", sizes: \"180x180\", href: \"/apple-touch-icon.png\" },\n { rel: \"icon\", type: \"image/png\", sizes: \"32x32\", href: \"/favicon-32x32.png\" },\n { rel: \"icon\", type: \"image/png\", sizes: \"16x16\", href: \"/favicon-16x16.png\" },\n { rel: \"manifest\", href: options?.manifest || \"/manifest.json\" },\n { rel: \"icon\", href: \"/favicon.ico\" },\n ],\n});\n\ntype GuardArgs = { location: ParsedLocation; context: QueryClientParam };\n\n/**\n * Route guard for `beforeLoad`. Routes are public by default; add this to close one.\n *\n * - `requireAuth()` — signed in with any provider. The only gate a population\n * without permission groups (e.g. AWS users) can pass.\n * - `requireAuth(\"admin\")` — signed in *and* in a group listed under that key.\n *\n * `reloadDocument` is required: `/auth/login` is a component-less server route and\n * must be reached with a full-document navigation. It starts the login directly when\n * only one provider is registered, otherwise it forwards to the `/login` chooser.\n */\nexport const requireAuth = (permissionKey?: keyof typeof permissions) => {\n return async ({ location, context }: GuardArgs) => {\n const user = await getUser({ queryClient: context.queryClient });\n\n if (!user)\n throw redirect({\n href: `/auth/login?returnTo=${encodeURIComponent(location.href)}`,\n reloadDocument: true,\n });\n\n if (permissionKey && !hasPermission(user, permissionKey))\n throw new Error(\"You do not have permission to access this page.\");\n\n return { user };\n };\n};\n\n/* Internal Utils */\nconst NON_PRODUCTION = /(?:^|[.-])(?:dev|qas|uat|test)(?:[.-]|$)/i;\n\n/** True only for a dev/qas/uat/test domain — localhost and production are not. */\nexport const isTestEnv = (origin: string | undefined) =>\n NON_PRODUCTION.test((origin ?? \"\").split(\".\").slice(1).join(\".\"));\n\nexport type FormOmittedProps =\n | \"name\"\n | \"value\"\n | \"onChange\"\n | \"onBlur\"\n | \"error\"\n | \"helperText\"\n | \"renderInput\"\n | \"type\"\n | \"aria-label\";\n\nexport const getFieldStatus = (field: AnyFieldApi) => {\n const { meta } = field.state;\n\n const isTouched = meta.isTouched;\n const hasError = !!meta.errors.length;\n const helperText = meta.errors[0]?.message;\n\n return { isTouched, hasError, helperText };\n};\n\n/**\n * Only same-origin paths are allowed, so `returnTo` cannot become an open\n * redirect. Backslash counts as a separator too: browsers normalize `/\\evil`\n * to the protocol-relative `//evil`.\n */\nexport const sanitizeReturnTo = (value: string | null | undefined): string =>\n value && /^\\/(?![/\\\\])/.test(value) ? value : \"/\";\n\nexport const toKebabCase = (str: string): string => {\n return str\n .replaceAll(/([a-z])([A-Z])/g, \"$1-$2\")\n .replaceAll(/[\\s_]+/g, \"-\")\n .replaceAll(/[^a-zA-Z0-9-]/g, \"\")\n .toLowerCase()\n .replaceAll(/-+/g, \"-\")\n .replaceAll(/(^-|-$)/g, \"\");\n};\n\nexport const foldForSearch = (value: unknown): string =>\n String(value ?? \"\")\n .toLowerCase()\n .normalize(\"NFD\")\n .replaceAll(/[\\u{300}-\\u{36F}]/gu, \"\")\n .normalize(\"NFC\");\n\nconst permissionGroups = new Set<string>(Object.values(permissions).flat());\n\n/**\n * Maps id/access-token claims to the serializable `User`. Groups are trimmed to\n * those named in `permissions.ts` — an unfiltered group list would blow the\n * cookie. Cognito's claim names differ, so both are read.\n */\nexport const buildUser = (payload: TokenPayload, provider: ProviderId): User => ({\n provider,\n name: (payload.name ?? payload[\"cognito:username\"] ?? \"\").split(\"/\")[0],\n email: (payload.preferred_username ?? payload.email ?? \"\").toLowerCase(),\n department: payload.department?.toUpperCase() || \"\",\n employeeId: (payload.employeeId ?? payload[\"cognito:username\"] ?? \"\").toUpperCase(),\n companyName: payload.companyName || \"\",\n groups:\n (payload.groups ?? payload[\"cognito:groups\"])?.filter((group) => permissionGroups.has(group)) ??\n [],\n});\n\nexport const hasPermission = (user: User | null, key: keyof typeof permissions): boolean =>\n user ? permissions[key].some((group) => user.groups.includes(group)) : false;\n"],"mappings":";;;;;;;;;;;;;;AAQA,MAAaA,mBAAmB;AAChC,MAAaC,oBAAoB;;AAGjC,MAAMC,eAAe;AAIrB,MAAMK,UAAaC,QAA0B;CAC3C,IAAI,OAAOC,iBAAiB,aAAa,OAAO;CAChD,IAAI;EACF,MAAMC,MAAMD,aAAaE,QAAQH,GAAG;EACpC,IAAI,CAACE,KAAK,OAAO;EACjB,MAAM,EAAEN,OAAOE,YAAYM,KAAKC,MAAMH,GAAG;EACzC,IAAII,KAAKC,IAAI,IAAIT,UAAUJ,cAAc;GACvCO,aAAaO,WAAWR,GAAG;GAC3B,OAAO;EACT;EACA,OAAOJ;CACT,QAAQ;EACNK,aAAaO,WAAWR,GAAG;EAC3B,OAAO;CACT;AACF;AAEA,MAAMS,YAAYT,KAAaJ,UAAyB;CACtD,IAAI,OAAOK,iBAAiB,aAAa;CACzC,IAAI;EACF,IAAIL,UAAU,QAAQA,UAAUc,KAAAA,GAAWT,aAAaO,WAAWR,GAAG;OACjEC,aAAaU,QAAQX,KAAKI,KAAKQ,UAAU;GAAEhB;GAAOE,SAASQ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A,CAAI5B,MAAM,GAAG,CAAC,CAAC;CACrE8B,QAAQF,QAAQG,sBAAsBH,QAAQE,SAAS,GAAA,CAAIZ,YAAY;CACvEc,YAAYJ,QAAQI,YAAYC,YAAY,KAAK;CACjDC,aAAaN,QAAQM,cAAcN,QAAQ,uBAAuB,GAAA,CAAIK,YAAY;CAClFE,aAAaP,QAAQO,eAAe;CACpCC,SACGR,QAAQQ,UAAUR,QAAQ,kBAAA,EAAoBS,QAAQC,UAAUhB,iBAAiBiB,IAAID,KAAK,CAAC,KAC5F,CAAA;AACJ;AAEA,MAAa3C,iBAAiBJ,MAAmBiD,QAC/CjD,OAAOlC,YAAYmF,IAAI,CAACC,MAAMH,UAAU/C,KAAK6C,OAAOM,SAASJ,KAAK,CAAC,IAAI"}
package/dist/utils.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as hasPermission, n as Platform, o as requirePermission } from "./utils-5x4uNxsX.mjs";
1
+ import { a as hasPermission, n as Platform, o as requireAuth } from "./utils-Bhi0KiBx.mjs";
2
2
  import i18next, { t } from "i18next";
3
3
  import { createEnv } from "@t3-oss/env-core";
4
4
  import { uuidv7 } from "uuidv7";
5
- export { Platform, createEnv, hasPermission, i18next, requirePermission, t, uuidv7 };
5
+ export { Platform, createEnv, hasPermission, i18next, requireAuth, t, uuidv7 };
package/dist/utils.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { o as hasPermission, s as requirePermission, t as Platform } from "./utils-DjdexspV.mjs";
1
+ import { l as requireAuth, s as hasPermission, t as Platform } from "./utils-KaM5VMTJ.mjs";
2
2
  import i18next, { t } from "i18next";
3
3
  import { createEnv } from "@t3-oss/env-core";
4
4
  import { uuidv7 } from "uuidv7";
5
- export { Platform, createEnv, hasPermission, i18next, requirePermission, t, uuidv7 };
5
+ export { Platform, createEnv, hasPermission, i18next, requireAuth, t, uuidv7 };
package/dist/vite.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Plugin } from "vite";
2
2
  //#region src/lib/vite-plugin.d.ts
3
- declare function viteWczLayout(): Plugin;
3
+ export declare function viteWczLayout(): Plugin;
4
4
  //#endregion
5
- export { viteWczLayout };
6
5
  //# sourceMappingURL=vite.d.mts.map
package/dist/vite.mjs CHANGED
@@ -72,13 +72,13 @@ function dayjsLocaleImports(resources) {
72
72
  function ensurePermissionsFile(permissionsPath, addWatchFile) {
73
73
  const dir = path.dirname(permissionsPath);
74
74
  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
75
- if (!fs.existsSync(permissionsPath)) fs.writeFileSync(permissionsPath, "export const permissions = {\n admin: [\"wcz-developers\"]\n} as const;");
75
+ if (!fs.existsSync(permissionsPath)) fs.writeFileSync(permissionsPath, "import type { Permissions } from \"wcz-layout/models\";\n\nexport const permissions = {\n admin: [\"wcz-developers\"],\n} as const satisfies Permissions;\n");
76
76
  addWatchFile(permissionsPath);
77
77
  }
78
78
  function ensureScopesFile(scopesPath, addWatchFile) {
79
79
  const dir = path.dirname(scopesPath);
80
80
  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
81
- if (!fs.existsSync(scopesPath)) fs.writeFileSync(scopesPath, "export const scopes = {\n} as const;");
81
+ if (!fs.existsSync(scopesPath)) fs.writeFileSync(scopesPath, "import type { Scopes } from \"wcz-layout/models\";\n\nexport const scopes = {\n graph: \"User.Read\",\n api: \"api://wistron.com/app-scope/access_as_user\",\n} as const satisfies Scopes;\n");
82
82
  addWatchFile(scopesPath);
83
83
  }
84
84
  function loadManifest(manifestPath, addWatchFile) {
@@ -91,7 +91,7 @@ function loadManifest(manifestPath, addWatchFile) {
91
91
  }
92
92
  function viteWczLayout() {
93
93
  const virtualModuleId = "virtual:wcz-layout";
94
- const resolvedVirtualModuleId = "\0virtual:wcz-layout";
94
+ const resolvedVirtualModuleId = "\0" + virtualModuleId;
95
95
  let localesPath;
96
96
  let permissionsPath;
97
97
  let scopesPath;
package/dist/vite.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.mjs","names":[],"sources":["../src/models/VaultConfig.ts","../src/lib/vite-plugin.ts"],"sourcesContent":["import z from \"zod\";\n\nexport const VaultConfigSchema = z.object({\n VAULT_ADDRESS: z.url(),\n VAULT_USERNAME: z.string().min(1),\n VAULT_PASSWORD: z.string().min(1),\n VAULT_SECRET_PATH: z.string().min(1),\n VAULT_MOUNT_POINT: z.string().default(\"release\"),\n});\n\nexport type VaultConfig = z.infer<typeof VaultConfigSchema>;\n","import fs from \"node:fs\";\nimport https from \"node:https\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport axios from \"axios\";\nimport { loadEnv } from \"vite\";\nimport { VaultConfigSchema } from \"../models/VaultConfig\";\nimport type { Resource } from \"i18next\";\nimport type { Plugin } from \"vite\";\n\nasync function fetchVaultSecrets(env: Record<string, string>): Promise<Record<string, string>> {\n const config = VaultConfigSchema.parse(env);\n const { VAULT_ADDRESS, VAULT_USERNAME, VAULT_PASSWORD, VAULT_SECRET_PATH, VAULT_MOUNT_POINT } =\n config;\n\n const client = axios.create({\n baseURL: VAULT_ADDRESS,\n httpsAgent: new https.Agent({ rejectUnauthorized: false }),\n });\n\n const { data: loginData } = await client.post(`/v1/auth/userpass/login/${VAULT_USERNAME}`, {\n password: VAULT_PASSWORD,\n });\n\n const { data: secretData } = await client.get(\n `/v1/${VAULT_MOUNT_POINT}/data/${VAULT_SECRET_PATH}`,\n {\n headers: { \"X-Vault-Token\": loginData.auth.client_token },\n },\n );\n\n const secrets = secretData?.data?.data;\n if (!secrets) throw new Error(\"No secrets found\");\n\n return Object.fromEntries(\n Object.entries(secrets).map(([key, value]) => [\n key,\n typeof value === \"string\" ? value : JSON.stringify(value),\n ]),\n );\n}\n\nasync function loadVaultSecrets(command: string): Promise<void> {\n if (command !== \"serve\") return;\n\n const env = loadEnv(\"development\", process.cwd(), \"\");\n if (!env.VAULT_ADDRESS) return;\n\n try {\n const secrets = await fetchVaultSecrets(env);\n Object.entries(secrets).forEach(([key, value]) => {\n process.env[key] = env[key]?.trim() ? env[key] : value;\n });\n } catch (e) {\n console.warn(\"[vite:wcz-layout] Vault failed:\", e instanceof Error ? e.message : e);\n }\n}\n\nfunction loadLocaleResources(localesPath: string, addWatchFile: (path: string) => void): Resource {\n if (!fs.existsSync(localesPath)) fs.mkdirSync(localesPath, { recursive: true });\n\n const enPath = path.join(localesPath, \"en.json\");\n if (!fs.existsSync(enPath)) fs.writeFileSync(enPath, JSON.stringify({}));\n\n const files = fs.readdirSync(localesPath);\n const resources: Resource = {};\n\n for (const file of files.filter((f) => f.endsWith(\".json\"))) {\n const lang = path.basename(file, \".json\");\n const filePath = path.join(localesPath, file);\n try {\n resources[lang] = { translation: JSON.parse(fs.readFileSync(filePath, \"utf-8\")) };\n } catch {\n resources[lang] = { translation: {} };\n }\n addWatchFile(filePath);\n }\n\n return resources;\n}\n\nconst require = createRequire(import.meta.url);\n\nfunction dayjsLocaleImports(resources: Resource): string {\n return Object.keys(resources)\n .map((lang) => lang.toLowerCase())\n .filter((lang) => {\n try {\n require.resolve(`dayjs/locale/${lang}.js`);\n return true;\n } catch {\n return false;\n }\n })\n .map((lang) => `import \"dayjs/locale/${lang}\";`)\n .join(\"\\n\");\n}\n\nfunction ensurePermissionsFile(\n permissionsPath: string,\n addWatchFile: (path: string) => void,\n): void {\n const dir = path.dirname(permissionsPath);\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n if (!fs.existsSync(permissionsPath)) {\n fs.writeFileSync(\n permissionsPath,\n 'export const permissions = {\\n admin: [\"wcz-developers\"]\\n} as const;',\n );\n }\n addWatchFile(permissionsPath);\n}\n\nfunction ensureScopesFile(scopesPath: string, addWatchFile: (path: string) => void): void {\n const dir = path.dirname(scopesPath);\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n if (!fs.existsSync(scopesPath)) {\n fs.writeFileSync(scopesPath, \"export const scopes = {\\n} as const;\");\n }\n addWatchFile(scopesPath);\n}\n\nfunction loadManifest(\n manifestPath: string,\n addWatchFile: (path: string) => void,\n): { name: string } & Record<string, unknown> {\n addWatchFile(manifestPath);\n try {\n return JSON.parse(fs.readFileSync(manifestPath, \"utf-8\"));\n } catch {\n return { name: \"\" };\n }\n}\n\nexport function viteWczLayout(): Plugin {\n const virtualModuleId = \"virtual:wcz-layout\";\n const resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\n\n let localesPath: string;\n let permissionsPath: string;\n let scopesPath: string;\n let envPath: string;\n let manifestPath: string;\n\n return {\n name: \"vite:wcz-layout\",\n enforce: \"pre\",\n configResolved(resolvedConfig) {\n localesPath = path.resolve(resolvedConfig.root, \"src/lib/locales\");\n permissionsPath = path.resolve(resolvedConfig.root, \"src/lib/auth/permissions.ts\");\n scopesPath = path.resolve(resolvedConfig.root, \"src/lib/auth/scopes.ts\");\n envPath = path.resolve(resolvedConfig.root, \"src/env.ts\");\n manifestPath = path.resolve(resolvedConfig.root, \"public/manifest.json\");\n },\n async config(_, { command }) {\n await loadVaultSecrets(command);\n },\n configureServer(server) {\n const refresh = (filePath: string) => {\n if (\n filePath.includes(localesPath) ||\n filePath === permissionsPath ||\n filePath === scopesPath ||\n filePath === envPath ||\n filePath === manifestPath\n ) {\n const module = server.moduleGraph.getModuleById(resolvedVirtualModuleId);\n if (module) server.moduleGraph.invalidateModule(module);\n server.ws.send({ type: \"full-reload\", path: \"*\" });\n }\n };\n\n server.watcher.add([localesPath, permissionsPath, scopesPath, envPath, manifestPath]);\n server.watcher.on(\"add\", refresh);\n server.watcher.on(\"change\", refresh);\n server.watcher.on(\"unlink\", refresh);\n },\n resolveId(id) {\n if (id === virtualModuleId) return resolvedVirtualModuleId;\n return null;\n },\n load(id) {\n if (id !== resolvedVirtualModuleId) return null;\n\n const resources = loadLocaleResources(localesPath, this.addWatchFile.bind(this));\n ensurePermissionsFile(permissionsPath, this.addWatchFile.bind(this));\n ensureScopesFile(scopesPath, this.addWatchFile.bind(this));\n const manifest = loadManifest(manifestPath, this.addWatchFile.bind(this));\n\n const normalizedPermissionsPath = permissionsPath.split(path.sep).join(path.posix.sep);\n const normalizedScopesPath = scopesPath.split(path.sep).join(path.posix.sep);\n const normalizedEnvPath = envPath.split(path.sep).join(path.posix.sep);\n return `\n ${dayjsLocaleImports(resources)}\n export const resources = ${JSON.stringify(resources)};\n export const manifest = ${JSON.stringify(manifest)};\n export { permissions } from \"${normalizedPermissionsPath}\";\n export { scopes } from \"${normalizedScopesPath}\";\n export { serverEnv } from \"${normalizedEnvPath}\";\n `;\n },\n };\n}\n"],"mappings":";;;;;;;;AAEA,MAAa,oBAAoB,EAAE,OAAO;CACxC,eAAe,EAAE,IAAI;CACrB,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAChC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAChC,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACnC,mBAAmB,EAAE,OAAO,CAAC,CAAC,QAAQ,SAAS;AACjD,CAAC;;;ACED,eAAe,kBAAkB,KAA8D;CAE7F,MAAM,EAAE,eAAe,gBAAgB,gBAAgB,mBAAmB,sBAD3D,kBAAkB,MAAM,GAErC;CAEF,MAAM,SAAS,MAAM,OAAO;EAC1B,SAAS;EACT,YAAY,IAAI,MAAM,MAAM,EAAE,oBAAoB,MAAM,CAAC;CAC3D,CAAC;CAED,MAAM,EAAE,MAAM,cAAc,MAAM,OAAO,KAAK,2BAA2B,kBAAkB,EACzF,UAAU,eACZ,CAAC;CAED,MAAM,EAAE,MAAM,eAAe,MAAM,OAAO,IACxC,OAAO,kBAAiB,QAAS,qBACjC,EACE,SAAS,EAAE,iBAAiB,UAAU,KAAK,aAAa,EAC1D,CACF;CAEA,MAAM,UAAU,YAAY,MAAM;CAClC,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,kBAAkB;CAEhD,OAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAC5C,KACA,OAAO,UAA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,OAAO;cACC,mBAAmB,SAAS,EAAC;uCACJ,KAAK,UAAU,SAAS,EAAC;sCAC1B,KAAK,UAAU,QAAQ,EAAC;2CACnB,0BAAyB;sCAC9B,qBAAoB;yCACjB,kBAAiB;;EAEtD;CACF;AACF"}
1
+ {"version":3,"file":"vite.mjs","names":["z","VaultConfigSchema","object","VAULT_ADDRESS","url","VAULT_USERNAME","string","min","VAULT_PASSWORD","VAULT_SECRET_PATH","VAULT_MOUNT_POINT","default","VaultConfig","infer","fs","https","createRequire","path","axios","loadEnv","VaultConfigSchema","Resource","Plugin","fetchVaultSecrets","env","Record","Promise","config","parse","VAULT_ADDRESS","VAULT_USERNAME","VAULT_PASSWORD","VAULT_SECRET_PATH","VAULT_MOUNT_POINT","client","create","baseURL","httpsAgent","Agent","rejectUnauthorized","data","loginData","post","password","secretData","get","headers","auth","client_token","secrets","Error","Object","fromEntries","entries","map","key","value","JSON","stringify","loadVaultSecrets","command","process","cwd","forEach","trim","e","console","warn","message","loadLocaleResources","localesPath","addWatchFile","existsSync","mkdirSync","recursive","enPath","join","writeFileSync","files","readdirSync","resources","file","filter","f","endsWith","lang","basename","filePath","translation","readFileSync","require","import","meta","url","dayjsLocaleImports","keys","toLowerCase","resolve","ensurePermissionsFile","permissionsPath","dir","dirname","ensureScopesFile","scopesPath","loadManifest","manifestPath","name","viteWczLayout","virtualModuleId","resolvedVirtualModuleId","envPath","enforce","configResolved","resolvedConfig","root","_","configureServer","server","refresh","includes","module","moduleGraph","getModuleById","invalidateModule","ws","send","type","watcher","add","on","resolveId","id","load","bind","manifest","normalizedPermissionsPath","split","sep","posix","normalizedScopesPath","normalizedEnvPath"],"sources":["../src/models/VaultConfig.ts","../src/lib/vite-plugin.ts"],"sourcesContent":["import z from \"zod\";\n\nexport const VaultConfigSchema = z.object({\n VAULT_ADDRESS: z.url(),\n VAULT_USERNAME: z.string().min(1),\n VAULT_PASSWORD: z.string().min(1),\n VAULT_SECRET_PATH: z.string().min(1),\n VAULT_MOUNT_POINT: z.string().default(\"release\"),\n});\n\nexport type VaultConfig = z.infer<typeof VaultConfigSchema>;\n","import fs from \"node:fs\";\nimport https from \"node:https\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport axios from \"axios\";\nimport { loadEnv } from \"vite\";\nimport { VaultConfigSchema } from \"../models/VaultConfig\";\nimport type { Resource } from \"i18next\";\nimport type { Plugin } from \"vite\";\n\nasync function fetchVaultSecrets(env: Record<string, string>): Promise<Record<string, string>> {\n const config = VaultConfigSchema.parse(env);\n const { VAULT_ADDRESS, VAULT_USERNAME, VAULT_PASSWORD, VAULT_SECRET_PATH, VAULT_MOUNT_POINT } =\n config;\n\n const client = axios.create({\n baseURL: VAULT_ADDRESS,\n httpsAgent: new https.Agent({ rejectUnauthorized: false }),\n });\n\n const { data: loginData } = await client.post(`/v1/auth/userpass/login/${VAULT_USERNAME}`, {\n password: VAULT_PASSWORD,\n });\n\n const { data: secretData } = await client.get(\n `/v1/${VAULT_MOUNT_POINT}/data/${VAULT_SECRET_PATH}`,\n {\n headers: { \"X-Vault-Token\": loginData.auth.client_token },\n },\n );\n\n const secrets = secretData?.data?.data;\n if (!secrets) throw new Error(\"No secrets found\");\n\n return Object.fromEntries(\n Object.entries(secrets).map(([key, value]) => [\n key,\n typeof value === \"string\" ? value : JSON.stringify(value),\n ]),\n );\n}\n\nasync function loadVaultSecrets(command: string): Promise<void> {\n if (command !== \"serve\") return;\n\n const env = loadEnv(\"development\", process.cwd(), \"\");\n if (!env.VAULT_ADDRESS) return;\n\n try {\n const secrets = await fetchVaultSecrets(env);\n Object.entries(secrets).forEach(([key, value]) => {\n process.env[key] = env[key]?.trim() ? env[key] : value;\n });\n } catch (e) {\n console.warn(\"[vite:wcz-layout] Vault failed:\", e instanceof Error ? e.message : e);\n }\n}\n\nfunction loadLocaleResources(localesPath: string, addWatchFile: (path: string) => void): Resource {\n if (!fs.existsSync(localesPath)) fs.mkdirSync(localesPath, { recursive: true });\n\n const enPath = path.join(localesPath, \"en.json\");\n if (!fs.existsSync(enPath)) fs.writeFileSync(enPath, JSON.stringify({}));\n\n const files = fs.readdirSync(localesPath);\n const resources: Resource = {};\n\n for (const file of files.filter((f) => f.endsWith(\".json\"))) {\n const lang = path.basename(file, \".json\");\n const filePath = path.join(localesPath, file);\n try {\n resources[lang] = { translation: JSON.parse(fs.readFileSync(filePath, \"utf-8\")) };\n } catch {\n resources[lang] = { translation: {} };\n }\n addWatchFile(filePath);\n }\n\n return resources;\n}\n\nconst require = createRequire(import.meta.url);\n\nfunction dayjsLocaleImports(resources: Resource): string {\n return Object.keys(resources)\n .map((lang) => lang.toLowerCase())\n .filter((lang) => {\n try {\n require.resolve(`dayjs/locale/${lang}.js`);\n return true;\n } catch {\n return false;\n }\n })\n .map((lang) => `import \"dayjs/locale/${lang}\";`)\n .join(\"\\n\");\n}\n\nfunction ensurePermissionsFile(\n permissionsPath: string,\n addWatchFile: (path: string) => void,\n): void {\n const dir = path.dirname(permissionsPath);\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n if (!fs.existsSync(permissionsPath)) {\n fs.writeFileSync(\n permissionsPath,\n 'import type { Permissions } from \"wcz-layout/models\";\\n\\n' +\n \"export const permissions = {\\n\" +\n ' admin: [\"wcz-developers\"],\\n' +\n \"} as const satisfies Permissions;\\n\",\n );\n }\n addWatchFile(permissionsPath);\n}\n\nfunction ensureScopesFile(scopesPath: string, addWatchFile: (path: string) => void): void {\n const dir = path.dirname(scopesPath);\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n if (!fs.existsSync(scopesPath)) {\n fs.writeFileSync(\n scopesPath,\n 'import type { Scopes } from \"wcz-layout/models\";\\n\\n' +\n \"export const scopes = {\\n\" +\n ' graph: \"User.Read\",\\n' +\n ' api: \"api://wistron.com/app-scope/access_as_user\",\\n' +\n \"} as const satisfies Scopes;\\n\",\n );\n }\n addWatchFile(scopesPath);\n}\n\nfunction loadManifest(\n manifestPath: string,\n addWatchFile: (path: string) => void,\n): { name: string } & Record<string, unknown> {\n addWatchFile(manifestPath);\n try {\n return JSON.parse(fs.readFileSync(manifestPath, \"utf-8\"));\n } catch {\n return { name: \"\" };\n }\n}\n\nexport function viteWczLayout(): Plugin {\n const virtualModuleId = \"virtual:wcz-layout\";\n const resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\n\n let localesPath: string;\n let permissionsPath: string;\n let scopesPath: string;\n let envPath: string;\n let manifestPath: string;\n\n return {\n name: \"vite:wcz-layout\",\n enforce: \"pre\",\n configResolved(resolvedConfig) {\n localesPath = path.resolve(resolvedConfig.root, \"src/lib/locales\");\n permissionsPath = path.resolve(resolvedConfig.root, \"src/lib/auth/permissions.ts\");\n scopesPath = path.resolve(resolvedConfig.root, \"src/lib/auth/scopes.ts\");\n envPath = path.resolve(resolvedConfig.root, \"src/env.ts\");\n manifestPath = path.resolve(resolvedConfig.root, \"public/manifest.json\");\n },\n async config(_, { command }) {\n await loadVaultSecrets(command);\n },\n configureServer(server) {\n const refresh = (filePath: string) => {\n if (\n filePath.includes(localesPath) ||\n filePath === permissionsPath ||\n filePath === scopesPath ||\n filePath === envPath ||\n filePath === manifestPath\n ) {\n const module = server.moduleGraph.getModuleById(resolvedVirtualModuleId);\n if (module) server.moduleGraph.invalidateModule(module);\n server.ws.send({ type: \"full-reload\", path: \"*\" });\n }\n };\n\n server.watcher.add([localesPath, permissionsPath, scopesPath, envPath, manifestPath]);\n server.watcher.on(\"add\", refresh);\n server.watcher.on(\"change\", refresh);\n server.watcher.on(\"unlink\", refresh);\n },\n resolveId(id) {\n if (id === virtualModuleId) return resolvedVirtualModuleId;\n return null;\n },\n load(id) {\n if (id !== resolvedVirtualModuleId) return null;\n\n const resources = loadLocaleResources(localesPath, this.addWatchFile.bind(this));\n ensurePermissionsFile(permissionsPath, this.addWatchFile.bind(this));\n ensureScopesFile(scopesPath, this.addWatchFile.bind(this));\n const manifest = loadManifest(manifestPath, this.addWatchFile.bind(this));\n\n const normalizedPermissionsPath = permissionsPath.split(path.sep).join(path.posix.sep);\n const normalizedScopesPath = scopesPath.split(path.sep).join(path.posix.sep);\n const normalizedEnvPath = envPath.split(path.sep).join(path.posix.sep);\n return `\n ${dayjsLocaleImports(resources)}\n export const resources = ${JSON.stringify(resources)};\n export const manifest = ${JSON.stringify(manifest)};\n export { permissions } from \"${normalizedPermissionsPath}\";\n export { scopes } from \"${normalizedScopesPath}\";\n export { serverEnv } from \"${normalizedEnvPath}\";\n `;\n },\n };\n}\n"],"mappings":";;;;;;;;AAEA,MAAaC,oBAAoBD,EAAEE,OAAO;CACxCC,eAAeH,EAAEI,IAAI;CACrBC,gBAAgBL,EAAEM,OAAO,CAAC,CAACC,IAAI,CAAC;CAChCC,gBAAgBR,EAAEM,OAAO,CAAC,CAACC,IAAI,CAAC;CAChCE,mBAAmBT,EAAEM,OAAO,CAAC,CAACC,IAAI,CAAC;CACnCG,mBAAmBV,EAAEM,OAAO,CAAC,CAACK,QAAQ,SAAS;AACjD,CAAC;;;ACED,eAAeY,kBAAkBC,KAA8D;CAE7F,MAAM,EAAEK,eAAeC,gBAAgBC,gBAAgBC,mBAAmBC,sBAD3Db,kBAAkBQ,MAAMJ,GAErCG;CAEF,MAAMO,SAAShB,MAAMiB,OAAO;EAC1BC,SAASP;EACTQ,YAAY,IAAItB,MAAMuB,MAAM,EAAEC,oBAAoB,MAAM,CAAC;CAC3D,CAAC;CAED,MAAM,EAAEC,MAAMC,cAAc,MAAMP,OAAOQ,KAAK,2BAA2BZ,kBAAkB,EACzFa,UAAUZ,eACZ,CAAC;CAED,MAAM,EAAES,MAAMI,eAAe,MAAMV,OAAOW,IACxC,OAAOZ,kBAAiB,QAASD,qBACjC,EACEc,SAAS,EAAE,iBAAiBL,UAAUM,KAAKC,aAAa,EAC1D,CACF;CAEA,MAAMC,UAAUL,YAAYJ,MAAMA;CAClC,IAAI,CAACS,SAAS,MAAM,IAAIC,MAAM,kBAAkB;CAEhD,OAAOC,OAAOC,YACZD,OAAOE,QAA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yBAAyB,OAAO;GAE3C,MAAM7B,YAAYX,oBAAoBC,aAAa,KAAKC,aAAa8D,KAAK,IAAI,CAAC;GAC/EnC,sBAAsBC,iBAAiB,KAAK5B,aAAa8D,KAAK,IAAI,CAAC;GACnE/B,iBAAiBC,YAAY,KAAKhC,aAAa8D,KAAK,IAAI,CAAC;GACzD,MAAMC,WAAW9B,aAAaC,cAAc,KAAKlC,aAAa8D,KAAK,IAAI,CAAC;GAExE,MAAME,4BAA4BpC,gBAAgBqC,MAAMvH,KAAKwH,GAAG,CAAC,CAAC7D,KAAK3D,KAAKyH,MAAMD,GAAG;GACrF,MAAME,uBAAuBpC,WAAWiC,MAAMvH,KAAKwH,GAAG,CAAC,CAAC7D,KAAK3D,KAAKyH,MAAMD,GAAG;GAC3E,MAAMG,oBAAoB9B,QAAQ0B,MAAMvH,KAAKwH,GAAG,CAAC,CAAC7D,KAAK3D,KAAKyH,MAAMD,GAAG;GACrE,OAAO;cACC3C,mBAAmBd,SAAS,EAAC;uCACJvB,KAAKC,UAAUsB,SAAS,EAAC;sCAC1BvB,KAAKC,UAAU4E,QAAQ,EAAC;2CACnBC,0BAAyB;sCAC9BI,qBAAoB;yCACjBC,kBAAiB;;EAEtD;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wcz-layout",
3
- "version": "9.7.0",
3
+ "version": "10.0.0",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "tanstack-intent"
@@ -63,42 +63,40 @@
63
63
  },
64
64
  "scripts": {
65
65
  "dev": "vp dev",
66
- "check": "vp check",
67
66
  "typecheck": "tsc --noEmit --watch --preserveWatchOutput",
68
67
  "build": "vp pack",
69
68
  "prepublishOnly": "npm run build"
70
69
  },
71
70
  "dependencies": {
72
- "@azure/msal-node": "^5.5.0",
73
71
  "@t3-oss/env-core": "^0.13.11",
74
- "i18next": "^26.3.6",
72
+ "i18next": "^26.4.2",
75
73
  "i18next-browser-languagedetector": "^8.2.1",
76
- "jose": "^6.2.9",
77
- "react-dropzone": "^20.1.0",
78
- "react-i18next": "^17.0.11",
79
- "react-intersection-observer": "^11.0.0",
74
+ "jose": "^6.2.12",
75
+ "react-dropzone": "^20.1.1",
76
+ "react-i18next": "^17.0.14",
77
+ "react-intersection-observer": "^11.0.1",
80
78
  "react-number-format": "^5.4.5",
81
79
  "tus-js-client": "^4.3.1",
82
80
  "uuidv7": "^1.2.1"
83
81
  },
84
82
  "devDependencies": {
85
83
  "@arethetypeswrong/core": "^0.18.5",
86
- "@rolldown/plugin-babel": "^0.2.3",
87
- "@tanstack/ai": "^0.44.1",
88
- "@tanstack/ai-client": "^0.23.2",
89
- "@tanstack/ai-openai": "^0.19.0",
90
- "@tanstack/highlight": "^0.0.10",
91
- "@tanstack/react-table": "^9.1.2",
84
+ "@rolldown/plugin-babel": "^0.2.4",
85
+ "@tanstack/ai": "^0.54.0",
86
+ "@tanstack/ai-client": "^0.31.1",
87
+ "@tanstack/ai-openai": "^0.22.6",
88
+ "@tanstack/highlight": "^0.1.0",
89
+ "@tanstack/intent": "^0.4.0",
92
90
  "@types/node": "^24.10.13",
93
- "@types/react": "^19.2.18",
94
- "@types/react-dom": "^19.2.4",
95
- "@vitejs/plugin-react": "^6.0.5",
91
+ "@types/react": "^19.3.0",
92
+ "@types/react-dom": "^19.3.0",
93
+ "@vitejs/plugin-react": "^6.1.1",
96
94
  "babel-plugin-react-compiler": "^1.0.0",
97
95
  "nitro": "npm:nitro-nightly@latest",
98
- "publint": "^0.3.23",
96
+ "publint": "^0.3.24",
99
97
  "typescript": "^7.0.2",
100
- "vite": "npm:@voidzero-dev/vite-plus-core@0.2.9",
101
- "vite-plus": "0.2.9"
98
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.3.1",
99
+ "vite-plus": "0.3.1"
102
100
  },
103
101
  "peerDependencies": {
104
102
  "@emotion/cache": "11.x",
@@ -106,15 +104,17 @@
106
104
  "@emotion/styled": "11.x",
107
105
  "@mui/icons-material": "9.x",
108
106
  "@mui/material": "9.x",
109
- "@mui/x-data-grid-premium": "9.x",
110
- "@mui/x-date-pickers-pro": "9.x",
107
+ "@mui/x-date-pickers": "9.x",
111
108
  "@tanstack/query-db-collection": "1.x",
112
109
  "@tanstack/react-db": "0.x",
113
110
  "@tanstack/react-form": "1.x",
111
+ "@tanstack/react-hotkeys": "0.x",
114
112
  "@tanstack/react-query": "5.x",
115
113
  "@tanstack/react-router": "1.x",
116
114
  "@tanstack/react-router-ssr-query": "1.x",
117
115
  "@tanstack/react-start": "1.x",
116
+ "@tanstack/react-table": "9.x",
117
+ "@tanstack/react-virtual": "3.x",
118
118
  "axios": "1.x",
119
119
  "dayjs": "1.x",
120
120
  "react": "19.x",
@@ -122,7 +122,7 @@
122
122
  "zod": "4.x"
123
123
  },
124
124
  "overrides": {
125
- "vite": "npm:@voidzero-dev/vite-plus-core@0.2.9"
125
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.3.1"
126
126
  },
127
127
  "packageManager": "npm@12.0.2"
128
128
  }