@softistx/alxia-react-router 0.86.4 → 0.88.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.
- package/README.md +81 -5
- package/dist/chunks/{index-t2ph23wk.js → index-5hjhzztk.js} +6 -17
- package/dist/chunks/{index-t2ph23wk.js.map → index-5hjhzztk.js.map} +3 -4
- package/dist/chunks/{index-v2z5k640.js → index-6zx9dfvs.js} +3 -18
- package/dist/chunks/{index-v2z5k640.js.map → index-6zx9dfvs.js.map} +3 -4
- package/dist/chunks/{index-xd5aqy3g.js → index-c721mm5a.js} +26 -3
- package/dist/chunks/{index-xd5aqy3g.js.map → index-c721mm5a.js.map} +4 -3
- package/dist/chunks/index-njfh26ez.js +19 -0
- package/dist/chunks/index-njfh26ez.js.map +10 -0
- package/dist/chunks/index-t68hwhz1.js +37 -0
- package/dist/chunks/{index-0786n4qe.js.map → index-t68hwhz1.js.map} +5 -4
- package/dist/errors/index.js +7 -4
- package/dist/errors/index.js.map +2 -2
- package/dist/errors/use-json-fetcher.d.ts +10 -1
- package/dist/errors/use-json-fetcher.d.ts.map +1 -1
- package/dist/fetcher/index.js +3 -5
- package/dist/fetcher/index.js.map +2 -2
- package/dist/oidc/dpop-fetch.d.ts +39 -0
- package/dist/oidc/dpop-fetch.d.ts.map +1 -0
- package/dist/oidc/env.d.ts +52 -0
- package/dist/oidc/env.d.ts.map +1 -0
- package/dist/oidc/index.d.ts +3 -0
- package/dist/oidc/index.d.ts.map +1 -1
- package/dist/oidc/index.js +248 -24
- package/dist/oidc/index.js.map +8 -5
- package/dist/oidc/oidc.d.ts +18 -0
- package/dist/oidc/oidc.d.ts.map +1 -1
- package/dist/oidc/routes.d.ts +76 -0
- package/dist/oidc/routes.d.ts.map +1 -0
- package/dist/session/index.js +9 -7
- package/dist/session/index.js.map +2 -2
- package/dist/session/model/index.js +2 -2
- package/dist/session/react/index.js +4 -6
- package/dist/session/react/index.js.map +2 -2
- package/docs/README.md +1 -1
- package/docs/guide/errors.md +21 -2
- package/docs/guide/fetcher.md +28 -0
- package/docs/guide/oidc.md +172 -6
- package/docs/roadmap.md +13 -0
- package/docs/troubleshooting.md +109 -0
- package/package.json +7 -7
- package/dist/chunks/index-0786n4qe.js +0 -25
- package/dist/chunks/index-ajtvyq35.js +0 -16
- package/dist/chunks/index-ajtvyq35.js.map +0 -10
package/README.md
CHANGED
|
@@ -1339,7 +1339,18 @@ const answer = useFetcherAnswer(fetcher, (result) => toast(result.message));
|
|
|
1339
1339
|
|
|
1340
1340
|
To react only when a write succeeded (close the dialog that sent it), `useFetcherDone(fetcher, (result) => result.ok, () => setOpen(false))` runs the callback once per new accepted answer, and not again when the dialog reopens with the fetcher's old data.
|
|
1341
1341
|
|
|
1342
|
-
|
|
1342
|
+
When the answer alone is needed, `useJsonFetcher`'s `post` resolves with it, a refusal included, once the fetcher is idle again (`undefined` when replaced, unmounted or unanswered):
|
|
1343
|
+
|
|
1344
|
+
```tsx
|
|
1345
|
+
// id from the row, toast from your toaster, action from the route
|
|
1346
|
+
const { post } = useJsonFetcher<typeof action>('delete');
|
|
1347
|
+
const onDelete = async () => {
|
|
1348
|
+
const answer = await post({ intent: 'delete', id }); // undefined: replaced, unmounted or unanswered
|
|
1349
|
+
if (answer && !answer.ok) toast(answer.error);
|
|
1350
|
+
};
|
|
1351
|
+
```
|
|
1352
|
+
|
|
1353
|
+
To await one submission's answer as a Promise that rejects on a refusal (a confirm dialog whose `onConfirm` stays open and shows the error until it settles), `useFetcherPromise` resolves with the next new answer, or rejects with an `Error` when your `refusal(answer)` returns a message:
|
|
1343
1354
|
|
|
1344
1355
|
```tsx
|
|
1345
1356
|
import { useJsonFetcher } from '@softistx/alxia-react-router/errors';
|
|
@@ -1717,6 +1728,67 @@ export const action = ({ request }: { request: Request }) => oidc.logout(request
|
|
|
1717
1728
|
with your answer, they carry the refreshed cookie. See the
|
|
1718
1729
|
[OIDC guide](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/oidc.md).
|
|
1719
1730
|
|
|
1731
|
+
### Less glue: `oidcFromEnv`, the route helpers and `dpopFetch`
|
|
1732
|
+
|
|
1733
|
+
A whole BFF in a few lines (`jose` installed, secrets in files, `OIDC_*` variables):
|
|
1734
|
+
|
|
1735
|
+
```ts
|
|
1736
|
+
// app/oidc.server.ts
|
|
1737
|
+
import { oidcClient, oidcFromEnv } from '@softistx/alxia-react-router/oidc';
|
|
1738
|
+
|
|
1739
|
+
// OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET_FILE, OIDC_REDIRECT_URI, OIDC_SESSION_SECRET_FILE
|
|
1740
|
+
// (and OIDC_COOKIE_NAME, OIDC_POST_LOGOUT_REDIRECT_URI): one `OidcEnvError` lists every problem at start-up
|
|
1741
|
+
export const oidc = oidcClient({
|
|
1742
|
+
...(await oidcFromEnv()),
|
|
1743
|
+
secure: !import.meta.env.DEV,
|
|
1744
|
+
scopes: ['profile', 'offline_access'],
|
|
1745
|
+
par: 'auto',
|
|
1746
|
+
dpop: {},
|
|
1747
|
+
});
|
|
1748
|
+
```
|
|
1749
|
+
|
|
1750
|
+
```ts
|
|
1751
|
+
// app/routes/sign-in.ts
|
|
1752
|
+
import { signInRoute } from '@softistx/alxia-react-router/oidc';
|
|
1753
|
+
import { oidc } from '../oidc.server';
|
|
1754
|
+
|
|
1755
|
+
export const { loader } = signInRoute(oidc);
|
|
1756
|
+
```
|
|
1757
|
+
|
|
1758
|
+
```ts
|
|
1759
|
+
// app/routes/auth.callback.ts
|
|
1760
|
+
import { callbackRoute } from '@softistx/alxia-react-router/oidc';
|
|
1761
|
+
import { oidc } from '../oidc.server';
|
|
1762
|
+
|
|
1763
|
+
export const { loader } = callbackRoute(oidc, { errorPath: '/sign-in/failed' });
|
|
1764
|
+
```
|
|
1765
|
+
|
|
1766
|
+
```ts
|
|
1767
|
+
// app/routes/sign-out.ts
|
|
1768
|
+
import { signOutRoute } from '@softistx/alxia-react-router/oidc';
|
|
1769
|
+
import { oidc } from '../oidc.server';
|
|
1770
|
+
|
|
1771
|
+
export const { action, loader } = signOutRoute(oidc);
|
|
1772
|
+
```
|
|
1773
|
+
|
|
1774
|
+
```ts
|
|
1775
|
+
// a loader that calls an API as the user
|
|
1776
|
+
import { data, type LoaderFunctionArgs } from 'react-router';
|
|
1777
|
+
import { dpopFetch } from '@softistx/alxia-react-router/oidc';
|
|
1778
|
+
import { oidc } from '../oidc.server';
|
|
1779
|
+
|
|
1780
|
+
export async function loader({ request }: LoaderFunctionArgs) {
|
|
1781
|
+
const user = await oidc.requireOidcUser(request);
|
|
1782
|
+
const api = dpopFetch(oidc, user);
|
|
1783
|
+
const orders = await (await api('https://api.example.com/orders?page=2')).json();
|
|
1784
|
+
return data({ orders }, { headers: user.headers });
|
|
1785
|
+
}
|
|
1786
|
+
```
|
|
1787
|
+
|
|
1788
|
+
`signOutRoute` goes to the issuer's `end_session_endpoint` (with `id_token_hint` and `post_logout_redirect_uri`) when discovery
|
|
1789
|
+
announces one, else ends the local session only. See the
|
|
1790
|
+
[OIDC guide](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/oidc.md#less-glue).
|
|
1791
|
+
|
|
1720
1792
|
## Traps
|
|
1721
1793
|
|
|
1722
1794
|
- **A context key made in `app/` reaches the loaders only through the
|
|
@@ -1835,7 +1907,7 @@ From `@softistx/alxia-react-router/pwa/build` (Bun; Node's built-ins its only im
|
|
|
1835
1907
|
| `BuildWorkerOptions` | `file` (required), `root`, `client`, `contract`, `offline`, `precacheRoutes`, `precacheFiles`, `maxPrecacheBytes`, `precacheAssets`, `minify` |
|
|
1836
1908
|
| `WorkerBuild` | `{ file, precache, precacheBytes, bytes }` |
|
|
1837
1909
|
|
|
1838
|
-
From `@softistx/alxia-react-router/errors` (`react-router`
|
|
1910
|
+
From `@softistx/alxia-react-router/errors` (`react-router` and `react` are its only package imports, `react` since `react-router` requires it as a peer, and never `@softistx/alxia`; it reaches `/fetcher`'s `use-fetcher-promise` files alone, for `useJsonFetcher`'s `post`):
|
|
1839
1911
|
|
|
1840
1912
|
| export | |
|
|
1841
1913
|
| --- | --- |
|
|
@@ -1864,7 +1936,7 @@ From `@softistx/alxia-react-router/errors` (`react-router` is its only package i
|
|
|
1864
1936
|
| `ApiRefusal` | `{ message, status }`: a failed call as a page says it; what `apiRefusal` returns for an API refusal (its status) or an unreachable API (503), else `undefined` |
|
|
1865
1937
|
| `requireSameSite(request, from?)`, `SameSiteOptions` | the same-site guard for any POST, a native form or JSON: 403 `Cross-site request refused` for `Origin: null`, a foreign `Origin` and a `Sec-Fetch-Site` of `cross-site` or `same-site`; a request with neither header goes on (as for `readJson`); headers only, the body stays unread. The reference is the request's own origin, `{ origin }` (a string or getter) or a `jsonActions()` instance |
|
|
1866
1938
|
| `jsonActions({ origin? })`, `JsonActions`, `JsonActionsOptions` | the JSON helpers of the actions, bound to the app's origin (a string, or a getter read at each request; the request's own by default): `readJson(request)` (403 `Cross-site request refused` for another origin or a cross-site fetch, 415 `Expected a JSON body`, 400 `Malformed JSON body`), `requireJsonPost(request)` (a native post goes back to its page) and `readInput(request, schema)` (the body's `input` through a Standard Schema, async allowed; 400 `The form sent an input the API would refuse`) |
|
|
1867
|
-
| `useJsonFetcher(key?, action?)`, `JsonBody` | a fetcher that posts JSON: `{ fetcher, post(body, to?), busy }`; `to` is the action of one call |
|
|
1939
|
+
| `useJsonFetcher(key?, action?)`, `JsonBody` | a fetcher that posts JSON: `{ fetcher, post(body, to?), busy }`; `to` is the action of one call, and `post` resolves with the action's answer (`await post(body)`; `undefined` when replaced, unmounted or unanswered) |
|
|
1868
1940
|
| `StandardSchemaV1` | the Standard Schema v1 type `readInput` takes, declared in `/errors` (type only, so no `@softistx/alxia`; `readInput`'s output is inferred from the schema's `~standard.types`); a Zod 4, Valibot or ArkType schema fits |
|
|
1869
1941
|
|
|
1870
1942
|
From `@softistx/alxia-react-router/session` (`react-router` and `/errors`' files are its only imports):
|
|
@@ -1990,8 +2062,12 @@ From `@softistx/alxia-react-router/oidc` (`react-router`, `/session`'s cookies a
|
|
|
1990
2062
|
|
|
1991
2063
|
| export | |
|
|
1992
2064
|
| --- | --- |
|
|
1993
|
-
| `oidcClient(options)`, `OidcOptions`, `OidcClient`, `OidcUser` | `{ signIn(request), callback(request), oidcUser(request), requireOidcUser(request), logout(request), names }`; `oidcUser` is `{ claims, accessToken, idToken, expiresAt, headers, dpop }`; options `par` (`'auto' \| 'always' \| 'never'`), `dpop` (`{ alg?: 'ES256' \| 'EdDSA' }`), `revokeOnLogout`, `revokeTimeoutMs` and `
|
|
2065
|
+
| `oidcClient(options)`, `OidcOptions`, `OidcClient`, `OidcUser` | `{ signIn(request), callback(request), oidcUser(request), requireOidcUser(request), refresh(user), logout(request), names }`; `oidcUser` is `{ claims, accessToken, idToken, expiresAt, headers, dpop, fetch }`; options `par` (`'auto' \| 'always' \| 'never'`), `dpop` (`{ alg?: 'ES256' \| 'EdDSA' }`), `revokeOnLogout`, `revokeTimeoutMs`, `onRevokeError`, `refreshSkewSeconds` (seconds before the end to refresh, 60) and `refreshFlightMs` (ms a refresh is shared by parallel requests, 10000; `oidcClient` throws a `TypeError` at start-up unless it is finite and from 0 to 2147483647, see [troubleshooting](docs/troubleshooting.md#typeerror-oidcclient-refreshflightms-must-be-a-finite-number-of-milliseconds-from-0-to-2147483647-oidc)) |
|
|
1994
2066
|
| `generateDpopKey(alg?)`, `signDpopProof(key, { method, url, accessToken?, nonce? })`, `DpopKey`, `DpopBinding`, `DpopAlgorithm`, `DpopProofInput` | DPoP proofs (RFC 9449) for code that keeps its own key; `OidcUser.dpop` is a `DpopBinding` (`thumbprint`, `proof`, `headers`, `fetch`) or `null` |
|
|
2067
|
+
| `oidcFromEnv(source?)`, `OidcEnvSource` (`{ prefix?, env?, readFile?, statFile? }`), `OidcEnvOptions` (what it returns), `OidcEnvError` | async: the issuer, client id and secret, redirect URI (the issuer's and redirect URIs are `https:`, or `http:` on loopback: `localhost`, `127.0.0.1`, `[::1]`), session secret (each secret from `<NAME>_FILE`, a single-value file only its owner can read, or `<NAME>`), cookie name and post-logout address from `OIDC_*` variables, to spread into `oidcClient` (`secure` stays yours); one `OidcEnvError` (`problems`) lists everything wrong |
|
|
2068
|
+
| `signInRoute(oidc, options?)`, `callbackRoute(oidc, options?)`, `signOutRoute(oidc, options?)`, `SignInRouteOptions` (`guard`), `CallbackRouteOptions` (`guard`, `onError`, `errorPath`), `SignOutRouteOptions` (`guard`, `origin`, `redirectTo`) | the route modules' `loader` and `action`: sign-in redirects to the issuer; callback answers an `OidcError` (a redirect to `errorPath?sign-in-error=<code>` by default); sign-out is a same-site POST that calls `logout` (RP-initiated when discovery has `end_session_endpoint`) |
|
|
2069
|
+
| `dpopFetch(oidc, user, options?)`, `DpopFetchOptions` (`onUser`), `DpopFetch` | `fetch` for API calls as the user: `Authorization: DPoP` and a proof (`htm`, `htu`, `ath`, `jti`), one retry on `use_dpop_nonce`; it refreshes an ended token with `oidc.refresh` from the last user it got; `Bearer` on a bearer session |
|
|
2070
|
+
| `oidc.refresh(user, { force? })` | the user refreshed from its own tokens (not the request's cookie, whose refresh token a rotation spends) when its access token ends within `refreshSkewSeconds`, else `user` itself (`force` refreshes anyway); its `headers` hold the `Set-Cookie` |
|
|
1995
2071
|
| `OidcError`, `OidcErrorCode` | what `callback` throws: a `code` and the `headers` that clear the spent challenge |
|
|
1996
2072
|
|
|
1997
2073
|
From `@softistx/alxia-react-router/api-keys` (`react-router` is its only import):
|
|
@@ -2075,7 +2151,7 @@ The `alxia-react-router` bin, run with `bunx`:
|
|
|
2075
2151
|
## Documentation
|
|
2076
2152
|
|
|
2077
2153
|
- [Documentation index](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/README.md): every page, and when to read it.
|
|
2078
|
-
- [A relying party of an OIDC issuer](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/oidc.md): `oidcClient`, the
|
|
2154
|
+
- [A relying party of an OIDC issuer](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/oidc.md): `oidcClient`, `oidcFromEnv`, the route helpers, `dpopFetch`, the options and the limits.
|
|
2079
2155
|
- [Flow docs per role](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/help.md): the `docs/flows` format, loading, `useHelpFlows`, the lazy `HelpPanel`, `useGuideRole` and the coverage check.
|
|
2080
2156
|
- [Getting started](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/getting-started.md): a new app, the official template or an existing app.
|
|
2081
2157
|
- [How it works](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/how-it-works.md): dev, the build and `vite preview`, and what the build sets for Bun.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HOME2,
|
|
3
|
-
safeNext2
|
|
4
|
-
|
|
3
|
+
safeNext2,
|
|
4
|
+
sitePath
|
|
5
|
+
} from "./index-t68hwhz1.js";
|
|
5
6
|
|
|
6
7
|
// src/session/model/link-post.ts
|
|
7
8
|
var LINK_JSON_HEADER2 = "x-alxia-link";
|
|
@@ -56,18 +57,6 @@ async function postLinkArgs2(path, body, fields, options = {}) {
|
|
|
56
57
|
return refusal;
|
|
57
58
|
}
|
|
58
59
|
var postLinkRequest2 = (path, email, options) => postLinkArgs2(path, { input: { email } }, ["email"], options);
|
|
59
|
-
// src/session/model/site-path.ts
|
|
60
|
-
function sitePath(path, {
|
|
61
|
-
label,
|
|
62
|
-
query = false
|
|
63
|
-
}) {
|
|
64
|
-
if (safeNext2(path) !== path || !query && /[?#]/.test(path)) {
|
|
65
|
-
const shown = query ? path : path.replace(/[?#].*$/s, "?…");
|
|
66
|
-
throw new TypeError(`${label} must be a path of this site${query ? "" : " with no query or fragment"}, starting with a single "/"; got ${JSON.stringify(shown)}.`);
|
|
67
|
-
}
|
|
68
|
-
return path;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
60
|
// src/session/model/paths.ts
|
|
72
61
|
var SIGN_IN_PATHS2 = {
|
|
73
62
|
signIn: "/sign-in",
|
|
@@ -90,7 +79,7 @@ function secondFactorPath2(next, path = SIGN_IN_PATHS2.secondFactor) {
|
|
|
90
79
|
}
|
|
91
80
|
// src/session/model/second-factor.ts
|
|
92
81
|
var TOTP_CODE2 = /^\d{6}$/;
|
|
93
|
-
export { LINK_JSON_HEADER2, postLinkArgs2, postLinkRequest2,
|
|
82
|
+
export { LINK_JSON_HEADER2, postLinkArgs2, postLinkRequest2, SIGN_IN_PATHS2, signInPath2, secondFactorPath2, TOTP_CODE2 };
|
|
94
83
|
|
|
95
|
-
//# debugId=
|
|
96
|
-
//# sourceMappingURL=index-
|
|
84
|
+
//# debugId=A46C333FD85A700C64756E2164756E21
|
|
85
|
+
//# sourceMappingURL=index-5hjhzztk.js.map
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/session/model/link-post.ts", "../src/session/model/
|
|
3
|
+
"sources": ["../src/session/model/link-post.ts", "../src/session/model/paths.ts", "../src/session/model/second-factor.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/** The refusal a promise-based auth form takes back: `form`, a wait, a field's word. */\nexport type LinkPostRefusal<F extends string = string> = {\n\tform?: string | undefined;\n\tretryAfter?: number | undefined;\n} & { [K in F]?: string | undefined };\n\n/** The request header that asks a link route for its redirects as data; `postLinkArgs` sends it. */\nexport const LINK_JSON_HEADER = 'x-alxia-link';\n\nexport interface LinkPostOptions {\n\t/** The `fetch` to use; the global one by default. */\n\treadonly fetch?: typeof fetch | undefined;\n\t/**\n\t * Where a `{ redirect }` answer leads; `location.assign`, or\n\t * `location.replace` when the answer says `replace` (the token page's\n\t * entry must not stay in the history), by default.\n\t */\n\treadonly navigate?:\n\t\t| ((location: string, how: { readonly replace: boolean }) => void)\n\t\t| undefined;\n\t/** The form's message for a failed call or an answer with no shape; English by default. */\n\treadonly unreachable?: string | undefined;\n}\n\nconst text = (value: unknown): string | undefined =>\n\ttypeof value === 'string' ? value : undefined;\n\nconst UNREACHABLE = 'Something went wrong. Try again.';\n\n/**\n * Posts `body` as JSON to a link route (whose action runs through\n * `handingOver`) and maps the answer to a promise form's refusal:\n * `undefined` when it is accepted (`sent`, or a `{ redirect }` it follows),\n * else `{ form, retryAfter, ...fields }`, `fields` naming the `fieldErrors`\n * to carry over. A network failure or an answer with no shape is the form's\n * message, never a success.\n */\nexport async function postLinkArgs<const F extends string>(\n\tpath: string,\n\tbody: unknown,\n\tfields: readonly F[],\n\toptions: LinkPostOptions = {},\n): Promise<LinkPostRefusal<F> | undefined> {\n\tconst send = options.fetch ?? fetch;\n\tconst unreachable = options.unreachable ?? UNREACHABLE;\n\tlet answer: Record<string, unknown> | undefined;\n\tlet ok = false;\n\ttry {\n\t\tconst response = await send(path, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/json',\n\t\t\t\t[LINK_JSON_HEADER]: 'json',\n\t\t\t},\n\t\t\tbody: JSON.stringify(body),\n\t\t\tcredentials: 'same-origin',\n\t\t});\n\t\tok = response.ok;\n\t\tconst parsed: unknown = await response.json().catch(() => undefined);\n\t\tif (parsed && typeof parsed === 'object') {\n\t\t\tanswer = parsed as Record<string, unknown>;\n\t\t}\n\t} catch {\n\t\treturn { form: unreachable } as LinkPostRefusal<F>;\n\t}\n\tconst redirect = text(answer?.['redirect']);\n\tif (ok && redirect !== undefined) {\n\t\tconst replace = answer?.['replace'] === true;\n\t\t(\n\t\t\toptions.navigate ??\n\t\t\t((to, how) =>\n\t\t\t\thow.replace\n\t\t\t\t\t? globalThis.location.replace(to)\n\t\t\t\t\t: globalThis.location.assign(to))\n\t\t)(redirect, { replace });\n\t\treturn undefined;\n\t}\n\tif (ok && answer?.['sent'] === true) return undefined;\n\tconst refusal: Record<string, string | number | undefined> = {\n\t\tform: text(answer?.['formError']),\n\t\tretryAfter:\n\t\t\ttypeof answer?.['retryAfter'] === 'number'\n\t\t\t\t? answer['retryAfter']\n\t\t\t\t: undefined,\n\t};\n\tconst errors = answer?.['fieldErrors'];\n\tif (errors && typeof errors === 'object') {\n\t\tfor (const field of fields) {\n\t\t\trefusal[field] = text((errors as Record<string, unknown>)[field]);\n\t\t}\n\t}\n\tif (refusal['form'] === undefined && !fields.some((f) => refusal[f])) {\n\t\trefusal['form'] = unreachable;\n\t}\n\treturn refusal as LinkPostRefusal<F>;\n}\n\n/** Requests a mail's link: posts `{ input: { email } }`; see {@link postLinkArgs}. */\nexport const postLinkRequest = (\n\tpath: string,\n\temail: string,\n\toptions?: LinkPostOptions,\n) => postLinkArgs(path, { input: { email } }, ['email'], options);\n",
|
|
6
|
-
"import { safeNext } from './safe-next';\n\n/**\n * A path of this site, or a `TypeError` naming `label`. With no `query`, the\n * path holds no `?` or `#` either, and the message prints it only up to\n * there, since what follows may be a token.\n */\nexport function sitePath(\n\tpath: string,\n\t{\n\t\tlabel,\n\t\tquery = false,\n\t}: { readonly label: string; readonly query?: boolean | undefined },\n): string {\n\tif (safeNext(path) !== path || (!query && /[?#]/.test(path))) {\n\t\tconst shown = query ? path : path.replace(/[?#].*$/s, '?…');\n\t\tthrow new TypeError(\n\t\t\t`${label} must be a path of this site${query ? '' : ' with no query or fragment'}, starting with a single \"/\"; got ${JSON.stringify(shown)}.`,\n\t\t);\n\t}\n\treturn path;\n}\n",
|
|
7
6
|
"import { HOME, safeNext } from './safe-next';\nimport { sitePath } from './site-path';\n\n/** The two pages of a sign-in. */\nexport interface SignInPaths {\n\treadonly signIn: string;\n\treadonly secondFactor: string;\n}\n\n/** The defaults: `/sign-in` and `/sign-in/second-factor`. */\nexport const SIGN_IN_PATHS: SignInPaths = {\n\tsignIn: '/sign-in',\n\tsecondFactor: '/sign-in/second-factor',\n};\n\nfunction withNext(\n\tpath: string,\n\tnext: string,\n\tquery?: Record<string, string>,\n): string {\n\tconst params = new URLSearchParams(query);\n\tconst target = safeNext(next);\n\tif (target !== HOME) params.set('next', target);\n\tconst search = params.toString();\n\treturn search ? `${path}?${search}` : path;\n}\n\n/**\n * The sign-in page's URL, coming back to `next` (none for the home page, and\n * `next` goes through `safeNext`). `query` adds parameters, such as\n * `{ expired: '1' }`; `path` replaces `/sign-in` and must be a path of this\n * site with no query or fragment (a `TypeError` otherwise).\n *\n * @example\n * signInPath('/orders'); // '/sign-in?next=%2Forders'\n * signInPath('/', { query: { expired: '1' } }); // '/sign-in?expired=1'\n */\nexport function signInPath(\n\tnext: string,\n\toptions: {\n\t\treadonly query?: Record<string, string> | undefined;\n\t\treadonly path?: string | undefined;\n\t} = {},\n): string {\n\tconst path =\n\t\toptions.path === undefined\n\t\t\t? SIGN_IN_PATHS.signIn\n\t\t\t: sitePath(options.path, { label: 'signInPath(): options.path' });\n\treturn withNext(path, next, options.query);\n}\n\n/** The second-factor page's URL, coming back to `next` as `signInPath` does. */\nexport function secondFactorPath(\n\tnext: string,\n\tpath: string = SIGN_IN_PATHS.secondFactor,\n): string {\n\treturn withNext(path, next);\n}\n",
|
|
8
7
|
"/** A code of an authenticator app: six digits. */\nexport const TOTP_CODE: RegExp = /^\\d{6}$/;\n\n/**\n * What a second-factor form sends: `code` is the issued code (an app's, or\n * the one mailed), `recovery` a recovery code. Janus has no name for it, only\n * `confirm` and `recover`.\n */\nexport type SecondFactorKind = 'code' | 'recovery';\n\n/** How a sign-in ended, in `@softistx/janus`'s words (`SignInResult['status']`). */\nexport type SignInStatus = 'signedIn' | 'secondFactor';\n\n/**\n * How a step-up is confirmed, in `@softistx/janus`'s words: a code mailed to the\n * current address, or the account's second factor.\n */\nexport type StepUpVia = 'email' | 'secondFactor';\n"
|
|
9
8
|
],
|
|
10
|
-
"mappings": "
|
|
11
|
-
"debugId": "
|
|
9
|
+
"mappings": ";;;;;;;AAOO,IAAM,oBAAmB;AAiBhC,IAAM,OAAO,CAAC,UACb,OAAO,UAAU,WAAW,QAAQ;AAErC,IAAM,cAAc;AAUb,eAAe,aAAoC,CACzD,MACA,MACA,QACA,UAA2B,CAAC,GACc;AAAA,EAC1C,MAAM,OAAO,QAAQ,SAA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Q,EAAE,GAAG;AAAA,IACrE,QAAQ,UAAU;AAAA,EACnB;AAAA,EACA,OAAO;AAAA;AAID,IAAM,mBAAkB,CAC9B,MACA,OACA,YACI,cAAa,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,GAAG,OAAO;;AC5FzD,IAAM,iBAA6B;AAAA,EACzC,QAAQ;AAAA,EACR,cAAc;AACf;AAEA,SAAS,QAAQ,CAChB,MACA,MACA,OACS;AAAA,EACT,MAAM,SAAS,IAAI,gBAAgB,KAAK;AAAA,EACxC,MAAM,SAAS,UAAS,IAAI;AAAA,EAC5B,IAAI,WAAW;AAAA,IAAM,OAAO,IAAI,QAAQ,MAAM;AAAA,EAC9C,MAAM,SAAS,OAAO,SAAS;AAAA,EAC/B,OAAO,SAAS,GAAG,QAAQ,WAAW;AAAA;AAahC,SAAS,WAAU,CACzB,MACA,UAGI,CAAC,GACI;AAAA,EACT,MAAM,OACL,QAAQ,SAAS,YACd,eAAc,SACd,SAAS,QAAQ,MAAM,EAAE,OAAO,6BAA6B,CAAC;AAAA,EAClE,OAAO,SAAS,MAAM,MAAM,QAAQ,KAAK;AAAA;AAInC,SAAS,iBAAgB,CAC/B,MACA,OAAe,eAAc,cACpB;AAAA,EACT,OAAO,SAAS,MAAM,IAAI;AAAA;;ACvDpB,IAAM,aAAoB;",
|
|
10
|
+
"debugId": "A46C333FD85A700C64756E2164756E21",
|
|
12
11
|
"names": []
|
|
13
12
|
}
|
|
@@ -2,21 +2,6 @@ import {
|
|
|
2
2
|
isCrossSite
|
|
3
3
|
} from "./index-mscfme4r.js";
|
|
4
4
|
|
|
5
|
-
// src/errors/page-path.ts
|
|
6
|
-
function nextOf2(url) {
|
|
7
|
-
const { pathname, searchParams } = new URL(url);
|
|
8
|
-
const trimmed = pathname.endsWith("/_.data") ? pathname.slice(0, -"_.data".length) : pathname.replace(/\.data$/, "");
|
|
9
|
-
const path = trimmed.replace(/^\/{2,}/, "/");
|
|
10
|
-
const params = new URLSearchParams(searchParams);
|
|
11
|
-
params.delete("_routes");
|
|
12
|
-
for (const value of params.getAll("index")) {
|
|
13
|
-
if (!value)
|
|
14
|
-
params.delete("index", value);
|
|
15
|
-
}
|
|
16
|
-
const search = params.toString();
|
|
17
|
-
return search ? `${path}?${search}` : path;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
5
|
// src/errors/same-site.ts
|
|
21
6
|
import { data } from "react-router";
|
|
22
7
|
function siteCheck(origin) {
|
|
@@ -48,7 +33,7 @@ function requireSameSite2(request, from) {
|
|
|
48
33
|
siteCheck(from?.origin)(request);
|
|
49
34
|
}
|
|
50
35
|
|
|
51
|
-
export {
|
|
36
|
+
export { siteCheck, rememberSiteCheck, hasSiteCheck, requireSameSite2 };
|
|
52
37
|
|
|
53
|
-
//# debugId=
|
|
54
|
-
//# sourceMappingURL=index-
|
|
38
|
+
//# debugId=27123DBDBE71E46964756E2164756E21
|
|
39
|
+
//# sourceMappingURL=index-6zx9dfvs.js.map
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/errors/
|
|
3
|
+
"sources": ["../src/errors/same-site.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * The page a request is for, as `next` carries it back after sign-in: its\n * path and search, without React Router's single-fetch details. A client\n * navigation's `request.url` is `/todos/demo/list.data?q=a&_routes=…`\n * (`/_.data` for `/`, `?index` for an index action), as the server\n * runtime's own `normalizeUrl` strips them.\n */\nexport function nextOf(url: string): string {\n\tconst { pathname, searchParams } = new URL(url);\n\tconst trimmed = pathname.endsWith('/_.data')\n\t\t? pathname.slice(0, -'_.data'.length)\n\t\t: pathname.replace(/\\.data$/, '');\n\t// `new URL('http://h/\\\\evil.com')` has the path `//evil.com`: never let a\n\t// `next` start with two slashes, which a redirect reads as another site.\n\tconst path = trimmed.replace(/^\\/{2,}/, '/');\n\tconst params = new URLSearchParams(searchParams);\n\tparams.delete('_routes');\n\t// An empty `index` names the index route; a valued one is the page's own.\n\tfor (const value of params.getAll('index')) {\n\t\tif (!value) params.delete('index', value);\n\t}\n\tconst search = params.toString();\n\treturn search ? `${path}?${search}` : path;\n}\n",
|
|
6
5
|
"import { data } from 'react-router';\nimport { isCrossSite } from './cross-site';\nimport type { JsonActions } from './json-actions';\n\n/** Refuses a request from another site with a 403; reads headers only. */\nexport type SiteCheck = (request: Request) => void;\n\n/**\n * The same-site rule of `readJson`: an `Origin` that is not the app's own, or\n * a `Sec-Fetch-Site` that is neither `same-origin` nor `none`, is a 403.\n * `origin` is the app's configured origin (or a getter), else the request's.\n */\nexport function siteCheck(\n\torigin?: string | (() => string | undefined) | undefined,\n): SiteCheck {\n\treturn (request) => {\n\t\tconst set = typeof origin === 'function' ? origin() : origin;\n\t\tif (isCrossSite(request, set)) {\n\t\t\tthrow data('Cross-site request refused', { status: 403 });\n\t\t}\n\t};\n}\n\n/**\n * Where a `jsonActions` instance keeps its site check: an enumerable property\n * under a registered symbol, so it survives `{ ...json }` and a second copy of\n * the package. Not public.\n */\nexport const SITE_CHECK = Symbol.for(\n\t'@softistx/alxia-react-router:site-check@1',\n);\n\n/** Puts the check on a `jsonActions` instance. */\nexport function rememberSiteCheck(actions: object, check: SiteCheck): void {\n\tObject.defineProperty(actions, SITE_CHECK, {\n\t\tvalue: check,\n\t\tenumerable: true,\n\t\twritable: false,\n\t});\n}\n\n/** Whether `actions` carries a site check, as every `jsonActions()` instance does. */\nexport const hasSiteCheck = (actions: object): boolean =>\n\ttypeof (actions as Record<symbol, unknown>)[SITE_CHECK] === 'function';\n\n/**\n * Refuses a cross-site request with the rule of the `jsonActions` instance\n * (its configured origin, read at each request); an object without a check\n * gets the request's own origin. It reads headers only, never the body.\n */\nexport function refuseCrossSite(actions: object, request: Request): void {\n\tconst check = (actions as Record<symbol, unknown>)[SITE_CHECK];\n\t(typeof check === 'function' ? (check as SiteCheck) : siteCheck())(request);\n}\n\n/** Options of {@link requireSameSite}. */\nexport interface SameSiteOptions {\n\t/**\n\t * The origin a request must come from, such as `https://app.example.com`:\n\t * required behind a TLS-terminating proxy, where the request's own URL\n\t * says `http:`. A getter is read at each request. Else the request's own\n\t * origin, which is right for a host that serves several tenants.\n\t */\n\torigin?: string | (() => string | undefined);\n}\n\n/**\n * The same-site guard for any POST, a native form or JSON: throws a 403\n * `Cross-site request refused` for an `Origin` that is not the app's own\n * (`Origin: null` and a foreign origin included) and for a `Sec-Fetch-Site`\n * that is neither `same-origin` nor `none`. A request with no `Origin` and no\n * `Sec-Fetch-Site` (a non-browser client, an old browser) goes on, as it does\n * for `readJson`: CSRF is a browser attack, and a browser sends one of them.\n * It reads headers only, never the body, so the form can still be read after.\n *\n * Pass a `jsonActions()` instance to apply its configured origin, or\n * `{ origin }`; else the request's own origin is the reference.\n */\nexport function requireSameSite(\n\trequest: Request,\n\tfrom?: JsonActions | SameSiteOptions,\n): void {\n\tif (from && hasSiteCheck(from)) {\n\t\trefuseCrossSite(from, request);\n\t\treturn;\n\t}\n\tsiteCheck((from as SameSiteOptions | undefined)?.origin)(request);\n}\n"
|
|
7
6
|
],
|
|
8
|
-
"mappings": ";;;;;
|
|
9
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;AAAA;AAYO,SAAS,SAAS,CACxB,QACY;AAAA,EACZ,OAAO,CAAC,YAAY;AAAA,IACnB,MAAM,MAAM,OAAO,WAAW,aAAa,OAAO,IAAI;AAAA,IACtD,IAAI,YAAY,SAAS,GAAG,GAAG;AAAA,MAC9B,MAAM,KAAK,8BAA8B,EAAE,QAAQ,IAAI,CAAC;AAAA,IACzD;AAAA;AAAA;AASK,IAAM,aAAa,OAAO,IAChC,2CACD;AAGO,SAAS,iBAAiB,CAAC,SAAiB,OAAwB;AAAA,EAC1E,OAAO,eAAe,SAAS,YAAY;AAAA,IAC1C,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,UAAU;AAAA,EACX,CAAC;AAAA;AAIK,IAAM,eAAe,CAAC,YAC5B,OAAQ,QAAoC,gBAAgB;AAOtD,SAAS,eAAe,CAAC,SAAiB,SAAwB;AAAA,EACxE,MAAM,QAAS,QAAoC;AAAA,GAClD,OAAO,UAAU,aAAc,QAAsB,UAAU,GAAG,OAAO;AAAA;AA0BpE,SAAS,gBAAe,CAC9B,SACA,MACO;AAAA,EACP,IAAI,QAAQ,aAAa,IAAI,GAAG;AAAA,IAC/B,gBAAgB,MAAM,OAAO;AAAA,IAC7B;AAAA,EACD;AAAA,EACA,UAAW,MAAsC,MAAM,EAAE,OAAO;AAAA;",
|
|
8
|
+
"debugId": "27123DBDBE71E46964756E2164756E21",
|
|
10
9
|
"names": []
|
|
11
10
|
}
|
|
@@ -2,6 +2,9 @@ import {
|
|
|
2
2
|
useFetcherAnswer2
|
|
3
3
|
} from "./index-zyg8amjc.js";
|
|
4
4
|
|
|
5
|
+
// src/errors/use-json-fetcher.ts
|
|
6
|
+
import { useFetcher } from "react-router";
|
|
7
|
+
|
|
5
8
|
// src/fetcher/use-fetcher-promise.ts
|
|
6
9
|
import { useCallback, useEffect, useRef } from "react";
|
|
7
10
|
class FetcherPromiseAborted2 extends Error {
|
|
@@ -84,7 +87,27 @@ function useFetcherPromise2(fetcher, options = {}) {
|
|
|
84
87
|
}, []);
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
|
|
90
|
+
// src/errors/use-json-fetcher.ts
|
|
91
|
+
function useJsonFetcher2(key, action) {
|
|
92
|
+
const fetcher = useFetcher(key ? { key } : undefined);
|
|
93
|
+
const run = useFetcherPromise2(fetcher);
|
|
94
|
+
const post = async (body, to = action) => {
|
|
95
|
+
try {
|
|
96
|
+
return await run(() => fetcher.submit(body, {
|
|
97
|
+
method: "post",
|
|
98
|
+
encType: "application/json",
|
|
99
|
+
...to ? { action: to } : {}
|
|
100
|
+
}));
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (error instanceof FetcherPromiseAborted2 || error instanceof FetcherPromiseNoAnswer2)
|
|
103
|
+
return;
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return { fetcher, post, busy: fetcher.state !== "idle" };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { FetcherPromiseAborted2, FetcherPromiseNoAnswer2, useFetcherPromise2, useJsonFetcher2 };
|
|
88
111
|
|
|
89
|
-
//# debugId=
|
|
90
|
-
//# sourceMappingURL=index-
|
|
112
|
+
//# debugId=F6CA255DE3ED570564756E2164756E21
|
|
113
|
+
//# sourceMappingURL=index-c721mm5a.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/fetcher/use-fetcher-promise.ts"],
|
|
3
|
+
"sources": ["../src/errors/use-json-fetcher.ts", "../src/fetcher/use-fetcher-promise.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"import { type FetcherWithComponents, useFetcher } from 'react-router';\nimport {\n\tFetcherPromiseAborted,\n\tFetcherPromiseNoAnswer,\n\tuseFetcherPromise,\n} from '../fetcher/use-fetcher-promise';\n\ntype AnswerOf<Action> = ReturnType<typeof useFetcher<Action>>['data'];\n\n/** What a fetcher can post as JSON. */\nexport type JsonBody = Parameters<FetcherWithComponents<unknown>['submit']>[0];\n\n/**\n * A fetcher posting JSON to its page's action (which reads it with\n * `readJson`, and answers `fetcherResult` or the like): `post` sends a\n * body, `busy` while it is in flight. `key` shares the fetcher between the\n * form that posts and the component that reads the answer; `action` posts to\n * another route's action instead (a resource route's, such as a\n * `notifications/poll`). `post` takes the target of one call as its second\n * argument (a list's rows each post to their own record's action).\n *\n * `post` resolves with the action's answer (a refusal included, so\n * `const answer = await post(body)` works), which `fetcher.data` holds too.\n * It settles once the fetcher is idle again (the loaders have revalidated).\n * It resolves with `undefined` when the call was replaced by a newer one, the\n * component unmounted, or the action answered nothing: a caller ignoring the\n * result needs no `catch`. A `submit` that throws still rejects.\n */\nexport function useJsonFetcher<Action, Body extends JsonBody = JsonBody>(\n\tkey?: string,\n\taction?: string,\n): {\n\tfetcher: ReturnType<typeof useFetcher<Action>>;\n\tpost(body: Body, to?: string): Promise<AnswerOf<Action> | undefined>;\n\tbusy: boolean;\n} {\n\tconst fetcher = useFetcher<Action>(key ? { key } : undefined);\n\tconst run = useFetcherPromise<AnswerOf<Action>>(fetcher);\n\tconst post = async (body: Body, to = action) => {\n\t\ttry {\n\t\t\treturn await run(() =>\n\t\t\t\tfetcher.submit(body, {\n\t\t\t\t\tmethod: 'post',\n\t\t\t\t\tencType: 'application/json',\n\t\t\t\t\t...(to ? { action: to } : {}),\n\t\t\t\t}),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\terror instanceof FetcherPromiseAborted ||\n\t\t\t\terror instanceof FetcherPromiseNoAnswer\n\t\t\t)\n\t\t\t\treturn undefined;\n\t\t\tthrow error;\n\t\t}\n\t};\n\treturn { fetcher, post, busy: fetcher.state !== 'idle' };\n}\n",
|
|
5
6
|
"import { useCallback, useEffect, useRef } from 'react';\nimport { type AnswerSource, useFetcherAnswer } from './use-fetcher-answer';\n\n/** What `useFetcherPromise` accepts. */\nexport interface FetcherPromiseOptions<Data> {\n\t/**\n\t * Decides whether an answer is a refusal: the message (or the `Error`) the\n\t * promise rejects with, `undefined` to resolve with the answer. Read from a\n\t * ref, so a new function each render is fine. Without it every answer\n\t * resolves.\n\t */\n\trefusal?: (answer: Data) => string | Error | undefined;\n}\n\n/** The rejection of a call replaced by a newer one, or cut off by an unmount. */\nexport class FetcherPromiseAborted extends Error {\n\toverride readonly name = 'FetcherPromiseAborted';\n\treadonly reason: 'superseded' | 'unmounted';\n\tconstructor(reason: 'superseded' | 'unmounted') {\n\t\tsuper(\n\t\t\treason === 'superseded'\n\t\t\t\t? 'useFetcherPromise: a newer call replaced this one before the fetcher answered'\n\t\t\t\t: 'useFetcherPromise: the component unmounted before the fetcher answered',\n\t\t);\n\t\tthis.reason = reason;\n\t}\n}\n\n/**\n * The rejection of a call whose submission ended, the fetcher idle again,\n * without a new answer: the action answered `null`, `undefined` or the very\n * data the fetcher already held.\n */\nexport class FetcherPromiseNoAnswer extends Error {\n\toverride readonly name = 'FetcherPromiseNoAnswer';\n\tconstructor() {\n\t\tsuper(\n\t\t\t'useFetcherPromise: the submission ended without a new answer (the action answered null, undefined or the same data)',\n\t\t);\n\t}\n}\n\ninterface Waiting<Data> {\n\tresolve(answer: Data): void;\n\treject(error: unknown): void;\n}\n\n/**\n * Ties one submission to its answer. `run(submit)` calls `submit` (usually\n * `() => fetcher.submit(...)`) and returns a Promise settled by the fetcher's\n * next new answer (see `useFetcherAnswer`): it resolves with the answer, or\n * rejects with an `Error` when `options.refusal` returns a message for it. An\n * answer the fetcher already held when `run` was called never settles it.\n *\n * A second `run` while one is pending rejects the older promise with a\n * `FetcherPromiseAborted` (`'superseded'`) and waits for the answer to the\n * newer one. A submission that ends, the fetcher idle again, without a new\n * answer (the action answered `null`, `undefined` or the same data) rejects\n * it with a `FetcherPromiseNoAnswer`. An unmount rejects the pending promise with a\n * `FetcherPromiseAborted` (`'unmounted'`). A `submit` that throws (or whose\n * promise rejects) rejects the promise with that error, and so does a\n * `refusal` that throws. `run` is stable.\n *\n * Catch every promise `run` returns: an abort rejects it, and one nobody\n * handles is an unhandled rejection. Ignore the aborts with\n * `.catch((e) => { if (!(e instanceof FetcherPromiseAborted)) throw e; })`.\n */\nexport function useFetcherPromise<Data>(\n\tfetcher: AnswerSource<Data>,\n\toptions: FetcherPromiseOptions<Data> = {},\n): (submit: () => void | Promise<unknown>) => Promise<Data> {\n\tconst waiting = useRef<Waiting<Data> | null>(null);\n\tconst refusal = useRef(options.refusal);\n\trefusal.current = options.refusal;\n\n\tuseFetcherAnswer(fetcher, (answer) => {\n\t\tconst pending = waiting.current;\n\t\tif (!pending) return;\n\t\twaiting.current = null;\n\t\tlet refused: string | Error | undefined;\n\t\ttry {\n\t\t\trefused = refusal.current?.(answer);\n\t\t} catch (error) {\n\t\t\tpending.reject(error);\n\t\t\treturn;\n\t\t}\n\t\tif (refused === undefined) pending.resolve(answer);\n\t\telse\n\t\t\tpending.reject(\n\t\t\t\ttypeof refused === 'string' ? new Error(refused) : refused,\n\t\t\t);\n\t});\n\n\t// Runs after `useFetcherAnswer`'s effect: a new answer has already settled\n\t// the call, so a call still waiting once the fetcher is idle again, having\n\t// seen it busy, got no answer.\n\tconst busy = useRef(false);\n\tconst lastWaiting = useRef<Waiting<Data> | null>(null);\n\tuseEffect(() => {\n\t\tconst pending = waiting.current;\n\t\tif (pending !== lastWaiting.current) {\n\t\t\tlastWaiting.current = pending;\n\t\t\tbusy.current = false;\n\t\t}\n\t\tif (!pending) return;\n\t\tif (fetcher.state !== 'idle') {\n\t\t\tbusy.current = true;\n\t\t\treturn;\n\t\t}\n\t\tif (!busy.current) return;\n\t\tbusy.current = false;\n\t\twaiting.current = null;\n\t\tpending.reject(new FetcherPromiseNoAnswer());\n\t});\n\n\tuseEffect(\n\t\t() => () => {\n\t\t\tconst pending = waiting.current;\n\t\t\twaiting.current = null;\n\t\t\tpending?.reject(new FetcherPromiseAborted('unmounted'));\n\t\t},\n\t\t[],\n\t);\n\n\treturn useCallback((submit) => {\n\t\twaiting.current?.reject(new FetcherPromiseAborted('superseded'));\n\t\treturn new Promise<Data>((resolve, reject) => {\n\t\t\tconst mine: Waiting<Data> = { resolve, reject };\n\t\t\twaiting.current = mine;\n\t\t\tconst fail = (error: unknown) => {\n\t\t\t\tif (waiting.current === mine) waiting.current = null;\n\t\t\t\treject(error);\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tPromise.resolve(submit()).catch(fail);\n\t\t\t} catch (error) {\n\t\t\t\tfail(error);\n\t\t\t}\n\t\t});\n\t}, []);\n}\n"
|
|
6
7
|
],
|
|
7
|
-
"mappings": ";;;;;AAAA;AAeO,MAAM,+BAA8B,MAAM;AAAA,EAC9B,OAAO;AAAA,EAChB;AAAA,EACT,WAAW,CAAC,QAAoC;AAAA,IAC/C,MACC,WAAW,eACR,kFACA,wE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AAO,CAAC,UAAmB;AAAA,QAChC,IAAI,QAAQ,YAAY;AAAA,UAAM,QAAQ,UAAU;AAAA,QAChD,OAAO,KAAK;AAAA;AAAA,MAEb,IAAI;AAAA,QACH,QAAQ,QAAQ,OAAO,CAAC,EAAE,MAAM,IAAI;AAAA,QACnC,OAAO,OAAO;AAAA,QACf,KAAK,KAAK;AAAA;AAAA,KAEX;AAAA,KACC,CAAC,CAAC;AAAA;;;AD/GC,SAAS,eAAwD,CACvE,KACA,QAKC;AAAA,EACD,MAAM,UAAU,WAAmB,MAAM,EAAE,IAAI,IAAI,SAAS;AAAA,EAC5D,MAAM,MAAM,mBAAoC,OAAO;AAAA,EACvD,MAAM,OAAO,OAAO,MAAY,KAAK,WAAW;AAAA,IAC/C,IAAI;AAAA,MACH,OAAO,MAAM,IAAI,MAChB,QAAQ,OAAO,MAAM;AAAA,QACpB,QAAQ;AAAA,QACR,SAAS;AAAA,WACL,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;AAAA,MAC5B,CAAC,CACF;AAAA,MACC,OAAO,OAAO;AAAA,MACf,IACC,iBAAiB,0BACjB,iBAAiB;AAAA,QAEjB;AAAA,MACD,MAAM;AAAA;AAAA;AAAA,EAGR,OAAO,EAAE,SAAS,MAAM,MAAM,QAAQ,UAAU,OAAO;AAAA;",
|
|
9
|
+
"debugId": "F6CA255DE3ED570564756E2164756E21",
|
|
9
10
|
"names": []
|
|
10
11
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/errors/page-path.ts
|
|
2
|
+
function nextOf2(url) {
|
|
3
|
+
const { pathname, searchParams } = new URL(url);
|
|
4
|
+
const trimmed = pathname.endsWith("/_.data") ? pathname.slice(0, -"_.data".length) : pathname.replace(/\.data$/, "");
|
|
5
|
+
const path = trimmed.replace(/^\/{2,}/, "/");
|
|
6
|
+
const params = new URLSearchParams(searchParams);
|
|
7
|
+
params.delete("_routes");
|
|
8
|
+
for (const value of params.getAll("index")) {
|
|
9
|
+
if (!value)
|
|
10
|
+
params.delete("index", value);
|
|
11
|
+
}
|
|
12
|
+
const search = params.toString();
|
|
13
|
+
return search ? `${path}?${search}` : path;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { nextOf2 };
|
|
17
|
+
|
|
18
|
+
//# debugId=1DAAE75E98DF109564756E2164756E21
|
|
19
|
+
//# sourceMappingURL=index-njfh26ez.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors/page-path.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * The page a request is for, as `next` carries it back after sign-in: its\n * path and search, without React Router's single-fetch details. A client\n * navigation's `request.url` is `/todos/demo/list.data?q=a&_routes=…`\n * (`/_.data` for `/`, `?index` for an index action), as the server\n * runtime's own `normalizeUrl` strips them.\n */\nexport function nextOf(url: string): string {\n\tconst { pathname, searchParams } = new URL(url);\n\tconst trimmed = pathname.endsWith('/_.data')\n\t\t? pathname.slice(0, -'_.data'.length)\n\t\t: pathname.replace(/\\.data$/, '');\n\t// `new URL('http://h/\\\\evil.com')` has the path `//evil.com`: never let a\n\t// `next` start with two slashes, which a redirect reads as another site.\n\tconst path = trimmed.replace(/^\\/{2,}/, '/');\n\tconst params = new URLSearchParams(searchParams);\n\tparams.delete('_routes');\n\t// An empty `index` names the index route; a valued one is the page's own.\n\tfor (const value of params.getAll('index')) {\n\t\tif (!value) params.delete('index', value);\n\t}\n\tconst search = params.toString();\n\treturn search ? `${path}?${search}` : path;\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAOO,SAAS,OAAM,CAAC,KAAqB;AAAA,EAC3C,QAAQ,UAAU,iBAAiB,IAAI,IAAI,GAAG;AAAA,EAC9C,MAAM,UAAU,SAAS,SAAS,SAAS,IACxC,SAAS,MAAM,GAAG,CAAC,SAAS,MAAM,IAClC,SAAS,QAAQ,WAAW,EAAE;AAAA,EAGjC,MAAM,OAAO,QAAQ,QAAQ,WAAW,GAAG;AAAA,EAC3C,MAAM,SAAS,IAAI,gBAAgB,YAAY;AAAA,EAC/C,OAAO,OAAO,SAAS;AAAA,EAEvB,WAAW,SAAS,OAAO,OAAO,OAAO,GAAG;AAAA,IAC3C,IAAI,CAAC;AAAA,MAAO,OAAO,OAAO,SAAS,KAAK;AAAA,EACzC;AAAA,EACA,MAAM,SAAS,OAAO,SAAS;AAAA,EAC/B,OAAO,SAAS,GAAG,QAAQ,WAAW;AAAA;",
|
|
8
|
+
"debugId": "1DAAE75E98DF109564756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/session/model/safe-next.ts
|
|
2
|
+
var HOME2 = "/";
|
|
3
|
+
var BASE = "http://next.invalid";
|
|
4
|
+
function safeNext2(value) {
|
|
5
|
+
if (!value || value.length > 2000)
|
|
6
|
+
return HOME2;
|
|
7
|
+
if (!value.startsWith("/") || value.startsWith("//"))
|
|
8
|
+
return HOME2;
|
|
9
|
+
if (/[\\\p{Cc}\s]/u.test(value))
|
|
10
|
+
return HOME2;
|
|
11
|
+
try {
|
|
12
|
+
const url = new URL(value, BASE);
|
|
13
|
+
const path = `${url.pathname}${url.search}${url.hash}`;
|
|
14
|
+
if (url.origin !== BASE || path.startsWith("//"))
|
|
15
|
+
return HOME2;
|
|
16
|
+
return path;
|
|
17
|
+
} catch {
|
|
18
|
+
return HOME2;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/session/model/site-path.ts
|
|
23
|
+
function sitePath(path, {
|
|
24
|
+
label,
|
|
25
|
+
query = false
|
|
26
|
+
}) {
|
|
27
|
+
if (safeNext2(path) !== path || !query && /[?#]/.test(path)) {
|
|
28
|
+
const shown = query ? path : path.replace(/[?#].*$/s, "?…");
|
|
29
|
+
throw new TypeError(`${label} must be a path of this site${query ? "" : " with no query or fragment"}, starting with a single "/"; got ${JSON.stringify(shown)}.`);
|
|
30
|
+
}
|
|
31
|
+
return path;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { HOME2, safeNext2, sitePath };
|
|
35
|
+
|
|
36
|
+
//# debugId=C4B60C470707A4A864756E2164756E21
|
|
37
|
+
//# sourceMappingURL=index-t68hwhz1.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/session/model/safe-next.ts"],
|
|
3
|
+
"sources": ["../src/session/model/safe-next.ts", "../src/session/model/site-path.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/** Where a sign-in lands when `next` is missing or unsafe. */\nexport const HOME = '/';\n\n/** The base a `next` is resolved against; `.invalid` never resolves. */\nconst BASE = 'http://next.invalid';\n\n/**\n * The `next` a sign-in may redirect to: a path of this site only. Anything\n * that could leave it (`//host`, `/\\host`, `https://…`, `javascript:…`, a\n * control character a browser would strip, a value over 2000 characters)\n * falls back to `/`. The path is read after normalisation, so `/a/..//host`\n * is refused too.\n *\n * @example\n * safeNext('/orders?page=2'); // '/orders?page=2'\n * safeNext('//evil.test'); // '/'\n */\nexport function safeNext(value: string | null | undefined): string {\n\tif (!value || value.length > 2000) return HOME;\n\tif (!value.startsWith('/') || value.startsWith('//')) return HOME;\n\t// Browsers read `\\` as `/` and drop tabs and newlines in URLs.\n\tif (/[\\\\\\p{Cc}\\s]/u.test(value)) return HOME;\n\ttry {\n\t\tconst url = new URL(value, BASE);\n\t\tconst path = `${url.pathname}${url.search}${url.hash}`;\n\t\t// Dot segments can collapse into `//host` again: check what is answered.\n\t\tif (url.origin !== BASE || path.startsWith('//')) return HOME;\n\t\treturn path;\n\t} catch {\n\t\treturn HOME;\n\t}\n}\n"
|
|
5
|
+
"/** Where a sign-in lands when `next` is missing or unsafe. */\nexport const HOME = '/';\n\n/** The base a `next` is resolved against; `.invalid` never resolves. */\nconst BASE = 'http://next.invalid';\n\n/**\n * The `next` a sign-in may redirect to: a path of this site only. Anything\n * that could leave it (`//host`, `/\\host`, `https://…`, `javascript:…`, a\n * control character a browser would strip, a value over 2000 characters)\n * falls back to `/`. The path is read after normalisation, so `/a/..//host`\n * is refused too.\n *\n * @example\n * safeNext('/orders?page=2'); // '/orders?page=2'\n * safeNext('//evil.test'); // '/'\n */\nexport function safeNext(value: string | null | undefined): string {\n\tif (!value || value.length > 2000) return HOME;\n\tif (!value.startsWith('/') || value.startsWith('//')) return HOME;\n\t// Browsers read `\\` as `/` and drop tabs and newlines in URLs.\n\tif (/[\\\\\\p{Cc}\\s]/u.test(value)) return HOME;\n\ttry {\n\t\tconst url = new URL(value, BASE);\n\t\tconst path = `${url.pathname}${url.search}${url.hash}`;\n\t\t// Dot segments can collapse into `//host` again: check what is answered.\n\t\tif (url.origin !== BASE || path.startsWith('//')) return HOME;\n\t\treturn path;\n\t} catch {\n\t\treturn HOME;\n\t}\n}\n",
|
|
6
|
+
"import { safeNext } from './safe-next';\n\n/**\n * A path of this site, or a `TypeError` naming `label`. With no `query`, the\n * path holds no `?` or `#` either, and the message prints it only up to\n * there, since what follows may be a token.\n */\nexport function sitePath(\n\tpath: string,\n\t{\n\t\tlabel,\n\t\tquery = false,\n\t}: { readonly label: string; readonly query?: boolean | undefined },\n): string {\n\tif (safeNext(path) !== path || (!query && /[?#]/.test(path))) {\n\t\tconst shown = query ? path : path.replace(/[?#].*$/s, '?…');\n\t\tthrow new TypeError(\n\t\t\t`${label} must be a path of this site${query ? '' : ' with no query or fragment'}, starting with a single \"/\"; got ${JSON.stringify(shown)}.`,\n\t\t);\n\t}\n\treturn path;\n}\n"
|
|
6
7
|
],
|
|
7
|
-
"mappings": ";AACO,IAAM,QAAO;AAGpB,IAAM,OAAO;AAaN,SAAS,SAAQ,CAAC,OAA0C;AAAA,EAClE,IAAI,CAAC,SAAS,MAAM,SAAS;AAAA,IAAM,OAAO;AAAA,EAC1C,IAAI,CAAC,MAAM,WAAW,GAAG,KAAK,MAAM,WAAW,IAAI;AAAA,I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A,EACA,OAAO;AAAA;",
|
|
9
|
+
"debugId": "C4B60C470707A4A864756E2164756E21",
|
|
9
10
|
"names": []
|
|
10
11
|
}
|
package/dist/errors/index.js
CHANGED
|
@@ -21,18 +21,21 @@ import {
|
|
|
21
21
|
fetcherResult
|
|
22
22
|
} from "../chunks/index-pghmb2dm.js";
|
|
23
23
|
import {
|
|
24
|
-
nextOf2,
|
|
25
24
|
siteCheck,
|
|
26
25
|
rememberSiteCheck,
|
|
27
26
|
requireSameSite2
|
|
28
|
-
} from "../chunks/index-
|
|
27
|
+
} from "../chunks/index-6zx9dfvs.js";
|
|
28
|
+
import"../chunks/index-zyg8amjc.js";
|
|
29
29
|
import {
|
|
30
30
|
useJsonFetcher2
|
|
31
|
-
} from "../chunks/index-
|
|
31
|
+
} from "../chunks/index-c721mm5a.js";
|
|
32
32
|
import {
|
|
33
33
|
isRouteRefusal2,
|
|
34
34
|
routeRefusalStatus2
|
|
35
35
|
} from "../chunks/index-thyabr5n.js";
|
|
36
|
+
import {
|
|
37
|
+
nextOf2
|
|
38
|
+
} from "../chunks/index-njfh26ez.js";
|
|
36
39
|
// src/errors/code-resolver.ts
|
|
37
40
|
var API_CODE = /^[a-z][a-zA-Z0-9-]*\.errors\.[a-z0-9-]+$/;
|
|
38
41
|
function paramsCode(issue) {
|
|
@@ -584,5 +587,5 @@ export {
|
|
|
584
587
|
waitMinutes2 as waitMinutes
|
|
585
588
|
};
|
|
586
589
|
|
|
587
|
-
//# debugId=
|
|
590
|
+
//# debugId=655EDCFB341A48B864756E2164756E21
|
|
588
591
|
//# sourceMappingURL=index.js.map
|
package/dist/errors/index.js.map
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"import type { ReactNode } from 'react';\nimport type { ApiMessages, CatalogueMessages } from './messages';\n\nexport interface ApiMessagesProviderProps<L extends string> {\n\t/** The store `apiCodeResolver` reads. */\n\tmessages: ApiMessages<L>;\n\t/** The messages the root's data carries, by language. */\n\tvalue: Readonly<Record<L, CatalogueMessages>> | undefined;\n\tchildren: ReactNode;\n}\n\n/**\n * Fills the browser's catalogue with the messages the root's data carries\n * (the few its forms word), before the children render: `apiCodeResolver`\n * reads them synchronously. A server render writes nothing: the server's\n * store holds the whole, fresher catalogue, and a render's data may be older\n * than it. It is a plain function (no JSX, no React runtime): use it as\n * `ApiMessagesProvider({ messages, value, children })` from a component, or\n * as an element's type.\n */\nexport function ApiMessagesProvider<L extends string>({\n\tmessages,\n\tvalue,\n\tchildren,\n}: ApiMessagesProviderProps<L>): ReactNode {\n\tconst inBrowser =\n\t\ttypeof (globalThis as { document?: unknown }).document !== 'undefined';\n\tif (value && inBrowser) {\n\t\tfor (const [language, held] of Object.entries<CatalogueMessages>(value)) {\n\t\t\tmessages.add(language as L, held);\n\t\t}\n\t}\n\treturn children;\n}\n",
|
|
21
21
|
"import { data } from 'react-router';\nimport type { ApiErrors } from './api-errors';\nimport { formRefusal } from './form-refusal';\n\n/**\n * What a record route's action answers to one posted section (`intent`):\n * done, or refused with the form's message, the messages by form field, and\n * whether someone changed the record since it was read. Built by\n * `sectionAction`, read by `useSectionSave` and `useRowSave`\n * (`@softistx/alxia-react-router/fetcher`).\n */\nexport type SectionResult =\n\t| { ok: true; intent: string }\n\t| {\n\t\t\tok: false;\n\t\t\tintent: string;\n\t\t\t/** The message for the form as a whole; empty when every issue found its field. */\n\t\t\terror: string;\n\t\t\t/** Messages by form field, already translated. */\n\t\t\tfieldErrors: Record<string, string>;\n\t\t\t/** Whether the API refused because the record changed since it was read. */\n\t\t\tstale: boolean;\n\t };\n\n/** What `sectionAction` takes besides the write. */\nexport interface SectionActionOptions {\n\t/** The form field an input path of the API's refusal belongs under, or `undefined` for none. */\n\tfieldOf: (path: string) => string | undefined;\n\t/** Whether the failure is the API's version conflict (the app's own check of its error). */\n\tisStale: (error: unknown) => boolean;\n}\n\n/**\n * Runs one section's write for a route's action: `{ ok: true, intent }`, or\n * the refusal `useSectionSave` shows (the API's field issues under the form\n * fields `fieldOf` names, a version conflict flagged by `isStale`), answered\n * with the refusal's status. A 401 and any other failure are thrown for the\n * error page, as `formRefusal` does.\n */\nexport async function sectionAction<L extends string>(\n\terrors: Pick<ApiErrors<L>, 'apiRefusal' | 'fieldErrors'>,\n\tlanguage: L,\n\tintent: string,\n\trun: () => Promise<unknown>,\n\t{ fieldOf, isStale }: SectionActionOptions,\n) {\n\ttry {\n\t\tawait run();\n\t\treturn { ok: true, intent } satisfies SectionResult;\n\t} catch (error) {\n\t\tconst { status, ...refusal } = formRefusal(\n\t\t\terrors,\n\t\t\terror,\n\t\t\tlanguage,\n\t\t\tfieldOf,\n\t\t);\n\t\treturn data(\n\t\t\t{\n\t\t\t\tok: false,\n\t\t\t\tintent,\n\t\t\t\tstale: isStale(error),\n\t\t\t\t...refusal,\n\t\t\t} satisfies SectionResult,\n\t\t\t{ status },\n\t\t);\n\t}\n}\n"
|
|
22
22
|
],
|
|
23
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBO,IAAM,WAAW;AA8BxB,SAAS,UAAU,CAAC,OAAsB;AAAA,EACzC,MAAM,OAAQ,MAAM,QAA2C;AAAA,EAC/D,OAAO,OAAO,SAAS,WAAW,OAAO;AAAA;AAYnC,SAAS,eAAiC,CAChD,UACA,SACqB;AAAA,EACrB,MAAM,YAAY,CAAC,QAClB,QAAQ,YAAY,QAAQ,UAAU,GAAG,IAAI,SAAS,KAAK,GAAG;AAAA,EAC/D,OAAO;AAAA,IACN,SAAS,CAAC,KAAK,SAAS,iBAAiB;AAAA,MACxC,IAAI,CAAC,UAAU,GAAG;AAAA,QACjB,OAAO,QAAQ,UAAU,KAAK,SAAS,eAAe;AAAA,MACvD,MAAM,WACL,OAAO,oBAAoB,aACxB,gBAAgB,IACf,mBAAmB,QAAQ,SAAS;AAAA,MACzC,OAAO,SAAS,WAAW,KAAK,SAAS,QAAQ,KAAK;AAAA;AAAA,IAEvD,MAAM,CAAC,OAAO;AAAA,MACb,OAAO,QA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
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type FetcherWithComponents, useFetcher } from 'react-router';
|
|
2
|
+
type AnswerOf<Action> = ReturnType<typeof useFetcher<Action>>['data'];
|
|
2
3
|
/** What a fetcher can post as JSON. */
|
|
3
4
|
export type JsonBody = Parameters<FetcherWithComponents<unknown>['submit']>[0];
|
|
4
5
|
/**
|
|
@@ -9,10 +10,18 @@ export type JsonBody = Parameters<FetcherWithComponents<unknown>['submit']>[0];
|
|
|
9
10
|
* another route's action instead (a resource route's, such as a
|
|
10
11
|
* `notifications/poll`). `post` takes the target of one call as its second
|
|
11
12
|
* argument (a list's rows each post to their own record's action).
|
|
13
|
+
*
|
|
14
|
+
* `post` resolves with the action's answer (a refusal included, so
|
|
15
|
+
* `const answer = await post(body)` works), which `fetcher.data` holds too.
|
|
16
|
+
* It settles once the fetcher is idle again (the loaders have revalidated).
|
|
17
|
+
* It resolves with `undefined` when the call was replaced by a newer one, the
|
|
18
|
+
* component unmounted, or the action answered nothing: a caller ignoring the
|
|
19
|
+
* result needs no `catch`. A `submit` that throws still rejects.
|
|
12
20
|
*/
|
|
13
21
|
export declare function useJsonFetcher<Action, Body extends JsonBody = JsonBody>(key?: string, action?: string): {
|
|
14
22
|
fetcher: ReturnType<typeof useFetcher<Action>>;
|
|
15
|
-
post(body: Body, to?: string): Promise<
|
|
23
|
+
post(body: Body, to?: string): Promise<AnswerOf<Action> | undefined>;
|
|
16
24
|
busy: boolean;
|
|
17
25
|
};
|
|
26
|
+
export {};
|
|
18
27
|
//# sourceMappingURL=use-json-fetcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-json-fetcher.d.ts","sourceRoot":"","sources":["../../src/errors/use-json-fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEtE,uCAAuC;AACvC,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/E
|
|
1
|
+
{"version":3,"file":"use-json-fetcher.d.ts","sourceRoot":"","sources":["../../src/errors/use-json-fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAOtE,KAAK,QAAQ,CAAC,MAAM,IAAI,UAAU,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,uCAAuC;AACvC,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,IAAI,SAAS,QAAQ,GAAG,QAAQ,EACtE,GAAG,CAAC,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,GACb;IACF,OAAO,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC;IACrE,IAAI,EAAE,OAAO,CAAC;CACd,CAsBA"}
|