wcz-layout 9.6.2 → 9.6.4
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/{Employee-iepWeWhO.d.mts → Employee-DbdStvU0.d.mts} +3 -3
- package/dist/auth.d.mts +1 -6
- package/dist/auth.mjs +6 -6
- package/dist/{authMiddleware-CKD6lG9v.mjs → authMiddleware-CjKA7C0W.mjs} +2 -3
- package/dist/{authMiddleware-CKD6lG9v.mjs.map → authMiddleware-CjKA7C0W.mjs.map} +1 -1
- package/dist/components.mjs +1 -1
- package/dist/data/client.d.mts +57 -57
- package/dist/data/client.mjs +2 -2
- package/dist/data/server.d.mts +1 -1
- package/dist/data/server.mjs +2 -2
- package/dist/data/server.mjs.map +1 -1
- package/dist/{entra-47nBhMK-.mjs → entra-DFhYO6Sj.mjs} +3 -3
- package/dist/entra-DFhYO6Sj.mjs.map +1 -0
- package/dist/{file-DczAUT9u.mjs → file--l_efzg-.mjs} +5 -6
- package/dist/{file-DczAUT9u.mjs.map → file--l_efzg-.mjs.map} +1 -1
- package/dist/{file-D1MfHsnw.mjs → file-BDeY2atB.mjs} +6 -11
- package/dist/file-BDeY2atB.mjs.map +1 -0
- package/dist/hooks.d.mts +3 -0
- package/dist/hooks.mjs +6 -3
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +73 -49
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.mjs +1 -1
- package/dist/middleware.mjs.map +1 -1
- package/dist/models.d.mts +1 -1
- package/dist/models.mjs +1 -1
- package/dist/models.mjs.map +1 -1
- package/dist/{msalServer-B3iBsafS.mjs → msalServer-CqLXgWpO.mjs} +3 -17
- package/dist/msalServer-CqLXgWpO.mjs.map +1 -0
- package/dist/{peoplesoft-4pOmhLn5.d.mts → peoplesoft-D4w8d4s1.d.mts} +2 -2
- package/dist/{peoplesoft-BPRwAaaM.mjs → peoplesoft-DqO-9g-4.mjs} +2 -2
- package/dist/peoplesoft-DqO-9g-4.mjs.map +1 -0
- package/dist/{utils-CqVAK5F8.mjs → utils-A_Lzklis.mjs} +27 -4
- package/dist/utils-A_Lzklis.mjs.map +1 -0
- package/dist/utils.mjs +4 -2
- package/dist/vite.mjs +13 -0
- package/dist/vite.mjs.map +1 -1
- package/package.json +127 -126
- package/skills/client-db/SKILL.md +1 -1
- package/skills/dialogs/SKILL.md +0 -1
- package/skills/general/SKILL.md +8 -9
- package/skills/start/SKILL.md +1 -1
- package/skills/start/steps/06-entra-setup.md +11 -14
- package/dist/entra-47nBhMK-.mjs.map +0 -1
- package/dist/env-CoveIivr.mjs +0 -30
- package/dist/env-CoveIivr.mjs.map +0 -1
- package/dist/file-D1MfHsnw.mjs.map +0 -1
- package/dist/msalServer-B3iBsafS.mjs.map +0 -1
- package/dist/peoplesoft-BPRwAaaM.mjs.map +0 -1
- package/dist/utils-CqVAK5F8.mjs.map +0 -1
- package/dist/utils-D39-w_ij.mjs +0 -4
- package/skills/notifications/SKILL.md +0 -43
package/skills/dialogs/SKILL.md
CHANGED
|
@@ -12,7 +12,6 @@ description: "Use when: creating or modifying alert, confirm, or custom dialogs.
|
|
|
12
12
|
- Custom dialogs must receive `DialogProps<T>`.
|
|
13
13
|
- Keep dialogs colocated inside `routes/feature/-components` when feature-specific.
|
|
14
14
|
- Always use translation; add new keys for feature-specific messages.
|
|
15
|
-
- Use notifications for lightweight feedback; dialogs when the user must decide or acknowledge.
|
|
16
15
|
|
|
17
16
|
## File Placement
|
|
18
17
|
|
package/skills/general/SKILL.md
CHANGED
|
@@ -10,7 +10,7 @@ description: "Use ALWAYS for project-wide conventions and coding standards. It d
|
|
|
10
10
|
Favor the established platform before introducing custom code or a new dependency:
|
|
11
11
|
|
|
12
12
|
- **TanStack ecosystem:** Use TanStack Start, Router, DB, Form, and Query for their respective application concerns. Consider adjacent TanStack libraries when they directly fit the feature: TanStack AI for AI interactions, TanStack Virtual for large virtualized lists, TanStack Pacer for debouncing, throttling, rate limiting, queuing, and batching, and TanStack Hotkeys for type-safe keyboard shortcuts.
|
|
13
|
-
- **Vite+:** Use Vite+ for the development server,
|
|
13
|
+
- **Vite+:** Use Vite+ for the development server, formatting, linting and testing.
|
|
14
14
|
- **Material UI:** Use Material UI for interface components and icons. When an advanced capability is needed, consider MUI X Charts for data visualization, Tree View for hierarchical data, Scheduler for calendars and timelines, and Chat for AI-powered conversations.
|
|
15
15
|
|
|
16
16
|
Before implementing an external library feature, consult the current documentation through Context7 MCP. Do not add a dependency when one of these platform libraries already covers the requirement.
|
|
@@ -30,12 +30,13 @@ Before implementing an external library feature, consult the current documentati
|
|
|
30
30
|
|
|
31
31
|
## File Organization
|
|
32
32
|
|
|
33
|
-
Use this ownership model for new application code. Keep feature-specific code close to its route; promote it to a root directory only when it is shared across multiple features.
|
|
33
|
+
Use this ownership model for new application code. Keep feature-specific code close to its route; promote it to a root directory only when it is shared across multiple features. One database table = one file per layer: every `<table>` slot below is the same singular camelCase table name, never grouped with its parent or child tables.
|
|
34
34
|
|
|
35
35
|
```txt
|
|
36
36
|
src/ # client-first architecture
|
|
37
37
|
├── components/ # shared components across multiple routes
|
|
38
38
|
├── db-collections/ # TanStack DB collections
|
|
39
|
+
│ └── <table>Collection.ts
|
|
39
40
|
├── hooks/ # shared hooks across multiple routes
|
|
40
41
|
├── lib/ # isomorphic/shared logic usable by client and server
|
|
41
42
|
│ ├── auth/
|
|
@@ -45,6 +46,7 @@ src/ # client-first architecture
|
|
|
45
46
|
│ │ ├── cs.json
|
|
46
47
|
│ │ └── en.json
|
|
47
48
|
│ └── schemas/ # shared Zod schemas
|
|
49
|
+
│ └── <table>.ts
|
|
48
50
|
├── routes/ # TanStack Router file-based routing
|
|
49
51
|
│ ├── __root.tsx
|
|
50
52
|
│ ├── index.tsx
|
|
@@ -57,18 +59,15 @@ src/ # client-first architecture
|
|
|
57
59
|
│ └── $id.tsx
|
|
58
60
|
├── server/ # server-only code
|
|
59
61
|
│ ├── actions/
|
|
60
|
-
│ │ └──
|
|
62
|
+
│ │ └── <table>.ts
|
|
61
63
|
│ ├── db/
|
|
62
64
|
│ │ ├── migrations/
|
|
63
65
|
│ │ ├── schemas/ # Drizzle schemas
|
|
64
|
-
│ │ │
|
|
66
|
+
│ │ │ ├── <table>.ts
|
|
67
|
+
│ │ │ └── relations.ts
|
|
65
68
|
│ │ └── index.ts
|
|
66
69
|
│ └── middleware/
|
|
67
70
|
│ └── databaseMiddleware.ts
|
|
68
71
|
└── types/
|
|
72
|
+
tests/ # test files
|
|
69
73
|
```
|
|
70
|
-
|
|
71
|
-
## Development And Validation
|
|
72
|
-
|
|
73
|
-
- Use only port 3000 for local development browser access.
|
|
74
|
-
- Do not build the application for routine validation; it is slow. Check TypeScript errors instead.
|
package/skills/start/SKILL.md
CHANGED
|
@@ -12,7 +12,7 @@ You are an AI assistant helping a developer bootstrap a new project from this te
|
|
|
12
12
|
## Execution Rules
|
|
13
13
|
|
|
14
14
|
- Execute steps in order. Read **only** the current step file.
|
|
15
|
-
-
|
|
15
|
+
- Run terminal commands and browser actions yourself. When a step needs user input, ask only the required question through the prescribed question tool, consume the answer, and resume in the same turn.
|
|
16
16
|
- Do not skip ahead or batch multiple steps.
|
|
17
17
|
- When a step has branches (yes/no), follow only the matching branch.
|
|
18
18
|
- To read a step, open the linked file in the **File** column directly.
|
|
@@ -14,9 +14,6 @@ once you have signed in" and stopping ends the session, and nothing resumes
|
|
|
14
14
|
it. A page that renders blank is usually still loading or still on the
|
|
15
15
|
sign-in gate — keep polling instead of reporting it as a problem.
|
|
16
16
|
|
|
17
|
-
When a part's browser work is finished — the ITSR request submitted, the Entra
|
|
18
|
-
configuration done — close the browser session before moving on.
|
|
19
|
-
|
|
20
17
|
---
|
|
21
18
|
|
|
22
19
|
## Part A — Application Creation
|
|
@@ -42,7 +39,7 @@ Ask via **AskUserQuestion**: **"Is the Entra ID application already created for
|
|
|
42
39
|
|
|
43
40
|
When the portal needs sign-in, poll until the ITSR request form is visible and continue — do not end the turn.
|
|
44
41
|
|
|
45
|
-
Once the request is submitted, **skip Part B
|
|
42
|
+
Once the request is submitted, close the ITSR browser session, **skip Part B**, and continue to the next step — the applications do not exist until the request is approved.
|
|
46
43
|
|
|
47
44
|
---
|
|
48
45
|
|
|
@@ -51,7 +48,7 @@ Once the request is submitted, **skip Part B** and continue to the next step —
|
|
|
51
48
|
Ask via **AskUserQuestion**: **"Have you configured the Entra ID application settings?"** — options `Yes` / `No`.
|
|
52
49
|
|
|
53
50
|
- **Yes** → skip to **Credentials** below.
|
|
54
|
-
- **No** → Open `https://entra.microsoft.com/` in the
|
|
51
|
+
- **No** → Open `https://entra.microsoft.com/` and complete every Part B step in one uninterrupted run. Reuse this signed-in tab and the portal's own navigation; for slow controls, poll and re-read the current blade instead of reloading or opening another tab. Derive every value from the app name and the fixed values below. Do not ask for owners; the owner list is fixed. Ask only before an explicitly user-approved irreversible action.
|
|
55
52
|
|
|
56
53
|
Gradually write all the data to `.env.local` with exactly these keys — keep any values already set by earlier steps (if this file does not exist, create it). If empty - fill `SESSION_SECRET` with a freshly generated value, and leave the rest empty until you know the values:
|
|
57
54
|
|
|
@@ -64,7 +61,7 @@ SESSION_SECRET=<generated-64-char-hex>
|
|
|
64
61
|
|
|
65
62
|
**Left navigation: App Registrations:**
|
|
66
63
|
|
|
67
|
-
1. Ask via **AskUserQuestion**
|
|
64
|
+
1. Use the application's display name already present in chat context. Ask via **AskUserQuestion** only if it is genuinely absent; otherwise open **App registrations**, filter by the exact name, and click the matching row. Its **Overview** page shows **Application (client) ID** and **Directory (tenant) ID** — read both and write them to `.env.local` as `ENTRA_CLIENT_ID` and `ENTRA_TENANT_ID` straight away, before configuring anything else. Never ask the user for these two values. Leave `ENTRA_CLIENT_SECRET` empty only until the client secret is created in step 3.
|
|
68
65
|
2. **Authentication (Preview)** — the left-nav item is named that, and it opens on the **Redirect URI configuration** tab. Three URIs are needed, where `<app-name>` is the `name` from `package.json`:
|
|
69
66
|
- `http://localhost:3000/auth/callback`
|
|
70
67
|
- `https://<app-name>.wcz-sat-qas-01.k8s.wistron.com/auth/callback`
|
|
@@ -77,17 +74,17 @@ SESSION_SECRET=<generated-64-char-hex>
|
|
|
77
74
|
c. The list now shows a **Web** group row with an **Edit** link. Click **Edit**: the panel lists the saved URIs plus one empty row, and filling a row spawns another empty row below it. Add the `qas` and `prd` URIs, then click **Configure**.
|
|
78
75
|
d. Verify all three appear as Web rows in the list.
|
|
79
76
|
|
|
80
|
-
3. **Certificates & secrets:** open the **Client secrets** tab → **+ New client secret**. Leave **Description** empty and set **Expires** to `730 days (24 months)` — always these values, never ask the user — then click **Add**.
|
|
77
|
+
3. **Certificates & secrets:** open the **Client secrets** tab → **+ New client secret**. Leave **Description** empty and set **Expires** to `730 days (24 months)` — always these values, never ask the user — then click **Add**. Read the new row's **Secret ID** and write it into `ENTRA_CLIENT_SECRET` in `.env.local` before navigating anywhere else. Never print the secret ID in chat or in a commit.
|
|
81
78
|
4. **Token configuration:** click **Add groups claim**. In the panel tick **Security groups** only, then expand each of **ID**, **Access**, and **SAML** in "Customize token properties by type" and switch the radio from `Group ID` to `sAMAccountName`. Click **Add**. The list should then show a `groups` claim with token type `ID, Access, SAML`.
|
|
82
|
-
5. **Expose an API:** next to **Application ID URI** click **Add** (or **Edit** if one exists). The portal prefills `api://<client-id>` — replace it with `api://wistron.com/<app-name>` (for `wh-fg-preparation`: `api://wistron.com/wh-fg-preparation`) and **Save**. Then **+ Add a scope** named `access_as_user`, set **Who can consent?** to `Admins and users`, and fill only the two required fields — **Admin consent display name** and **Admin consent description**. Leave the user consent fields empty (optional) and **State** on `Enabled`, then click **Add scope**.
|
|
83
|
-
6. **Owners:**
|
|
79
|
+
5. **Expose an API:** next to **Application ID URI** click **Add** (or **Edit** if one exists). The portal prefills `api://<client-id>` — replace it with `api://wistron.com/<app-name>` (for `wh-fg-preparation`: `api://wistron.com/wh-fg-preparation`) and **Save**. Then **+ Add a scope** named `access_as_user`, set **Who can consent?** to `Admins and users`, and fill only the two required fields — **Admin consent display name** and **Admin consent description**. Leave the user consent fields empty (optional) and **State** on `Enabled`, then click **Add scope**. Do not navigate away or report progress as complete until the saved `api://wistron.com/<app-name>` URI and enabled `access_as_user` scope are both visible in the portal.
|
|
80
|
+
6. **Owners:** first read the current table once. Add only missing people from this fixed list: Radim Staworowski, Martin Husar, Dalibor Homola, Patrik Lorenc, Tien Thanh Tran, Sebastian Ondruska. In the picker, search each missing full name, wait for the exact name and Wistron UPN match, select it, then replace the search text with the next name without closing the picker. Submit the batch once and verify all six names in the refreshed table.
|
|
84
81
|
7. **Manifest:** the page opens the **Microsoft Graph App Manifest (New)** JSON in a code editor. Inside the `api` object change `"acceptMappedClaims": null` to `true` and `"requestedAccessTokenVersion": null` to `2`, then click **Save**.
|
|
85
82
|
|
|
86
83
|
**Left navigation: Enterprise Applications:**
|
|
87
84
|
|
|
88
|
-
1. Open **Enterprise apps → All applications** and search
|
|
89
|
-
2. **Owners:** repeat the owner process from App Registrations
|
|
90
|
-
3. **Single sign-on** opens as **OIDC-based Sign-on**; there is no SAML wizard.
|
|
85
|
+
1. Open **Enterprise apps → All applications** and search with the exact display name already resolved in App Registrations; do not ask for it again.
|
|
86
|
+
2. **Owners:** repeat the batched owner process from App Registrations. Inspect the table once, keep the picker open while searching and selecting every missing exact Wistron record, and confirm the selected-user count increments after each selection. Click **Select** once, wait for `Owner assignment succeeded`, then verify all six names in the refreshed table. The toolbar and table may load after the heading; keep polling until both appear.
|
|
87
|
+
3. **Single sign-on** opens as **OIDC-based Sign-on**; there is no SAML wizard. Wait for the embedded OIDC content, then click the visible **Edit** pencil under **② Attributes & Claims**. If its reference is stale, re-read this page and click the new reference. Ignore background `400`/`403` console messages while the requested controls remain usable. Confirm the claims list already holds `groups → user.groups`, then add each missing row with **+ Add new claim**:
|
|
91
88
|
|
|
92
89
|
| Claim Name | Source Attribute |
|
|
93
90
|
| ------------------ | --------------------------- |
|
|
@@ -96,6 +93,6 @@ SESSION_SECRET=<generated-64-char-hex>
|
|
|
96
93
|
| `employeeCategory` | `user.extensionattribute13` |
|
|
97
94
|
| `companyName` | `user.companyname` |
|
|
98
95
|
|
|
99
|
-
For each one: type the claim name in **Name** and **Source** on `Attribute
|
|
96
|
+
For each one: type the claim name in **Name** and leave **Source** on `Attribute`. **Source attribute** is a dropdown, not a text field: click it, use its filter input when needed, and select the plain unquoted attribute option (never the quoted constant). Click **Save**, then wait for the editor to close and verify the exact name/value row in **Additional claims** before adding the next claim. During the close transition the old form may briefly mark every field invalid even though the save succeeded; the refreshed claims row or `Successfully saved SSO user claims` notification is authoritative. Leave **Claim conditions** and **Advanced SAML claims options** untouched. Finish by verifying all four rows plus the existing `groups → user.groups` row in one claims-table read.
|
|
100
97
|
|
|
101
|
-
4.
|
|
98
|
+
4. After all owners and claims are verified, close the Entra browser session and report Part B complete.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entra-47nBhMK-.mjs","names":["ConfidentialClientApplication","CryptoProvider","InteractionRequiredAuthError","ServerError","TokenPayload","serverEnv","LOGIN_SCOPES","ENTRA_AUTHORITY","ENTRA_TENANT_ID","cryptoProvider","createConfidentialClient","auth","clientId","ENTRA_CLIENT_ID","clientSecret","ENTRA_CLIENT_SECRET","authority","extractRefreshToken","client","cache","JSON","parse","getTokenCache","serialize","RefreshToken","Record","secret","Object","values","buildAuthCodeUrl","opts","redirectUri","state","codeChallenge","Promise","getAuthCodeUrl","scopes","responseMode","codeChallengeMethod","exchangeCodeForSession","code","codeVerifier","refreshToken","claims","result","acquireTokenByCode","Error","idTokenClaims","SessionExpiredError","acquireDelegatedToken","ReadonlyArray","accessToken","acquireTokenByRefreshToken","forceCache","error","errorCode","message","buildLogoutUrl","postLogoutRedirectUri","base","encodeURIComponent"],"sources":["../src/lib/auth/entra.ts"],"sourcesContent":["import {\r\n ConfidentialClientApplication,\r\n CryptoProvider,\r\n InteractionRequiredAuthError,\r\n ServerError,\r\n} from \"@azure/msal-node\";\r\nimport type { TokenPayload } from \"~/models/TokenPayload\";\r\nimport { serverEnv } from \"~/env\";\r\n\r\n/**\r\n * Scopes requested during the interactive login. `offline_access` yields the\r\n * refresh token that the session is built around; `User.Read` lets us read the\r\n * user's Graph profile (e.g. avatar). Resource API scopes (file, approval, …) are\r\n * acquired on demand via {@link acquireDelegatedToken} using the multi-resource\r\n * refresh token.\r\n */\r\nexport const LOGIN_SCOPES = [\"openid\", \"profile\", \"offline_access\", \"User.Read\"];\r\n\r\n/** Entra authority for this tenant. */\r\nexport const ENTRA_AUTHORITY = `https://login.microsoftonline.com/${serverEnv.ENTRA_TENANT_ID}`;\r\n\r\n/** Shared across login/callback/refresh calls — stateless and cheap to reuse. */\r\nexport const cryptoProvider = new CryptoProvider();\r\n\r\n/**\r\n * Creates a confidential client (no persistent cache plugin).\r\n *\r\n * The interactive/refresh flows below deliberately use a FRESH client per token\r\n * operation rather than a singleton: the client's in-memory cache then holds only\r\n * that operation's tokens, so {@link extractRefreshToken} reads the correct user's\r\n * refresh token — a shared client would accumulate (and leak) every user's tokens.\r\n * Persisting just the refresh token (not the whole multi-KB MSAL cache) is what\r\n * keeps the session in a small cookie with no server-side token store.\r\n */\r\nexport const createConfidentialClient = (): ConfidentialClientApplication =>\r\n new ConfidentialClientApplication({\r\n auth: {\r\n clientId: serverEnv.ENTRA_CLIENT_ID,\r\n clientSecret: serverEnv.ENTRA_CLIENT_SECRET,\r\n authority: ENTRA_AUTHORITY,\r\n },\r\n });\r\n\r\n/**\r\n * Pulls the refresh-token secret out of a client's in-memory MSAL cache. MSAL\r\n * intentionally hides refresh tokens, so reading the serialized cache is the only\r\n * way to persist just the RT (instead of the whole cache) in the session cookie.\r\n */\r\nfunction extractRefreshToken(client: ConfidentialClientApplication): string | undefined {\r\n const cache = JSON.parse(client.getTokenCache().serialize()) as {\r\n RefreshToken?: Record<string, { secret?: string }>;\r\n };\r\n return Object.values(cache.RefreshToken ?? {})[0]?.secret;\r\n}\r\n\r\n/** First leg of the auth-code flow: the URL to redirect the browser to. */\r\nexport function buildAuthCodeUrl(opts: {\r\n redirectUri: string;\r\n state: string;\r\n codeChallenge: string;\r\n}): Promise<string> {\r\n return createConfidentialClient().getAuthCodeUrl({\r\n scopes: LOGIN_SCOPES,\r\n redirectUri: opts.redirectUri,\r\n responseMode: \"query\",\r\n state: opts.state,\r\n codeChallenge: opts.codeChallenge,\r\n codeChallengeMethod: \"S256\",\r\n });\r\n}\r\n\r\n/**\r\n * Second leg of the auth-code flow: exchange the code for tokens, returning the\r\n * refresh token and the id-token claims to persist in the session.\r\n */\r\nexport async function exchangeCodeForSession(opts: {\r\n code: string;\r\n redirectUri: string;\r\n codeVerifier: string;\r\n}): Promise<{ refreshToken: string; claims: TokenPayload }> {\r\n const client = createConfidentialClient();\r\n const result = await client.acquireTokenByCode({\r\n code: opts.code,\r\n scopes: LOGIN_SCOPES,\r\n redirectUri: opts.redirectUri,\r\n codeVerifier: opts.codeVerifier,\r\n });\r\n\r\n const refreshToken = extractRefreshToken(client);\r\n if (!refreshToken)\r\n throw new Error(\"No refresh token returned (is the offline_access scope granted?)\");\r\n\r\n return { refreshToken, claims: (result.idTokenClaims ?? {}) as TokenPayload };\r\n}\r\n\r\n/**\r\n * Acquires a delegated access token for `scopes` from the stored refresh token.\r\n * Entra rotates the refresh token on each use, so the (possibly new) refresh\r\n * token is returned for the caller to persist. Throws when the refresh token is\r\n * expired/revoked and interaction is required.\r\n */\r\n/** The refresh token is expired/revoked — the user must sign in interactively. */\r\nexport class SessionExpiredError extends Error {}\r\n\r\nexport async function acquireDelegatedToken(opts: {\r\n refreshToken: string;\r\n scopes: ReadonlyArray<string>;\r\n}): Promise<{ accessToken: string; refreshToken: string }> {\r\n const client = createConfidentialClient();\r\n let result;\r\n try {\r\n result = await client.acquireTokenByRefreshToken({\r\n refreshToken: opts.refreshToken,\r\n scopes: [...opts.scopes],\r\n forceCache: true,\r\n });\r\n } catch (error) {\r\n // Revocation, inactivity expiry (AADSTS70008/700082/50173) and Conditional\r\n // Access sign-in frequency (AADSTS70043) all surface as interaction-required\r\n // or invalid_grant — the session is dead, only an interactive login helps.\r\n if (\r\n error instanceof InteractionRequiredAuthError ||\r\n (error instanceof ServerError && error.errorCode === \"invalid_grant\")\r\n )\r\n throw new SessionExpiredError(error.message);\r\n throw error;\r\n }\r\n if (!result) throw new Error(\"Failed to acquire token from refresh token\");\r\n\r\n return {\r\n accessToken: result.accessToken,\r\n refreshToken: extractRefreshToken(client) ?? opts.refreshToken,\r\n };\r\n}\r\n\r\n/** Entra's front-channel logout endpoint, which clears the user's IdP session. */\r\nexport function buildLogoutUrl(postLogoutRedirectUri: string): string {\r\n const base = `${ENTRA_AUTHORITY}/oauth2/v2.0/logout`;\r\n return `${base}?post_logout_redirect_uri=${encodeURIComponent(postLogoutRedirectUri)}`;\r\n}\r\n"],"mappings":";;;;;;;;;;AAgBA,MAAaM,eAAe;CAAC;CAAU;CAAW;CAAkB;AAAW;;AAG/E,MAAaC,kBAAkB,qCAAqCF,UAAUG;;AAG9E,MAAaC,iBAAiB,IAAIR,eAAe;;;;;;;;;;;AAYjD,MAAaS,iCACX,IAAIV,8BAA8B,EAChCW,MAAM;CACJC,UAAUP,UAAUQ;CACpBC,cAAcT,UAAUU;CACxBC,WAAWT;AACb,EACF,CAAC;;;;;;AAOH,SAASU,oBAAoBC,QAA2D;CACtF,MAAMC,QAAQC,KAAKC,MAAMH,OAAOI,cAAc,CAAC,CAACC,UAAU,CAAC;CAG3D,OAAOI,OAAOC,OAAOT,MAAMK,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,EAAEE;AACrD;;AAGA,SAAgBG,iBAAiBC,MAIb;CAClB,OAAOpB,yBAAyB,CAAC,CAACyB,eAAe;EAC/CC,QAAQ9B;EACRyB,aAAaD,KAAKC;EAClBM,cAAc;EACdL,OAAOF,KAAKE;EACZC,eAAeH,KAAKG;EACpBK,qBAAqB;CACvB,CAAC;AACH;;;;;AAMA,eAAsBC,uBAAuBT,MAIe;CAC1D,MAAMZ,SAASR,yBAAyB;CACxC,MAAMkC,SAAS,MAAM1B,OAAO2B,mBAAmB;EAC7CL,MAAMV,KAAKU;EACXJ,QAAQ9B;EACRyB,aAAaD,KAAKC;EAClBU,cAAcX,KAAKW;CACrB,CAAC;CAED,MAAMC,eAAezB,oBAAoBC,MAAM;CAC/C,IAAI,CAACwB,cACH,MAAM,IAAII,MAAM,kEAAkE;CAEpF,OAAO;EAAEJ;EAAcC,QAASC,OAAOG,iBAAiB,CAAC;CAAmB;AAC9E;;;;;;;;AASA,IAAaC,sBAAb,cAAyCF,MAAM,CAAA;AAE/C,eAAsBG,sBAAsBnB,MAGe;CACzD,MAAMZ,SAASR,yBAAyB;CACxC,IAAIkC;CACJ,IAAI;EACFA,SAAS,MAAM1B,OAAOkC,2BAA2B;GAC/CV,cAAcZ,KAAKY;GACnBN,QAAQ,CAAC,GAAGN,KAAKM,MAAM;GACvBiB,YAAY;EACd,CAAC;CACH,SAASC,OAAO;EAId,IACEA,iBAAiBpD,gCAChBoD,iBAAiBnD,eAAemD,MAAMC,cAAc,iBAErD,MAAM,IAAIP,oBAAoBM,MAAME,OAAO;EAC7C,MAAMF;CACR;CACA,IAAI,CAACV,QAAQ,MAAM,IAAIE,MAAM,4CAA4C;CAEzE,OAAO;EACLK,aAAaP,OAAOO;EACpBT,cAAczB,oBAAoBC,MAAM,KAAKY,KAAKY;CACpD;AACF;;AAGA,SAAgBe,eAAeC,uBAAuC;CAEpE,OAAO,GAAGC,GADMpD,gBAAe,qBACjB,4BAA6BqD,mBAAmBF,qBAAqB;AACrF"}
|
package/dist/env-CoveIivr.mjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { z as z$1 } from "zod";
|
|
2
|
-
import { createEnv } from "@t3-oss/env-core";
|
|
3
|
-
createEnv({
|
|
4
|
-
clientPrefix: "VITE_",
|
|
5
|
-
client: { VITE_MUI_LICENSE_KEY: z$1.string() },
|
|
6
|
-
runtimeEnv: import.meta.env,
|
|
7
|
-
emptyStringAsUndefined: true
|
|
8
|
-
});
|
|
9
|
-
const serverEnv = createEnv({
|
|
10
|
-
server: {
|
|
11
|
-
ENTRA_CLIENT_ID: z$1.string().min(1),
|
|
12
|
-
ENTRA_TENANT_ID: z$1.string().min(1),
|
|
13
|
-
ENTRA_CLIENT_SECRET: z$1.string().min(1),
|
|
14
|
-
SESSION_SECRET: z$1.string().min(32),
|
|
15
|
-
FILE_BASE_URL: z$1.string().min(1).optional(),
|
|
16
|
-
APPROVAL_BASE_URL: z$1.string().min(1).optional(),
|
|
17
|
-
PEOPLESOFT_BASE_URL: z$1.string().min(1).optional(),
|
|
18
|
-
EMAIL_BASE_URL: z$1.string().min(1).optional(),
|
|
19
|
-
AI_BASE_URL: z$1.string().min(1).optional(),
|
|
20
|
-
AI_SUBSCRIPTION_KEY: z$1.string().min(1).optional(),
|
|
21
|
-
AI_CLIENT_ID: z$1.string().min(1).optional(),
|
|
22
|
-
AI_CLIENT_SECRET: z$1.string().min(1).optional()
|
|
23
|
-
},
|
|
24
|
-
runtimeEnv: process.env,
|
|
25
|
-
emptyStringAsUndefined: true
|
|
26
|
-
});
|
|
27
|
-
//#endregion
|
|
28
|
-
export { serverEnv as t };
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=env-CoveIivr.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env-CoveIivr.mjs","names":["createEnv","z","clientEnv","clientPrefix","client","VITE_MUI_LICENSE_KEY","string","runtimeEnv","import","meta","env","emptyStringAsUndefined","serverEnv","server","ENTRA_CLIENT_ID","min","ENTRA_TENANT_ID","ENTRA_CLIENT_SECRET","SESSION_SECRET","FILE_BASE_URL","optional","APPROVAL_BASE_URL","PEOPLESOFT_BASE_URL","EMAIL_BASE_URL","AI_BASE_URL","AI_SUBSCRIPTION_KEY","AI_CLIENT_ID","AI_CLIENT_SECRET","process"],"sources":["../src/env.ts"],"sourcesContent":["import { createEnv } from \"@t3-oss/env-core\";\nimport { z } from \"zod\";\n\nexport const clientEnv = createEnv({\n clientPrefix: \"VITE_\",\n client: {\n VITE_MUI_LICENSE_KEY: z.string(),\n },\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 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 AI_CLIENT_ID: z.string().min(1).optional(),\n AI_CLIENT_SECRET: z.string().min(1).optional(),\n },\n runtimeEnv: process.env,\n emptyStringAsUndefined: true,\n});\n"],"mappings":";;AAGyBA,UAAU;CACjCG,cAAc;CACdC,QAAQ,EACNC,sBAAsBJ,IAAEK,OAAO,EACjC;CACAC,YAAYC,OAAOC,KAAKC;CACxBC,wBAAwB;AAC1B,CAAC;AAED,MAAaC,YAAYZ,UAAU;CACjCa,QAAQ;EACNC,iBAAiBb,IAAEK,OAAO,CAAC,CAACS,IAAI,CAAC;EACjCC,iBAAiBf,IAAEK,OAAO,CAAC,CAACS,IAAI,CAAC;EACjCE,qBAAqBhB,IAAEK,OAAO,CAAC,CAACS,IAAI,CAAC;EACrCG,gBAAgBjB,IAAEK,OAAO,CAAC,CAACS,IAAI,EAAE;EACjCI,eAAelB,IAAEK,OAAO,CAAC,CAACS,IAAI,CAAC,CAAC,CAACK,SAAS;EAC1CC,mBAAmBpB,IAAEK,OAAO,CAAC,CAACS,IAAI,CAAC,CAAC,CAACK,SAAS;EAC9CE,qBAAqBrB,IAAEK,OAAO,CAAC,CAACS,IAAI,CAAC,CAAC,CAACK,SAAS;EAChDG,gBAAgBtB,IAAEK,OAAO,CAAC,CAACS,IAAI,CAAC,CAAC,CAACK,SAAS;EAC3CI,aAAavB,IAAEK,OAAO,CAAC,CAACS,IAAI,CAAC,CAAC,CAACK,SAAS;EACxCK,qBAAqBxB,IAAEK,OAAO,CAAC,CAACS,IAAI,CAAC,CAAC,CAACK,SAAS;EAChDM,cAAczB,IAAEK,OAAO,CAAC,CAACS,IAAI,CAAC,CAAC,CAACK,SAAS;EACzCO,kBAAkB1B,IAAEK,OAAO,CAAC,CAACS,IAAI,CAAC,CAAC,CAACK,SAAS;CAC/C;CACAb,YAAYqB,QAAQlB;CACpBC,wBAAwB;AAC1B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-D1MfHsnw.mjs","names":["createServerOnlyFn","getRequest","axios","AxiosError","AxiosInstance","https","serverEnv","scopes","definedScopes","getAppToken","getTokenOnBehalfOf","getAccessToken","getSessionUser","ApiOptions","baseURL","scopeKey","httpsAgent","Agent","rejectUnauthorized","createApi","Promise","resolvedBaseURL","process","env","Error","authHeader","headers","get","accessToken","startsWith","substring","length","api","create","Authorization","interceptors","response","use","undefined","error","data","message","createServerOnlyFn","AxiosResponse","https","Readable","DefaultHttpStack","Upload","z","serverEnv","uuidv7","getAppToken","getAccessToken","getSessionUser","createApi","FileMeta","FileMetaSchema","GetFileMetasSchema","object","appName","string","min","max","subId","uuid","FileSchema","id","UpdateFileMetaSchema","extend","fileName","DeleteFileSchema","BatchDeleteFilesSchema","UploadFileResult","UploadFileMetaSchema","file","instanceof","File","fileApi","baseURL","scopeKey","toFileResponse","response","disposition","Response","headers","Headers","String","contentLength","set","toWeb","data","ReadableStream","getFileMetas","input","Promise","Array","parse","queryParams","URLSearchParams","append","api","fileMetas","request","url","toString","method","getFileThumbnail","responseType","getFile","downloadFile","updateFileMeta","deleteFile","batchDeleteFiles","insecureHttpsAgent","Agent","rejectUnauthorized","uploadFile","accessToken","stream","fromWeb","resolve","reject","upload","endpoint","FILE_BASE_URL","httpStack","agent","uploadSize","size","chunkSize","metadata","filename","name","filetype","type","Authorization","onError","onSuccess","start"],"sources":["../src/data/server/utils/createApi.ts","../src/data/server/file.ts"],"sourcesContent":["import { createServerOnlyFn } from \"@tanstack/react-start\";\r\nimport { getRequest } from \"@tanstack/react-start/server\";\r\nimport axios, { AxiosError, type AxiosInstance } from \"axios\";\r\nimport https from \"node:https\";\r\nimport type { serverEnv } from \"virtual:wcz-layout\";\r\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\r\nimport { getAppToken, getTokenOnBehalfOf } from \"~/lib/auth/msalServer\";\r\nimport { getAccessToken, getSessionUser } from \"~/lib/auth/user\";\r\n\r\nexport interface ApiOptions {\r\n baseURL: keyof typeof serverEnv & `${string}BASE_URL${string}`;\r\n scopeKey: keyof typeof definedScopes;\r\n}\r\n\r\nconst httpsAgent = new https.Agent({\r\n rejectUnauthorized: false,\r\n});\r\n\r\nexport const createApi = createServerOnlyFn(\r\n async ({ baseURL, scopeKey }: ApiOptions): Promise<AxiosInstance> => {\r\n const resolvedBaseURL = process.env[baseURL];\r\n if (!resolvedBaseURL) throw new Error(`\"${baseURL}\" env variable is not set.`);\r\n\r\n const authHeader = getRequest().headers.get(\"Authorization\");\r\n let accessToken: string;\r\n if (authHeader?.startsWith(\"Bearer \")) {\r\n accessToken = await getTokenOnBehalfOf(authHeader.substring(\"Bearer \".length), scopeKey);\r\n } else {\r\n accessToken = (await getSessionUser())\r\n ? await getAccessToken(scopeKey)\r\n : await getAppToken(scopeKey);\r\n }\r\n\r\n const api = axios.create({\r\n baseURL: resolvedBaseURL,\r\n httpsAgent,\r\n headers: { Authorization: `Bearer ${accessToken}` },\r\n });\r\n\r\n api.interceptors.response.use(undefined, (error: unknown) => {\r\n if (error instanceof AxiosError)\r\n throw new Error(error.response?.data?.message ?? error.message);\r\n throw error;\r\n });\r\n\r\n return api;\r\n },\r\n);\r\n","import { createServerOnlyFn } from \"@tanstack/react-start\";\r\nimport type { AxiosResponse } from \"axios\";\r\nimport https from \"node:https\";\r\nimport { Readable } from \"node:stream\";\r\nimport { DefaultHttpStack, Upload } from \"tus-js-client\";\r\nimport { z } from \"zod\";\r\nimport { serverEnv } from \"~/env\";\r\nimport { uuidv7 } from \"~/exports/utils\";\r\nimport { getAppToken } from \"~/lib/auth/msalServer\";\r\nimport { getAccessToken, getSessionUser } from \"~/lib/auth/user\";\r\nimport { createApi } from \"~/data/server/utils/createApi\";\r\nimport type { FileMeta } from \"~/models/file/FileMeta\";\r\nimport { FileMetaSchema } from \"~/models/file/FileMeta\";\r\n\r\nexport const GetFileMetasSchema = z.object({\r\n appName: z.string().min(1).max(255),\r\n subId: z.uuid(),\r\n});\r\n\r\nexport const FileSchema = z.object({\r\n appName: z.string().min(1).max(255),\r\n id: z.uuid(),\r\n});\r\n\r\nexport const UpdateFileMetaSchema = FileMetaSchema.extend({\r\n fileName: z.string().min(1).max(255),\r\n});\r\n\r\nconst DeleteFileSchema = FileSchema;\r\n\r\nconst BatchDeleteFilesSchema = GetFileMetasSchema;\r\n\r\nexport interface UploadFileResult {\r\n id: string;\r\n appName: string;\r\n subId: string;\r\n fileName: string;\r\n}\r\n\r\nexport const UploadFileMetaSchema = z.object({\r\n appName: z.string().min(1).max(255),\r\n subId: z.uuid(),\r\n file: z.instanceof(File),\r\n});\r\n\r\nconst fileApi = () => createApi({ baseURL: \"FILE_BASE_URL\", scopeKey: \"file\" });\r\n\r\nfunction toFileResponse(response: AxiosResponse<Readable>, disposition?: string): Response {\r\n const headers = new Headers({\r\n \"Cache-Control\": \"private, max-age=3600, immutable\",\r\n \"Content-Type\": String(response.headers[\"content-type\"] ?? \"application/octet-stream\"),\r\n });\r\n const contentLength = response.headers[\"content-length\"];\r\n if (contentLength) headers.set(\"Content-Length\", String(contentLength));\r\n if (disposition) headers.set(\"Content-Disposition\", disposition);\r\n\r\n return new Response(Readable.toWeb(response.data) as ReadableStream, { headers });\r\n}\r\n\r\nexport const getFileMetas = createServerOnlyFn(\r\n async ({ data }: { data: z.input<typeof GetFileMetasSchema> }): Promise<Array<FileMeta>> => {\r\n const input = GetFileMetasSchema.parse(data);\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", input.appName);\r\n queryParams.append(\"subId\", input.subId);\r\n\r\n const api = await fileApi();\r\n const { data: fileMetas } = await api.request<Array<FileMeta>>({\r\n url: `/v1/meta?${queryParams.toString()}`,\r\n method: \"GET\",\r\n });\r\n return fileMetas;\r\n },\r\n);\r\n\r\nexport const getFileThumbnail = createServerOnlyFn(\r\n async ({ data }: { data: z.input<typeof FileSchema> }): Promise<Response> => {\r\n const input = FileSchema.parse(data);\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", input.appName);\r\n queryParams.append(\"id\", input.id);\r\n\r\n const api = await fileApi();\r\n const response = await api.request<Readable>({\r\n url: `/v1/thumbnail?${queryParams.toString()}`,\r\n method: \"GET\",\r\n responseType: \"stream\",\r\n });\r\n\r\n return toFileResponse(response);\r\n },\r\n);\r\n\r\nexport const getFile = createServerOnlyFn(\r\n async ({ data }: { data: z.input<typeof FileSchema> }): Promise<Response> => {\r\n const input = FileSchema.parse(data);\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", input.appName);\r\n queryParams.append(\"id\", input.id);\r\n\r\n const api = await fileApi();\r\n const response = await api.request<Readable>({\r\n url: `/v1?${queryParams.toString()}`,\r\n method: \"GET\",\r\n responseType: \"stream\",\r\n });\r\n\r\n return toFileResponse(response, \"inline\");\r\n },\r\n);\r\n\r\nexport const downloadFile = createServerOnlyFn(\r\n async ({ data }: { data: z.input<typeof FileSchema> }): Promise<Response> => {\r\n const input = FileSchema.parse(data);\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", input.appName);\r\n queryParams.append(\"id\", input.id);\r\n\r\n const api = await fileApi();\r\n const response = await api.request<Readable>({\r\n url: `/v1/download?${queryParams.toString()}`,\r\n method: \"GET\",\r\n responseType: \"stream\",\r\n });\r\n\r\n return toFileResponse(response);\r\n },\r\n);\r\n\r\nexport const updateFileMeta = createServerOnlyFn(\r\n async ({ data }: { data: z.input<typeof UpdateFileMetaSchema> }): Promise<void> => {\r\n const input = UpdateFileMetaSchema.parse(data);\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", input.appName);\r\n queryParams.append(\"id\", input.id);\r\n\r\n const api = await fileApi();\r\n await api.request({ url: `/v1/meta?${queryParams.toString()}`, method: \"PUT\", data: input });\r\n },\r\n);\r\n\r\nexport const deleteFile = createServerOnlyFn(\r\n async ({ data }: { data: z.input<typeof DeleteFileSchema> }): Promise<void> => {\r\n const input = DeleteFileSchema.parse(data);\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", input.appName);\r\n queryParams.append(\"id\", input.id);\r\n\r\n const api = await fileApi();\r\n await api.request({ url: `/v1?${queryParams.toString()}`, method: \"DELETE\" });\r\n },\r\n);\r\n\r\nexport const batchDeleteFiles = createServerOnlyFn(\r\n async ({ data }: { data: z.input<typeof BatchDeleteFilesSchema> }): Promise<void> => {\r\n const input = BatchDeleteFilesSchema.parse(data);\r\n const queryParams = new URLSearchParams();\r\n queryParams.append(\"appName\", input.appName);\r\n queryParams.append(\"subId\", input.subId);\r\n\r\n const api = await fileApi();\r\n await api.request({ url: `/v1?${queryParams.toString()}`, method: \"DELETE\" });\r\n },\r\n);\r\n\r\nconst insecureHttpsAgent = new https.Agent({ rejectUnauthorized: false });\r\n\r\nexport const uploadFile = createServerOnlyFn(\r\n async ({ data }: { data: z.input<typeof UploadFileMetaSchema> }): Promise<UploadFileResult> => {\r\n const input = UploadFileMetaSchema.parse(data);\r\n const accessToken = (await getSessionUser())\r\n ? await getAccessToken(\"file\")\r\n : await getAppToken(\"file\");\r\n const stream = Readable.fromWeb(\r\n input.file.stream() as import(\"node:stream/web\").ReadableStream,\r\n );\r\n\r\n const id = uuidv7();\r\n\r\n await new Promise<void>((resolve, reject) => {\r\n const upload = new Upload(stream, {\r\n endpoint: `${serverEnv.FILE_BASE_URL}/v1/upload`,\r\n httpStack: new DefaultHttpStack({ agent: insecureHttpsAgent }),\r\n uploadSize: input.file.size,\r\n chunkSize: 1_048_576,\r\n metadata: {\r\n id,\r\n appName: input.appName,\r\n subId: input.subId,\r\n filename: input.file.name,\r\n filetype: input.file.type,\r\n },\r\n headers: { Authorization: `Bearer ${accessToken}` },\r\n onError: reject,\r\n onSuccess: () => resolve(),\r\n });\r\n upload.start();\r\n });\r\n\r\n return {\r\n id,\r\n appName: input.appName,\r\n subId: input.subId,\r\n fileName: input.file.name,\r\n };\r\n },\r\n);\r\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAMgB,aAAa,IAAIX,MAAMY,MAAM,EACjCC,oBAAoB,MACtB,CAAC;AAED,MAAaC,YAAYnB,mBACvB,OAAO,EAAEc,SAASC,eAAmD;CACnE,MAAMM,kBAAkBC,QAAQC,IAAIT;CACpC,IAAI,CAACO,iBAAiB,MAAM,IAAIG,MAAM,IAAIV,QAAO,2BAA4B;CAE7E,MAAMW,aAAaxB,WAAW,CAAC,CAACyB,QAAQC,IAAI,eAAe;CAC3D,IAAIC;CACJ,IAAIH,YAAYI,WAAW,SAAS,GAClCD,cAAc,MAAMlB,mBAAmBe,WAAWK,UAAU,CAAgB,GAAGf,QAAQ;MAEvFa,cAAe,MAAMhB,eAAe,IAChC,MAAMD,eAAeI,QAAQ,IAC7B,MAAMN,YAAYM,QAAQ;CAGhC,MAAMiB,MAAM9B,MAAM+B,OAAO;EACvBnB,SAASO;EACTL;EACAU,SAAS,EAAEQ,eAAe,UAAUN,cAAc;CACpD,CAAC;CAEDI,IAAIG,aAAaC,SAASC,IAAIC,KAAAA,IAAYC,UAAmB;EAC3D,IAAIA,iBAAiBpC,YACnB,MAAM,IAAIqB,MAAMe,MAAMH,UAAUI,MAAMC,WAAWF,MAAME,OAAO;EAChE,MAAMF;CACR,CAAC;CAED,OAAOP;AACT,CACF;;;ACjCA,MAAayB,qBAAqBT,IAAEU,OAAO;CACzCC,SAASX,IAAEY,O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AAaC,aAAa1E,mBACxB,OAAO,EAAEgD,WAAsF;CAC7F,MAAMG,QAAQpB,qBAAqBuB,MAAMN,IAAI;CAC7C,MAAM2B,cAAe,MAAMhE,eAAe,IACtC,MAAMD,eAAe,MAAM,IAC3B,MAAMD,YAAY,MAAM;CAC5B,MAAMmE,SAASzE,SAAS0E,QACtB1B,MAAMnB,KAAK4C,OAAO,CACpB;CAEA,MAAMpD,KAAKhB,OAAO;CAElB,MAAM,IAAI4C,SAAe0B,SAASC,WAAW;EAiB3CC,IAhBmB3E,OAAOuE,QAAQ;GAChCK,UAAU,GAAG1E,UAAU2E,cAAa;GACpCC,WAAW,IAAI/E,iBAAiB,EAAEgF,OAAOb,mBAAmB,CAAC;GAC7Dc,YAAYlC,MAAMnB,KAAKsD;GACvBC,WAAW;GACXC,UAAU;IACRhE;IACAP,SAASkC,MAAMlC;IACfI,OAAO8B,MAAM9B;IACboE,UAAUtC,MAAMnB,KAAK0D;IACrBC,UAAUxC,MAAMnB,KAAK4D;GACvB;GACAlD,SAAS,EAAEmD,eAAe,UAAUlB,cAAc;GAClDmB,SAASf;GACTgB,iBAAiBjB,QAAQ;EAC3B,CACAE,CAAM,CAACgB,MAAM;CACf,CAAC;CAED,OAAO;EACLxE;EACAP,SAASkC,MAAMlC;EACfI,OAAO8B,MAAM9B;EACbM,UAAUwB,MAAMnB,KAAK0D;CACvB;AACF,CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"msalServer-B3iBsafS.mjs","names":["createServerOnlyFn","ConfidentialClientApplication","scopes","definedScopes","ccaInstance","getCCA","Promise","createConfidentialClient","getTokenOnBehalfOf","userToken","scopeKey","cca","result","acquireTokenOnBehalfOf","oboAssertion","Error","accessToken","getAppToken","defaultScopes","map","scope","lastSlash","lastIndexOf","baseUri","substring","uniqueScopes","Set","acquireTokenByClientCredential"],"sources":["../src/lib/auth/msalServer.ts"],"sourcesContent":["import { createServerOnlyFn } from \"@tanstack/react-start\";\nimport type { ConfidentialClientApplication } from \"@azure/msal-node\";\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\n\nlet ccaInstance: ConfidentialClientApplication | null = null;\nconst getCCA = async (): Promise<ConfidentialClientApplication> => {\n if (!ccaInstance) {\n const { createConfidentialClient } = await import(\"./entra\");\n ccaInstance = createConfidentialClient();\n }\n return ccaInstance;\n};\n\n/**\n * On-Behalf-Of flow: Exchange user token for a token to call downstream API\n * Use when: Server needs to call microservice on behalf of the logged-in user\n */\nexport const getTokenOnBehalfOf = createServerOnlyFn(\n async (userToken: string, scopeKey: keyof typeof definedScopes): Promise<string> => {\n const cca = await getCCA();\n const scopes = [...definedScopes[scopeKey]];\n const result = await cca.acquireTokenOnBehalfOf({\n oboAssertion: userToken,\n scopes,\n });\n if (!result) throw new Error(\"Failed to acquire OBO token\");\n return result.accessToken;\n },\n);\n\n/**\n * Client Credentials flow: Get app-only token (no user context)\n * Use when: Background jobs, scheduled tasks, service-to-service calls\n */\nexport const getAppToken = createServerOnlyFn(\n async (scopeKey: keyof typeof definedScopes): Promise<string> => {\n const cca = await getCCA();\n const scopes = definedScopes[scopeKey];\n const defaultScopes = scopes.map((scope) => {\n const lastSlash = scope.lastIndexOf(\"/\");\n const baseUri = scope.substring(0, lastSlash);\n return `${baseUri}/.default`;\n });\n const uniqueScopes = [...new Set(defaultScopes)];\n const result = await cca.acquireTokenByClientCredential({ scopes: uniqueScopes });\n if (!result) throw new Error(\"Failed to acquire app token\");\n return result.accessToken;\n },\n);\n"],"mappings":";;;AAIA,IAAII,cAAoD;AACxD,MAAMC,SAAS,YAAoD;CACjE,IAAI,CAACD,aAAa;EAChB,MAAM,EAAEG,6BAA6B,MAAM,OAAO;EAClDH,cAAcG,yBAAyB;CACzC;CACA,OAAOH;AACT;;;;;AAMA,MAAaI,qBAAqBR,mBAChC,OAAOS,WAAmBC,aAA0D;CAClF,MAAMC,MAAM,MAAMN,OAAO;CACzB,MAAMH,WAAS,CAAC,GAAGC,OAAcO,SAAS;CAC1C,MAAME,SAAS,MAAMD,IAAIE,uBAAuB;EAC9CC,cAAcL;EACdP,QAAAA;CACF,CAAC;CACD,IAAI,CAACU,QAAQ,MAAM,IAAIG,MAAM,6BAA6B;CAC1D,OAAOH,OAAOI;AAChB,CACF;;;;;AAMA,MAAaC,cAAcjB,mBACzB,OAAOU,aAA0D;CAC/D,MAAMC,MAAM,MAAMN,OAAO;CAEzB,MAAMa,gBADSf,OAAcO,SACD,CAACS,KAAKC,UAAU;EAC1C,MAAMC,YAAYD,MAAME,YAAY,GAAG;EAEvC,OAAO,GADSF,MAAMI,UAAU,GAAGH,SACzBE,EAAO;CACnB,CAAC;CACD,MAAME,eAAe,CAAC,GAAG,IAAIC,IAAIR,aAAa,CAAC;CAC/C,MAAMN,SAAS,MAAMD,IAAIgB,+BAA+B,EAAEzB,QAAQuB,aAAa,CAAC;CAChF,IAAI,CAACb,QAAQ,MAAM,IAAIG,MAAM,6BAA6B;CAC1D,OAAOH,OAAOI;AAChB,CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"peoplesoft-BPRwAaaM.mjs","names":["createServerOnlyFn","z","createApi","ApproveApprovalSchema","CancelApprovalSchema","CreateApprovalSchema","ResubmitApprovalSchema","WithdrawApprovalSchema","Approval","ApprovalStatus","ApprovalStepResult","GetApprovalsSchema","object","appName","string","min","max","status","optional","approverEmployeeId","stepResult","GetApprovalSchema","id","uuid","approvalApi","baseURL","scopeKey","getApprovals","data","input","Promise","Array","parse","queryParams","URLSearchParams","append","toString","api","approvals","request","url","method","getApproval","approval","createApproval","approveApproval","resubmitApproval","withdrawApproval","cancelApproval","createServerOnlyFn","z","createApi","Department","Employee","SearchEmployeesSchema","object","searchTerm","string","min","EmployeeIdSchema","employeeId","DepartmentIdSchema","departmentId","CompanyCodeSchema","companyCode","peoplesoftApi","baseURL","scopeKey","searchEmployees","data","input","Promise","Array","parse","api","employees","request","url","encodeURIComponent","method","getEmployees","getActiveEmployees","getEmployeeByEmployeeId","employee","getPreviousEmployeeIds","getEmployeeSupervisor","getEmployeeSubordinates","getEmployeeManager","getEmployeeGeneralManager","getDepartments","departments","getDepartmentById","department","getDepartmentManager","getDepartmentEmployees","getCompanyGeneralManager"],"sources":["../src/data/server/approval.ts","../src/data/server/peoplesoft.ts"],"sourcesContent":["import { createServerOnlyFn } from \"@tanstack/react-start\";\nimport { z } from \"zod\";\nimport { createApi } from \"~/data/server/utils/createApi\";\nimport {\n ApproveApprovalSchema,\n CancelApprovalSchema,\n CreateApprovalSchema,\n ResubmitApprovalSchema,\n WithdrawApprovalSchema,\n} from \"~/models/approval/Approval\";\nimport type { Approval } from \"~/models/approval/Approval\";\nimport { ApprovalStatus } from \"~/models/approval/ApprovalStatus\";\nimport { ApprovalStepResult } from \"~/models/approval/ApprovalStepResult\";\n\nexport const GetApprovalsSchema = z.object({\n appName: z.string().min(1).max(255),\n status: ApprovalStatus.optional(),\n approverEmployeeId: z.string().min(1).max(20).optional(),\n stepResult: ApprovalStepResult.optional(),\n});\n\nexport const GetApprovalSchema = z.object({\n id: z.uuid(),\n});\n\nconst approvalApi = () => createApi({ baseURL: \"APPROVAL_BASE_URL\", scopeKey: \"approval\" });\n\nexport const getApprovals = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof GetApprovalsSchema> }): Promise<Array<Approval>> => {\n const input = GetApprovalsSchema.parse(data);\n const queryParams = new URLSearchParams();\n queryParams.append(\"applicationName\", input.appName);\n if (input.status) queryParams.append(\"status\", input.status.toString());\n if (input.approverEmployeeId)\n queryParams.append(\"approverEmployeeId\", input.approverEmployeeId);\n if (input.stepResult) queryParams.append(\"stepResult\", input.stepResult.toString());\n\n const api = await approvalApi();\n const { data: approvals } = await api.request<Array<Approval>>({\n url: `/Requests/Requests?${queryParams.toString()}`,\n method: \"GET\",\n });\n return approvals;\n },\n);\n\nexport const getApproval = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof GetApprovalSchema> }): Promise<Approval> => {\n const input = GetApprovalSchema.parse(data);\n const api = await approvalApi();\n const { data: approval } = await api.request<Approval>({\n url: `/Requests/${input.id}`,\n method: \"GET\",\n });\n return approval;\n },\n);\n\nexport const createApproval = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof CreateApprovalSchema> }): Promise<Approval> => {\n const input = CreateApprovalSchema.parse(data);\n const api = await approvalApi();\n const { data: approval } = await api.request<Approval>({\n url: `/Requests`,\n method: \"POST\",\n data: input,\n });\n return approval;\n },\n);\n\nexport const approveApproval = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof ApproveApprovalSchema> }): Promise<Approval> => {\n const input = ApproveApprovalSchema.parse(data);\n const api = await approvalApi();\n const { data: approval } = await api.request<Approval>({\n url: `/Requests/${input.id}/single-approval`,\n method: \"POST\",\n data: input,\n });\n return approval;\n },\n);\n\nexport const resubmitApproval = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof ResubmitApprovalSchema> }): Promise<Approval> => {\n const input = ResubmitApprovalSchema.parse(data);\n const api = await approvalApi();\n const { data: approval } = await api.request<Approval>({\n url: `/Requests/${input.id}/resubmit`,\n method: \"POST\",\n data: input,\n });\n return approval;\n },\n);\n\nexport const withdrawApproval = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof WithdrawApprovalSchema> }): Promise<void> => {\n const input = WithdrawApprovalSchema.parse(data);\n const api = await approvalApi();\n await api.request<void>({\n url: `/Requests/${input.id}/withdraw`,\n method: \"POST\",\n data: input,\n });\n },\n);\n\nexport const cancelApproval = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof CancelApprovalSchema> }): Promise<void> => {\n const input = CancelApprovalSchema.parse(data);\n const api = await approvalApi();\n await api.request<void>({\n url: `/Requests/${input.id}/cancel`,\n method: \"POST\",\n data: input,\n });\n },\n);\n","import { createServerOnlyFn } from \"@tanstack/react-start\";\nimport { z } from \"zod\";\nimport { createApi } from \"~/data/server/utils/createApi\";\nimport type { Department } from \"~/models/peoplesoft/Department\";\nimport type { Employee } from \"~/models/peoplesoft/Employee\";\n\nexport const SearchEmployeesSchema = z.object({\n searchTerm: z.string().min(1),\n});\n\nexport const EmployeeIdSchema = z.object({\n employeeId: z.string().min(1),\n});\n\nexport const DepartmentIdSchema = z.object({\n departmentId: z.string().min(1),\n});\n\nexport const CompanyCodeSchema = z.object({\n companyCode: z.string().min(1),\n});\n\nconst peoplesoftApi = () => createApi({ baseURL: \"PEOPLESOFT_BASE_URL\", scopeKey: \"peoplesoft\" });\n\nexport const searchEmployees = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof SearchEmployeesSchema> }): Promise<Array<Employee>> => {\n const input = SearchEmployeesSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employees } = await api.request<Array<Employee>>({\n url: `/v1/employee?search=${encodeURIComponent(input.searchTerm)}`,\n method: \"GET\",\n });\n return employees;\n },\n);\n\nexport const getEmployees = createServerOnlyFn(async (): Promise<Array<Employee>> => {\n const api = await peoplesoftApi();\n const { data: employees } = await api.request<Array<Employee>>({\n url: `/v1/employee/all`,\n method: \"GET\",\n });\n return employees;\n});\n\nexport const getActiveEmployees = createServerOnlyFn(async (): Promise<Array<Employee>> => {\n const api = await peoplesoftApi();\n const { data: employees } = await api.request<Array<Employee>>({\n url: `/v1/employee/active`,\n method: \"GET\",\n });\n return employees;\n});\n\nexport const getEmployeeByEmployeeId = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof EmployeeIdSchema> }): Promise<Employee> => {\n const input = EmployeeIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employee } = await api.request<Employee>({\n url: `/v1/employee/${encodeURIComponent(input.employeeId)}`,\n method: \"GET\",\n });\n return employee;\n },\n);\n\nexport const getPreviousEmployeeIds = createServerOnlyFn(async (): Promise<Array<Employee>> => {\n const api = await peoplesoftApi();\n const { data: employees } = await api.request<Array<Employee>>({\n url: `/v1/employee/previousIds`,\n method: \"GET\",\n });\n return employees;\n});\n\nexport const getEmployeeSupervisor = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof EmployeeIdSchema> }): Promise<Employee> => {\n const input = EmployeeIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employee } = await api.request<Employee>({\n url: `/v1/employee/${encodeURIComponent(input.employeeId)}/supervisor`,\n method: \"GET\",\n });\n return employee;\n },\n);\n\nexport const getEmployeeSubordinates = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof EmployeeIdSchema> }): Promise<Array<Employee>> => {\n const input = EmployeeIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employees } = await api.request<Array<Employee>>({\n url: `/v1/employee/${encodeURIComponent(input.employeeId)}/subordinates`,\n method: \"GET\",\n });\n return employees;\n },\n);\n\nexport const getEmployeeManager = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof EmployeeIdSchema> }): Promise<Employee> => {\n const input = EmployeeIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employee } = await api.request<Employee>({\n url: `/v1/employee/${encodeURIComponent(input.employeeId)}/manager`,\n method: \"GET\",\n });\n return employee;\n },\n);\n\nexport const getEmployeeGeneralManager = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof EmployeeIdSchema> }): Promise<Employee> => {\n const input = EmployeeIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employee } = await api.request<Employee>({\n url: `/v1/employee/${encodeURIComponent(input.employeeId)}/generalManager`,\n method: \"GET\",\n });\n return employee;\n },\n);\n\nexport const getDepartments = createServerOnlyFn(async (): Promise<Array<Department>> => {\n const api = await peoplesoftApi();\n const { data: departments } = await api.request<Array<Department>>({\n url: `/v1/department/all`,\n method: \"GET\",\n });\n return departments;\n});\n\nexport const getDepartmentById = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof DepartmentIdSchema> }): Promise<Department> => {\n const input = DepartmentIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: department } = await api.request<Department>({\n url: `/v1/department/${encodeURIComponent(input.departmentId)}`,\n method: \"GET\",\n });\n return department;\n },\n);\n\nexport const getDepartmentManager = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof DepartmentIdSchema> }): Promise<Employee> => {\n const input = DepartmentIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employee } = await api.request<Employee>({\n url: `/v1/department/${encodeURIComponent(input.departmentId)}/manager`,\n method: \"GET\",\n });\n return employee;\n },\n);\n\nexport const getDepartmentEmployees = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof DepartmentIdSchema> }): Promise<Array<Employee>> => {\n const input = DepartmentIdSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employees } = await api.request<Array<Employee>>({\n url: `/v1/department/${encodeURIComponent(input.departmentId)}/employees`,\n method: \"GET\",\n });\n return employees;\n },\n);\n\nexport const getCompanyGeneralManager = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof CompanyCodeSchema> }): Promise<Employee> => {\n const input = CompanyCodeSchema.parse(data);\n const api = await peoplesoftApi();\n const { data: employee } = await api.request<Employee>({\n url: `/v1/company/${encodeURIComponent(input.companyCode)}/generalManager`,\n method: \"GET\",\n });\n return employee;\n },\n);\n"],"mappings":";;;;;AAcA,MAAaW,qBAAqBV,IAAEW,OAAO;CACzCC,SAASZ,IAAEa,OAAO,CAAC,CAACC,IAAI,CAAC,CAAC,CAACC,IAAI,GAAG;CAClCC,QAAQR,eAAeS,SAAS;CAChCC,oBAAoBlB,IAAEa,OAAO,CAAC,CAACC,IAAI,CAAC,CAAC,CAACC,IAAI,EAAE,CAAC,CAACE,SAAS;CACvDE,YAAYV,mBAAmBQ,SAAS;AAC1C,CAAC;AAED,MAAaG,oBAAoBpB,IAAEW,OAAO,EACxCU,IAAIrB,IAAEsB,KAAK,EACb,CAAC;AAED,MAAMC,oBAAoBtB,UAAU;CAAEuB,SAAS;CAAqBC,UAAU;AAAW,CAAC;AAE1F,MAAaC,eAAe3B,mBAC1B,OAAO,EAAE4B,WAAmF;CAC1F,MAAMC,QAAQlB,mBAAmBqB,MAAMJ,IAAI;CAC3C,MAAMK,cAAc,IAAIC,gBAAgB;CACxCD,YAAYE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Q;CACV,CAAC;CACD,OAAOa;AACT,CACF;AAEA,MAAaC,uBAAuB5C,mBAClC,OAAO,EAAEoB,WAA4E;CACnF,MAAMC,QAAQT,mBAAmBY,MAAMJ,IAAI;CAE3C,MAAM,EAAEA,MAAMc,aAAa,OAAMT,MADfT,cAAc,EAAA,CACKW,QAAkB;EACrDC,KAAK,kBAAkBC,mBAAmBR,MAAMR,YAAY,EAAC;EAC7DiB,QAAQ;CACV,CAAC;CACD,OAAOI;AACT,CACF;AAEA,MAAaW,yBAAyB7C,mBACpC,OAAO,EAAEoB,WAAmF;CAC1F,MAAMC,QAAQT,mBAAmBY,MAAMJ,IAAI;CAE3C,MAAM,EAAEA,MAAMM,cAAc,OAAMD,MADhBT,cAAc,EAAA,CACMW,QAAyB;EAC7DC,KAAK,kBAAkBC,mBAAmBR,MAAMR,YAAY,EAAC;EAC7DiB,QAAQ;CACV,CAAC;CACD,OAAOJ;AACT,CACF;AAEA,MAAaoB,2BAA2B9C,mBACtC,OAAO,EAAEoB,WAA2E;CAClF,MAAMC,QAAQP,kBAAkBU,MAAMJ,IAAI;CAE1C,MAAM,EAAEA,MAAMc,aAAa,OAAMT,MADfT,cAAc,EAAA,CACKW,QAAkB;EACrDC,KAAK,eAAeC,mBAAmBR,MAAMN,WAAW,EAAC;EACzDe,QAAQ;CACV,CAAC;CACD,OAAOI;AACT,CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-CqVAK5F8.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","serverEnv","getAppSession","useSession","getSession","name","password","SESSION_SECRET","queryOptions","createServerFn","createServerOnlyFn","scopes","definedScopes","QueryClientParam","User","OFFLINE_USER_KEY","withOfflineFallback","getAppSession","getSessionUser","method","handler","Promise","session","data","user","userQueryOptions","queryKey","queryFn","staleTime","Infinity","networkMode","refetchOnReconnect","getUser","queryClient","import","meta","env","SSR","ensureQueryData","getAccessToken","scopeKey","refreshToken","Error","acquireDelegatedToken","SessionExpiredError","accessToken","update","error","clear","Response","json","message","status","AnyFieldApi","redirect","ParsedLocation","manifest","permissions","QueryClientParam","TokenPayload","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","requirePermission","permissionKey","location","context","user","queryClient","encodeURIComponent","reloadDocument","hasPermission","Error","FormOmittedProps","getFieldStatus","field","state","isTouched","hasError","errors","length","helperText","message","toKebabCase","str","replaceAll","toLowerCase","permissionGroups","Set","Object","values","flat","buildUser","payload","split","email","preferred_username","department","toUpperCase","employeeId","companyName","groups","filter","group","has","key","some","includes"],"sources":["../src/lib/auth/offline.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 = \"wcz-auth-user\";\nexport const OFFLINE_PHOTO_KEY = \"wcz-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(\"wcz-auth-logout\", String(Date.now()));\n};\n\nif (typeof window !== \"undefined\")\n window.addEventListener(\"storage\", (event) => {\n if (event.key === \"wcz-auth-logout\") location.href = \"/auth/logout\";\n });\n","import { serverEnv } from \"~/env\";\r\n\r\nexport const getAppSession = async () => {\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({\r\n name: \"session\",\r\n password: serverEnv.SESSION_SECRET,\r\n });\r\n};\r\n","import { queryOptions } from \"@tanstack/react-query\";\r\nimport { createServerFn, createServerOnlyFn } from \"@tanstack/react-start\";\r\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\r\nimport type { QueryClientParam } from \"~/models/QueryClientParam\";\r\nimport type { User } from \"~/models/User\";\r\nimport { OFFLINE_USER_KEY, withOfflineFallback } from \"./offline\";\r\nimport { getAppSession } from \"./session\";\r\n\r\n/**\r\n * Reads the signed-in user from the session cookie, or null. As a server function\r\n * it runs in-process when called on the server (SSR, middleware) and as an RPC\r\n * when called from the client — so it doubles as the client `queryFn`.\r\n */\r\nexport const getSessionUser = createServerFn({ method: \"GET\" }).handler(\r\n async (): Promise<User | null> => {\r\n const session = await getAppSession();\r\n return session.data.user ?? null;\r\n },\r\n);\r\n\r\n/**\r\n * Client-side query for the signed-in user. Shared between `getUser` (route\r\n * `beforeLoad`) and the always-mounted observer in `LayoutProvider` — the\r\n * observer is what seeds the offline snapshot on the very first page load\r\n * (`beforeLoad` does not re-run after SSR hydration) and what makes\r\n * `refetchOnReconnect` fire once connectivity returns.\r\n */\r\nexport const userQueryOptions = queryOptions({\r\n queryKey: [\"auth\", \"user\"],\r\n queryFn: () => withOfflineFallback(OFFLINE_USER_KEY, () => getSessionUser()),\r\n staleTime: Infinity,\r\n // Default \"online\" pauses the query (never calling queryFn) once the browser\r\n // reports no connection — which is exactly when the fallback is needed.\r\n networkMode: \"offlineFirst\",\r\n // Back online: re-confirm the session and re-stamp the snapshot's grace period.\r\n refetchOnReconnect: \"always\",\r\n});\r\n\r\nexport const getUser = ({ queryClient }: QueryClientParam): Promise<User | null> => {\r\n if (import.meta.env.SSR) return getSessionUser();\r\n\r\n return queryClient.ensureQueryData(userQueryOptions);\r\n};\r\n\r\n/**\r\n * Server-only token acquisition: a delegated access token for the given API\r\n * scope, minted from the user's session refresh token. Entra rotates the refresh\r\n * token on each use, so the rotated token is persisted back to the session. Use\r\n * inside server functions and middleware — it is stripped from the client bundle\r\n * and throws if called there.\r\n */\r\nexport const getAccessToken = createServerOnlyFn(\r\n async (scopeKey: keyof typeof definedScopes): Promise<string> => {\r\n const session = await getAppSession();\r\n if (!session.data.refreshToken) throw new Error(\"No active session. User not signed in.\");\r\n\r\n // Dynamic import so `entra` (and its `@azure/msal-node` dependency) stays out\r\n // of the client graph — this module also exports the isomorphic `getUser`.\r\n const { acquireDelegatedToken, SessionExpiredError } = await import(\"./entra\");\r\n try {\r\n const { accessToken, refreshToken } = await acquireDelegatedToken({\r\n refreshToken: session.data.refreshToken,\r\n scopes: definedScopes[scopeKey],\r\n });\r\n\r\n if (refreshToken !== session.data.refreshToken) await session.update({ refreshToken });\r\n return accessToken;\r\n } catch (error) {\r\n // Revoked/expired refresh token: clear the dead session and answer 401 so\r\n // the client can redirect to /auth/login, instead of surfacing a 500.\r\n if (error instanceof SessionExpiredError) {\r\n await session.clear();\r\n throw Response.json(\r\n { message: \"Unauthorized: Session expired, sign in again\" },\r\n { status: 401 },\r\n );\r\n }\r\n throw error;\r\n }\r\n },\r\n);\r\n","import type { AnyFieldApi } from \"@tanstack/react-form\";\r\nimport { redirect } from \"@tanstack/react-router\";\r\nimport type { ParsedLocation } from \"@tanstack/react-router\";\r\nimport { manifest, permissions } from \"virtual:wcz-layout\";\r\nimport type { QueryClientParam } from \"~/models/QueryClientParam\";\r\nimport type { TokenPayload } from \"~/models/TokenPayload\";\r\nimport type { User } from \"~/models/User\";\r\nimport { getUser } from \"./auth/user\";\r\n\r\nexport const WISTRON_PRIMARY_COLOR = \"#00506E\";\r\nexport const WISTRON_SECONDARY_COLOR = \"#64DC00\";\r\n\r\nexport class Platform {\r\n static get isAndroid() {\r\n return /android/i.test(this.userAgent);\r\n }\r\n static get isIOS() {\r\n return /iPad|iPhone|iPod/.test(this.userAgent);\r\n }\r\n static get isWindows() {\r\n return /windows/i.test(this.userAgent);\r\n }\r\n static get isMacOS() {\r\n return /Macintosh|MacIntel|MacPPC|Mac68K/.test(this.userAgent);\r\n }\r\n\r\n private static get userAgent() {\r\n return typeof navigator === \"undefined\" ? \"\" : navigator.userAgent;\r\n }\r\n}\r\n\r\ninterface RootRouteHeadOptions {\r\n manifest?: string;\r\n}\r\n\r\nexport const rootRouteHead = (options?: RootRouteHeadOptions) => ({\r\n meta: [\r\n { charSet: \"utf-8\" },\r\n { name: \"viewport\", content: \"width=device-width, initial-scale=1\" },\r\n { title: manifest.name },\r\n { name: \"og:type\", content: \"website\" },\r\n { name: \"og:title\", content: manifest.name },\r\n { name: \"og:image\", content: \"/favicon-32x32.png\" },\r\n ],\r\n links: [\r\n { rel: \"apple-touch-icon\", sizes: \"180x180\", href: \"/apple-touch-icon.png\" },\r\n { rel: \"icon\", type: \"image/png\", sizes: \"32x32\", href: \"/favicon-32x32.png\" },\r\n { rel: \"icon\", type: \"image/png\", sizes: \"16x16\", href: \"/favicon-16x16.png\" },\r\n { rel: \"manifest\", href: options?.manifest || \"/manifest.json\" },\r\n { rel: \"icon\", href: \"/favicon.ico\" },\r\n ],\r\n});\r\n\r\nexport const requirePermission = (permissionKey: keyof typeof permissions) => {\r\n return async ({ location, context }: { location: ParsedLocation; context: QueryClientParam }) => {\r\n const user = await getUser({ queryClient: context.queryClient });\r\n\r\n if (!user)\r\n throw redirect({\r\n href: `/auth/login?returnTo=${encodeURIComponent(location.href)}`,\r\n reloadDocument: true,\r\n });\r\n\r\n if (!hasPermission(user, permissionKey))\r\n throw new Error(\"You do not have permission to access this page.\");\r\n\r\n return { user };\r\n };\r\n};\r\n\r\n/* Internal Utils */\r\nexport type FormOmittedProps =\r\n | \"name\"\r\n | \"value\"\r\n | \"onChange\"\r\n | \"onBlur\"\r\n | \"error\"\r\n | \"helperText\"\r\n | \"renderInput\"\r\n | \"type\"\r\n | \"aria-label\";\r\n\r\nexport const getFieldStatus = (field: AnyFieldApi) => {\r\n const { meta } = field.state;\r\n\r\n const isTouched = meta.isTouched;\r\n const hasError = !!meta.errors.length;\r\n const helperText = meta.errors[0]?.message;\r\n\r\n return { isTouched, hasError, helperText };\r\n};\r\n\r\nexport const toKebabCase = (str: string): string => {\r\n return str\r\n .replaceAll(/([a-z])([A-Z])/g, \"$1-$2\")\r\n .replaceAll(/[\\s_]+/g, \"-\")\r\n .replaceAll(/[^a-zA-Z0-9-]/g, \"\")\r\n .toLowerCase()\r\n .replaceAll(/-+/g, \"-\")\r\n .replaceAll(/(^-|-$)/g, \"\");\r\n};\r\n\r\nconst permissionGroups = new Set<string>(Object.values(permissions).flat());\r\n\r\nexport const buildUser = (payload: TokenPayload): User => ({\r\n name: payload.name?.split(\"/\")[0],\r\n email: payload.preferred_username?.toLowerCase(),\r\n department: payload.department?.toUpperCase() || \"\",\r\n employeeId: payload.employeeId?.toUpperCase() || \"\",\r\n companyName: payload.companyName || \"\",\r\n groups: payload.groups?.filter((group) => permissionGroups.has(group)) ?? [],\r\n});\r\n\r\nexport const hasPermission = (user: User | null, key: keyof typeof permissions): boolean =>\r\n user ? permissions[key].some((group) => user.groups.includes(group)) : false;\r\n"],"mappings":";;;;;;;;;;;;;AAQA,MAAaA,mBAAmB;AAChC,MAAaC,oBAAoB;;AAGjC,MAAMC,eAAe,MAAU,KAAK;AAIpC,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;O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,QAAQtC,MAAMuC,MAAM,GAAG,CAAC,CAAC;CAC/BC,OAAOF,QAAQG,oBAAoBV,YAAY;CAC/CW,YAAYJ,QAAQI,YAAYC,YAAY,KAAK;CACjDC,YAAYN,QAAQM,YAAYD,YAAY,KAAK;CACjDE,aAAaP,QAAQO,eAAe;CACpCC,QAAQR,QAAQQ,QAAQC,QAAQC,UAAUhB,iBAAiBiB,IAAID,KAAK,CAAC,KAAK,CAAA;AAC5E;AAEA,MAAahC,iBAAiBJ,MAAmBsC,QAC/CtC,OAAOhC,YAAYsE,IAAI,CAACC,MAAMH,UAAUpC,KAAKkC,OAAOM,SAASJ,KAAK,CAAC,IAAI"}
|
package/dist/utils-D39-w_ij.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: notifications
|
|
3
|
-
description: "Use when: displaying feedback with snackbars."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
## Rules
|
|
7
|
-
|
|
8
|
-
- Use `useNotification()` for lightweight non-blocking user feedback.
|
|
9
|
-
- Always use translation; add new keys for feature-specific messages.
|
|
10
|
-
- Notifications are automatically queued by the provider and shown one at a time.
|
|
11
|
-
- `autoHideDuration` defaults to 5000 ms and is not capped by the library; keep overrides reasonable (~10000 ms) for messages that need more reading time.
|
|
12
|
-
- Use `severity: "success" | "info" | "warning" | "error"` consistently with the outcome. Severity is optional — omitting it renders a plain snackbar (no colored `Alert`).
|
|
13
|
-
- Use notifications for lightweight feedback; dialogs when the user must decide or acknowledge.
|
|
14
|
-
|
|
15
|
-
## File Placement
|
|
16
|
-
|
|
17
|
-
```txt
|
|
18
|
-
wcz-layout/hooks — useNotification hook, useTranslation
|
|
19
|
-
src/lib/locales/ — translation keys
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Examples
|
|
23
|
-
|
|
24
|
-
```ts
|
|
25
|
-
// basic usage
|
|
26
|
-
const { notify } = useNotification();
|
|
27
|
-
const { t } = useTranslation();
|
|
28
|
-
|
|
29
|
-
notify(t("Feature.Created"), {
|
|
30
|
-
severity: "success",
|
|
31
|
-
autoHideDuration: 6000,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// error handling
|
|
35
|
-
try {
|
|
36
|
-
await deleteFeature({ data: id });
|
|
37
|
-
} catch (error) {
|
|
38
|
-
notify(error instanceof Error ? error.message : t("DeleteFailed"), {
|
|
39
|
-
severity: "error",
|
|
40
|
-
autoHideDuration: 10000,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
```
|