@softistx/alxia-react-router 0.87.0 → 0.89.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 +72 -3
- 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-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 +5 -3
- package/dist/errors/index.js.map +2 -2
- package/dist/oidc/callback.d.ts +4 -0
- package/dist/oidc/callback.d.ts.map +1 -0
- package/dist/oidc/client.d.ts +57 -0
- package/dist/oidc/client.d.ts.map +1 -0
- package/dist/oidc/context.d.ts +42 -0
- package/dist/oidc/context.d.ts.map +1 -0
- package/dist/oidc/dpop-fetch.d.ts +40 -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 +5 -1
- package/dist/oidc/index.d.ts.map +1 -1
- package/dist/oidc/index.js +614 -326
- package/dist/oidc/index.js.map +19 -7
- package/dist/oidc/logout.d.ts +4 -0
- package/dist/oidc/logout.d.ts.map +1 -0
- package/dist/oidc/refresh.d.ts +10 -0
- package/dist/oidc/refresh.d.ts.map +1 -0
- package/dist/oidc/routes.d.ts +76 -0
- package/dist/oidc/routes.d.ts.map +1 -0
- package/dist/oidc/session.d.ts +7 -0
- package/dist/oidc/session.d.ts.map +1 -0
- package/dist/oidc/signin.d.ts +4 -0
- package/dist/oidc/signin.d.ts.map +1 -0
- package/dist/oidc/stored.d.ts +21 -0
- package/dist/oidc/stored.d.ts.map +1 -0
- package/dist/oidc/tokens.d.ts +13 -0
- package/dist/oidc/tokens.d.ts.map +1 -0
- package/dist/oidc/{oidc.d.ts → types.d.ts} +8 -45
- package/dist/oidc/{oidc.d.ts.map → types.d.ts.map} +1 -1
- package/dist/oidc/user.d.ts +6 -0
- package/dist/oidc/user.d.ts.map +1 -0
- package/dist/pwa/react/index.d.ts +2 -0
- package/dist/pwa/react/index.d.ts.map +1 -1
- package/dist/pwa/react/index.js +264 -3
- package/dist/pwa/react/index.js.map +6 -3
- package/dist/pwa/react/push-status.d.ts +31 -0
- package/dist/pwa/react/push-status.d.ts.map +1 -0
- package/dist/pwa/react/push-store.d.ts +55 -0
- package/dist/pwa/react/push-store.d.ts.map +1 -0
- package/dist/pwa/react/use-push-subscription.d.ts +15 -0
- package/dist/pwa/react/use-push-subscription.d.ts.map +1 -0
- package/dist/pwa/worker/index.d.ts +2 -0
- package/dist/pwa/worker/index.d.ts.map +1 -1
- package/dist/pwa/worker/index.js +94 -4
- package/dist/pwa/worker/index.js.map +7 -6
- package/dist/pwa/worker/plan.d.ts +7 -0
- package/dist/pwa/worker/plan.d.ts.map +1 -1
- package/dist/pwa/worker/push.d.ts +48 -0
- package/dist/pwa/worker/push.d.ts.map +1 -0
- package/dist/pwa/worker/scope.d.ts +23 -0
- package/dist/pwa/worker/scope.d.ts.map +1 -1
- package/dist/pwa/worker/start-worker.d.ts +2 -0
- package/dist/pwa/worker/start-worker.d.ts.map +1 -1
- package/dist/session/index.js +9 -7
- package/dist/session/index.js.map +2 -2
- package/dist/session/model/index.js +2 -2
- package/docs/README.md +1 -1
- package/docs/guide/fetcher.md +13 -0
- package/docs/guide/oidc.md +172 -6
- package/docs/guide/pwa.md +101 -1
- package/docs/roadmap.md +8 -0
- package/docs/troubleshooting.md +127 -0
- package/package.json +7 -7
- package/dist/chunks/index-0786n4qe.js +0 -25
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { OidcClient } from './client';
|
|
2
|
+
import type { OidcUser } from './types';
|
|
3
|
+
/** A `fetch` that calls a resource as one signed-in user. */
|
|
4
|
+
export type DpopFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
5
|
+
/** The part of the relying party `dpopFetch` needs. */
|
|
6
|
+
export type DpopRefresher = Pick<OidcClient, 'refresh'>;
|
|
7
|
+
/** Options of {@link dpopFetch}. */
|
|
8
|
+
export interface DpopFetchOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Called with the new user each time the access token or its expiry changes
|
|
11
|
+
* (parallel calls sharing one refresh report it once). Its `headers` hold the
|
|
12
|
+
* `Set-Cookie` to pass with the route's answer (the last one wins: each refresh
|
|
13
|
+
* starts from the previous user, so the cookie it sets replaces the older one).
|
|
14
|
+
*/
|
|
15
|
+
readonly onUser?: ((user: OidcUser) => void) | undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `fetch` for the calls a loader or an action makes to an API as the signed-in
|
|
19
|
+
* user. On a DPoP-bound session (`oidcClient`'s `dpop` option) each call carries
|
|
20
|
+
* `Authorization: DPoP <token>` and a fresh proof (`htm`, `htu` without its
|
|
21
|
+
* query, `ath`, `jti`), and a `401` with `WWW-Authenticate: DPoP
|
|
22
|
+
* error="use_dpop_nonce"` is signed again with the `DPoP-Nonce` sent and
|
|
23
|
+
* retried once; the nonce is remembered per server. On a bearer session it
|
|
24
|
+
* sends `Authorization: Bearer <token>` through the client's own `fetch`.
|
|
25
|
+
*
|
|
26
|
+
* It keeps the last user it got. Before each call it asks `oidc.refresh` for a
|
|
27
|
+
* fresh one, which refreshes from that user's own tokens (never the request's
|
|
28
|
+
* cookie, whose refresh token a rotation spends) only when the access token
|
|
29
|
+
* ends within `refreshSkewSeconds`. A body must be a string or bytes, since a
|
|
30
|
+
* stream cannot be sent twice.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const user = await oidc.requireOidcUser(request);
|
|
34
|
+
* let latest = user;
|
|
35
|
+
* const api = dpopFetch(oidc, user, { onUser: (next) => (latest = next) });
|
|
36
|
+
* const orders = await (await api('https://api.example.com/orders?page=2')).json();
|
|
37
|
+
* return data({ orders }, { headers: latest.headers });
|
|
38
|
+
*/
|
|
39
|
+
export declare function dpopFetch(oidc: DpopRefresher, user: OidcUser, options?: DpopFetchOptions): DpopFetch;
|
|
40
|
+
//# sourceMappingURL=dpop-fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dpop-fetch.d.ts","sourceRoot":"","sources":["../../src/oidc/dpop-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GAAG,CACvB,KAAK,EAAE,MAAM,GAAG,GAAG,EACnB,IAAI,CAAC,EAAE,WAAW,KACd,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,uDAAuD;AACvD,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAExD,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACzD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CACxB,IAAI,EAAE,aAAa,EACnB,IAAI,EAAE,QAAQ,EACd,OAAO,GAAE,gBAAqB,GAC5B,SAAS,CAgBX"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { OidcOptions } from './types';
|
|
2
|
+
/** Every start-up problem of the environment, in one error. */
|
|
3
|
+
export declare class OidcEnvError extends Error {
|
|
4
|
+
readonly problems: readonly string[];
|
|
5
|
+
readonly name = "OidcEnvError";
|
|
6
|
+
constructor(problems: readonly string[]);
|
|
7
|
+
}
|
|
8
|
+
/** What {@link oidcFromEnv} reads. */
|
|
9
|
+
export interface OidcEnvSource {
|
|
10
|
+
/** The variables' prefix. `'OIDC'` by default (`OIDC_ISSUER`, …). */
|
|
11
|
+
readonly prefix?: string | undefined;
|
|
12
|
+
/** The environment; `process.env` by default. */
|
|
13
|
+
readonly env?: Readonly<Record<string, string | undefined>> | undefined;
|
|
14
|
+
/** Reads a secret file; `Bun.file(path).text()` by default. */
|
|
15
|
+
readonly readFile?: ((path: string) => Promise<string>) | undefined;
|
|
16
|
+
/** Gives a secret file's `mode`, to refuse one that group or others can read; `Bun.file(path).stat()` by default. */
|
|
17
|
+
readonly statFile?: ((path: string) => Promise<{
|
|
18
|
+
readonly mode: number;
|
|
19
|
+
}>) | undefined;
|
|
20
|
+
}
|
|
21
|
+
/** What {@link oidcFromEnv} gives: spread it into `oidcClient`, with `secure`. */
|
|
22
|
+
export type OidcEnvOptions = Pick<OidcOptions, 'issuer' | 'clientId' | 'clientSecret' | 'redirectUri' | 'secret' | 'name' | 'postLogoutRedirectUri'>;
|
|
23
|
+
/**
|
|
24
|
+
* The relying party's settings from the environment, checked once at start-up:
|
|
25
|
+
* every missing or malformed variable is listed in one `OidcEnvError`, never a
|
|
26
|
+
* secret's value. `secure` is not read from the environment: give it to
|
|
27
|
+
* `oidcClient` yourself (`secure: !import.meta.env.DEV`).
|
|
28
|
+
*
|
|
29
|
+
* | variable (prefix `OIDC`) | |
|
|
30
|
+
* | --- | --- |
|
|
31
|
+
* | `OIDC_ISSUER` | required, an `https:` URL (`http:` on loopback) |
|
|
32
|
+
* | `OIDC_CLIENT_ID` | required |
|
|
33
|
+
* | `OIDC_CLIENT_SECRET_FILE` or `OIDC_CLIENT_SECRET` | the secret of a confidential client; none for a public one |
|
|
34
|
+
* | `OIDC_REDIRECT_URI` | required, an `https:` URL (`http:` on loopback) |
|
|
35
|
+
* | `OIDC_SESSION_SECRET_FILE` or `OIDC_SESSION_SECRET` | required, 32 characters or more |
|
|
36
|
+
* | `OIDC_COOKIE_NAME` | `'oidc'` by default |
|
|
37
|
+
* | `OIDC_POST_LOGOUT_REDIRECT_URI` | optional, an `https:` URL (`http:` on loopback) |
|
|
38
|
+
*
|
|
39
|
+
* A `_FILE` variable names a file whose trimmed content is the value, and
|
|
40
|
+
* that only its owner can read (no group or other permission bit), with no
|
|
41
|
+
* whitespace inside; a message never prints the path. Prefer it to the plain
|
|
42
|
+
* variable for a secret.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* export const oidc = oidcClient({
|
|
46
|
+
* ...(await oidcFromEnv()),
|
|
47
|
+
* secure: !import.meta.env.DEV,
|
|
48
|
+
* scopes: ['profile', 'email', 'offline_access'],
|
|
49
|
+
* });
|
|
50
|
+
*/
|
|
51
|
+
export declare function oidcFromEnv(source?: OidcEnvSource): Promise<OidcEnvOptions>;
|
|
52
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/oidc/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,+DAA+D;AAC/D,qBAAa,YAAa,SAAQ,KAAK;IAE1B,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE;IADhD,SAAkB,IAAI,kBAAkB;gBACnB,QAAQ,EAAE,SAAS,MAAM,EAAE;CAKhD;AAED,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC7B,qEAAqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,iDAAiD;IACjD,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,SAAS,CAAC;IACxE,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;IACpE,qHAAqH;IACrH,QAAQ,CAAC,QAAQ,CAAC,EACf,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,GACtD,SAAS,CAAC;CACb;AAED,kFAAkF;AAClF,MAAM,MAAM,cAAc,GAAG,IAAI,CAChC,WAAW,EACT,QAAQ,GACR,UAAU,GACV,cAAc,GACd,aAAa,GACb,QAAQ,GACR,MAAM,GACN,uBAAuB,CACzB,CAAC;AAiHF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,WAAW,CAChC,MAAM,GAAE,aAAkB,GACxB,OAAO,CAAC,cAAc,CAAC,CAqCzB"}
|
package/dist/oidc/index.d.ts
CHANGED
|
@@ -5,7 +5,11 @@
|
|
|
5
5
|
* `react-router`, `/session`'s cookie helpers and `jose` (an optional peer),
|
|
6
6
|
* nothing else.
|
|
7
7
|
*/
|
|
8
|
+
export { type OidcClient, oidcClient } from './client';
|
|
8
9
|
export { type DpopAlgorithm, type DpopBinding, type DpopKey, type DpopProofInput, generateDpopKey, signDpopProof, } from './dpop';
|
|
10
|
+
export { type DpopFetch, type DpopFetchOptions, type DpopRefresher, dpopFetch, } from './dpop-fetch';
|
|
11
|
+
export { OidcEnvError, type OidcEnvOptions, type OidcEnvSource, oidcFromEnv, } from './env';
|
|
9
12
|
export { OidcError, type OidcErrorCode } from './errors';
|
|
10
|
-
export { type
|
|
13
|
+
export { type CallbackRouteOptions, callbackRoute, type SignInRouteOptions, type SignOutRouteOptions, signInRoute, signOutRoute, } from './routes';
|
|
14
|
+
export type { OidcOptions, OidcUser } from './types';
|
|
11
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/oidc/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oidc/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,eAAe,EACf,aAAa,GACb,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EACN,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oidc/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,eAAe,EACf,aAAa,GACb,MAAM,QAAQ,CAAC;AAChB,OAAO,EACN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,SAAS,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,WAAW,GACX,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EACN,KAAK,oBAAoB,EACzB,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,WAAW,EACX,YAAY,GACZ,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC"}
|