@absolutejs/auth 0.45.8 → 0.46.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.
@@ -24,6 +24,7 @@ type SamlAssertionRequest = {
24
24
  type SamlMetadataRequest = {
25
25
  acsUrl: string;
26
26
  connection: SamlConnection;
27
+ sloUrl?: string;
27
28
  };
28
29
  type SamlLogoutRequest = {
29
30
  connection: SamlConnection;
@@ -36,12 +37,18 @@ type SamlLogoutResponseRequest = {
36
37
  connection: SamlConnection;
37
38
  relayState?: string;
38
39
  samlResponse: string;
40
+ signature?: string;
41
+ signatureAlgorithm?: string;
42
+ signedQueryString?: string;
39
43
  sloUrl: string;
40
44
  };
41
45
  type SamlIdpLogoutRequest = {
42
46
  connection: SamlConnection;
43
47
  relayState?: string;
44
48
  samlRequest: string;
49
+ signature?: string;
50
+ signatureAlgorithm?: string;
51
+ signedQueryString?: string;
45
52
  sloUrl: string;
46
53
  };
47
54
  type SamlLogoutResponseAck = {
@@ -1,2 +1,7 @@
1
1
  import type { SamlAdapter } from './config';
2
- export declare const createNodeSamlAdapter: () => Promise<SamlAdapter>;
2
+ export type NodeSamlAdapterOptions = {
3
+ spPrivateKey?: string;
4
+ spCertificate?: string;
5
+ signatureAlgorithm?: 'sha1' | 'sha256' | 'sha512';
6
+ };
7
+ export declare const createNodeSamlAdapter: (options?: NodeSamlAdapterOptions) => Promise<SamlAdapter>;
@@ -135,6 +135,8 @@ export declare const samlSsoRoutes: <UserType>({ authSessionStore, cookieSecure,
135
135
  RelayState?: string | undefined;
136
136
  SAMLResponse?: string | undefined;
137
137
  SAMLRequest?: string | undefined;
138
+ SigAlg?: string | undefined;
139
+ Signature?: string | undefined;
138
140
  };
139
141
  headers: unknown;
140
142
  response: {
package/dist/types.d.ts CHANGED
@@ -196,6 +196,14 @@ export type OnSessionCleanup<UserType> = (({ removedSessions, removedUnregistere
196
196
  export type RouteString = `/${string}`;
197
197
  export type AuthorizeRoute = `${string}/:provider${'' | `/${string}`}`;
198
198
  export type AuthConfig<UserType> = {
199
+ /** Canonical user resolver: load the application user for a session subject
200
+ * (`sub`). REQUIRED, and the single source of truth for `UserType` — every
201
+ * other user-typed callback (`credentials.getUserByEmail`,
202
+ * `sso.getSsoUser`, `onCallbackSuccess`, …) is checked against the shape
203
+ * `getUser` returns (via `NoInfer`), so they cannot disagree. This is also
204
+ * the resolver the package uses to hydrate the typed `user` in
205
+ * `protectRoute`'s context. */
206
+ getUser: (sub: string) => UserType | Promise<UserType>;
199
207
  providersConfiguration: OAuth2ConfigurationOptions;
200
208
  /** Override the `Secure` attribute on every cookie the package sets (session, OAuth state,
201
209
  * code_verifier, SSO nonce, ring, etc.). When omitted, defaults to
@@ -222,36 +230,36 @@ export type AuthConfig<UserType> = {
222
230
  cleanupIntervalMs?: number;
223
231
  maxSessions?: number;
224
232
  sessionDurationMs?: number;
225
- authSessionStore?: AuthSessionStore<UserType>;
233
+ authSessionStore?: AuthSessionStore<NoInfer<UserType>>;
226
234
  /** Append-only audit logging. When present, `auth()` emits structured events
227
235
  * (register, login, mfa_*, password_reset, logout, …) from every flow into the
228
236
  * `auditStore` and/or `onAuditEvent` hook. SOC 2 prerequisite. */
229
- audit?: AuditConfig<UserType>;
237
+ audit?: AuditConfig<NoInfer<UserType>>;
230
238
  /** Local email/password (credentials) block. Additive and optional — when present,
231
239
  * mounts register / verify-email / login / reset-password routes that produce the
232
240
  * same `SessionData<UserType>` as OAuth, transparent to `protectRoute`. */
233
- credentials?: CredentialsConfig<UserType>;
241
+ credentials?: CredentialsConfig<NoInfer<UserType>>;
234
242
  /** Passwordless login: magic links + email/SMS OTP. When present, mounts the magic-link flow
235
243
  * (if `onSendMagicLink` is set) and/or the OTP flow (if `onSendOtp` is set) under
236
244
  * `{passwordlessRoute}`; each verify route resolves the email to a user and mints the same
237
245
  * `SessionData<UserType>` as every other flow. */
238
- passwordless?: PasswordlessConfig<UserType>;
246
+ passwordless?: PasswordlessConfig<NoInfer<UserType>>;
239
247
  /** Multi-factor auth (TOTP + backup codes). When present alongside `credentials`,
240
248
  * `auth()` auto-wires the login MFA gate, mounts the enroll/challenge routes, and
241
249
  * promotes the parked session once a factor is verified. */
242
- mfa?: MfaConfig<UserType>;
250
+ mfa?: MfaConfig<NoInfer<UserType>>;
243
251
  /** Per-identity attempt throttling + account lockout on the credential login route
244
252
  * (progressive: locks after `maxAttempts` failures within `windowMs`). */
245
253
  lockout?: LockoutConfig;
246
254
  /** Self-service session management: `GET /auth/sessions` (list the caller's active
247
255
  * sessions) and `DELETE /auth/sessions/:id` (remote revoke). Requires an
248
256
  * `authSessionStore` that can enumerate sessions. */
249
- sessions?: SessionsConfig<UserType>;
257
+ sessions?: SessionsConfig<NoInfer<UserType>>;
250
258
  /** Per-organization enterprise SSO (the WorkOS-style model). When present, mounts
251
259
  * `GET {ssoRoute}/oidc/:organizationId/authorize` + `.../callback`, resolves the org's
252
260
  * OIDC connection from `ssoConnectionStore`, verifies the id_token in-house against the
253
261
  * issuer's JWKS, and mints the same `SessionData<UserType>` as every other flow. */
254
- sso?: SSOConfig<UserType>;
262
+ sso?: SSOConfig<NoInfer<UserType>>;
255
263
  /** SCIM 2.0 auto-provisioning for enterprise directory sync (Okta / Azure AD). When present,
256
264
  * mounts `{scimRoute}/Users` (+ `/ServiceProviderConfig`) with per-org bearer-token auth via
257
265
  * `scimTokenStore`, and maps SCIM resources to the consumer's user store through hooks. */
@@ -269,12 +277,12 @@ export type AuthConfig<UserType> = {
269
277
  * JWTs signed by a key you own (self-hosted JWKS), refresh-token rotation, and
270
278
  * optional DPoP (RFC 9449) sender-constrained tokens. The authorize endpoint reuses
271
279
  * the package session, so the IdP login gets passkeys / MFA / SSO for free. */
272
- oidc?: OidcProviderConfig<UserType>;
280
+ oidc?: OidcProviderConfig<NoInfer<UserType>>;
273
281
  /** First-class multi-tenancy (the WorkOS model). When present, mounts organization +
274
282
  * membership + invitation routes under `{organizationsRoute}`: list the caller's orgs, create
275
283
  * one (caller becomes owner), invite/accept/revoke by email, and list/remove members. Ties the
276
284
  * bare `organizationId` used by SSO/SCIM/RBAC into a real tenant model with org-scoped roles. */
277
- organizations?: OrganizationsConfig<UserType>;
285
+ organizations?: OrganizationsConfig<NoInfer<UserType>>;
278
286
  /** Admin portal — the WorkOS self-serve "setup link" model, headless. When present, mounts
279
287
  * `{portalRoute}` endpoints a customer's IT admin (holding a scoped setup token from
280
288
  * `createSetupSession`) calls to read the service-provider URLs and configure their own SSO
@@ -283,21 +291,21 @@ export type AuthConfig<UserType> = {
283
291
  /** Org-scoped roles & permissions (builds on `organizations`). When present, mounts routes to
284
292
  * list an org's role definitions and set a member's roles. Pair with
285
293
  * `createMembershipPermissionResolver` to make `authorization.hasPermission` turnkey. */
286
- roles?: RolesConfig<UserType>;
294
+ roles?: RolesConfig<NoInfer<UserType>>;
287
295
  /** Role-based / attribute-based access control (E4). When present, `auth()` exposes a
288
296
  * `protectPermission(check, handler)` derive (alongside `protectRoute`) that delegates the
289
297
  * decision to your `hasPermission` hook — the package stays schema-agnostic about roles. */
290
- authorization?: AuthorizationConfig<UserType>;
298
+ authorization?: AuthorizationConfig<NoInfer<UserType>>;
291
299
  /** GDPR/CCPA self-service compliance (E5). When present, mounts `GET {complianceRoute}/export`
292
300
  * (right to access) and `DELETE {complianceRoute}` (right to erasure — runs your delete hook,
293
301
  * revokes the user's sessions, clears the cookie). Pair with `audit.redact` for PII redaction. */
294
- compliance?: ComplianceConfig<UserType>;
302
+ compliance?: ComplianceConfig<NoInfer<UserType>>;
295
303
  /** Passwordless / passkey auth (WebAuthn). When present, mounts the registration ceremony
296
304
  * (`{webauthnRoute}/register/options` + `/verify`, adds a passkey to the authenticated caller)
297
305
  * and the authentication ceremony (`.../authenticate/options` + `/verify`, passwordless sign-in
298
306
  * → mints the same `SessionData<UserType>`). A `webauthnAdapter` wraps a vetted library (e.g.
299
307
  * `@simplewebauthn/server`); the package never bundles the WebAuthn crypto. */
300
- webauthn?: WebAuthnConfig<UserType>;
308
+ webauthn?: WebAuthnConfig<NoInfer<UserType>>;
301
309
  /** Signed outbound webhooks. When present, every emitted auth event (the audit taxonomy) is
302
310
  * HMAC-signed (Standard Webhooks scheme) and POSTed to each endpoint. Delivery is best-effort
303
311
  * and isolated per endpoint; configuring this alone (without `audit`) is enough to turn on
@@ -311,25 +319,25 @@ export type AuthConfig<UserType> = {
311
319
  * Only available when `UserType` has the fields the fragments render
312
320
  * (`sub` + optional email/name); users that don't enable HTMX are never
313
321
  * constrained. */
314
- htmx?: UserType extends AuthHtmxUser ? AuthHtmxConfig : never;
322
+ htmx?: NoInfer<UserType> extends AuthHtmxUser ? AuthHtmxConfig : never;
315
323
  unregisteredSessionDurationMs?: number;
316
- resolveAuthIntent?: ResolveAuthIntent<UserType>;
324
+ resolveAuthIntent?: ResolveAuthIntent<NoInfer<UserType>>;
317
325
  onAuthorizeSuccess?: OnAuthorizeSuccess;
318
326
  onAuthorizeError?: OnAuthorizeError;
319
- onCallbackSuccess?: OnCallbackSuccess<UserType>;
320
- onLinkIdentity?: OnLinkIdentity<UserType>;
321
- onLinkIdentityConflict?: OnLinkIdentityConflict<UserType>;
322
- onLinkConnector?: OnLinkConnector<UserType>;
327
+ onCallbackSuccess?: OnCallbackSuccess<NoInfer<UserType>>;
328
+ onLinkIdentity?: OnLinkIdentity<NoInfer<UserType>>;
329
+ onLinkIdentityConflict?: OnLinkIdentityConflict<NoInfer<UserType>>;
330
+ onLinkConnector?: OnLinkConnector<NoInfer<UserType>>;
323
331
  onCallbackError?: OnCallbackError;
324
- onStatus?: OnStatus<UserType>;
332
+ onStatus?: OnStatus<NoInfer<UserType>>;
325
333
  onRefreshSuccess?: OnRefreshSuccess;
326
334
  onRefreshError?: OnRefreshError;
327
- onSignOut?: OnSignOut<UserType>;
335
+ onSignOut?: OnSignOut<NoInfer<UserType>>;
328
336
  onRevocationSuccess?: OnRevocationSuccess;
329
337
  onRevocationError?: OnRevocationError;
330
338
  onProfileSuccess?: OnProfileSuccess;
331
339
  onProfileError?: OnProfileError;
332
- onSessionCleanup?: OnSessionCleanup<UserType>;
340
+ onSessionCleanup?: OnSessionCleanup<NoInfer<UserType>>;
333
341
  };
334
342
  /** The serializable subset of `AuthConfig` — the route paths, session durations, and
335
343
  * limits that can live in a data file (`auth.config.ts` via `defineAuthSettings`) and
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.45.8",
2
+ "version": "0.46.0",
3
3
  "name": "@absolutejs/auth",
4
4
  "description": "An authorization library for absolutejs",
5
5
  "repository": {