@hyper.authio/testing 0.0.0-stage → 0.7.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 CHANGED
@@ -1,3 +1,59 @@
1
- # Temporary Holding Version
1
+ # @hyper.authio/testing
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An in-memory Authio realm served over HTTP on loopback, for tests of code built on `@hyper.authio/client`,
4
+ `@hyper.authio/server` or `@hyper.authio/express`.
5
+
6
+ ```bash
7
+ npm install -D @hyper.authio/testing
8
+ ```
9
+
10
+ ```ts
11
+ import { FakeAuthio, ManualClock, createWebhookDelivery } from "@hyper.authio/testing";
12
+
13
+ const authio = await FakeAuthio.start({
14
+ realm: "acme",
15
+ clients: [{ clientId: "orders-api", clientSecret: "secret" }],
16
+ users: [{ sub: "u-1", username: "alice", password: "p", claims: { user_resource_access: { editor: { orders: ["read"] } } } }],
17
+ });
18
+
19
+ const token = await authio.issueAccessToken({
20
+ sub: "u-1",
21
+ audience: "https://orders.example.com",
22
+ scope: "orders:read",
23
+ claims: { groups: ["finance"], org_id: "o-1" },
24
+ });
25
+
26
+ // point the SDK at authio.issuer, then:
27
+ await authio.close();
28
+ ```
29
+
30
+ - Endpoints: discovery (every endpoint it advertises is served), JWKS, authorization, token (client credentials,
31
+ authorization code with ID tokens, refresh with rotation, token exchange including connected accounts, password,
32
+ device code, personal access token), introspection (answered according to who asks, like Authio), revocation,
33
+ UserInfo (JSON, or a signed JWT with `userInfoAsJwt`), device authorization and end session.
34
+ - Sign-in: `authorize(url)` follows an authorization URL as a browser would and returns the callback URL (or, for
35
+ `response_mode=web_message`, the posted parameters). It signs in `signInAs`, the `login_hint` or the first user;
36
+ honours PKCE (S256, plain), `prompt` (`none` answers `login_required` without a session, `login` signs in again),
37
+ `max_age`, `acr_values`, and sends RFC 9207 `iss` (`omitAuthorizationIssuer` leaves it out). ID tokens carry `nonce`,
38
+ `sid`, `auth_time`, `acr`, `amr` and `at_hash`. `createAuthorizationCode` still mints a code directly.
39
+ - Sign-out: the end-session endpoint checks `post_logout_redirect_uri`, echoes `state`, and posts a logout token to the
40
+ `backchannelLogoutUri` of every client of the session (`backchannelDeliveries`); `deliverBackchannelLogout` and
41
+ `createLogoutToken` do it by hand. Ending a session revokes its refresh tokens; `revokeRefreshTokens({ sub | sid })`
42
+ and `revokeToken(token)` revoke them by hand.
43
+ - Refresh tokens carry the session's `sid` through refreshes and are introspectable by the client they were issued to
44
+ (`token_type` `Refresh`), as a BFF's session check needs.
45
+ - JWE: a client with `encryption: { key, algorithm }` (RSA-OAEP or RSA-OAEP-256) gets its ID tokens, UserInfo, and
46
+ optionally access and logout tokens encrypted; `issueAccessToken({ encryptTo })` mints one directly.
47
+ - Personal access tokens: `personalAccessTokens: [{ token: "pat_…", sub, clientId? }]`.
48
+ - Client authentication: `client_secret_basic`, `client_secret_post`, `private_key_jwt` (register `publicKey`) and
49
+ `none`.
50
+ - `issueAccessToken` options: `expiresIn` (negative for an expired token), `type` (`ID` for a non-access token),
51
+ `issuer`, `untrusted` (a signature that does not verify).
52
+ - `failures.set("token", [{ status: 503 }])` answers the next calls to an endpoint with errors; `deviceOutcomes`
53
+ scripts device polling; `connectionResponder` scripts connected-account exchanges; `requests` records every call.
54
+ - `ManualClock` moves only when told to: device polling and cache expiry run instantly.
55
+ - `createWebhookDelivery(type, data, secret)` builds a signed delivery (`body`, `headers`).
56
+
57
+ ## License
58
+
59
+ MIT