@absolutejs/auth 0.53.5 → 0.53.7

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.
@@ -2,7 +2,7 @@ import type { CredentialsConfig } from '../credentials/config';
2
2
  import type { MfaConfig } from '../mfa/config';
3
3
  import type { OnCallbackSuccess, OnRevocationSuccess, OnSignOut } from '../types';
4
4
  import type { AuditEmitter } from './config';
5
- export declare const composeCallbackAudit: <UserType>(onCallbackSuccess: OnCallbackSuccess<UserType>, emit: AuditEmitter) => (context: Parameters<NonNullable<OnCallbackSuccess<UserType>>>[0]) => Promise<void | Response | import("..").StatusReturn | undefined>;
5
+ export declare const composeCallbackAudit: <UserType>(onCallbackSuccess: OnCallbackSuccess<UserType>, emit: AuditEmitter) => (context: Parameters<NonNullable<OnCallbackSuccess<UserType>>>[0]) => Promise<void | Response | import("..").StatusReturn>;
6
6
  export declare const composeCredentialsAudit: <UserType>(credentials: CredentialsConfig<UserType>, emit: AuditEmitter, getUserId?: (user: UserType) => string) => CredentialsConfig<UserType>;
7
7
  export declare const composeMfaAudit: <UserType>(mfa: MfaConfig<UserType>, emit: AuditEmitter) => MfaConfig<UserType>;
8
8
  export declare const composeRevocationAudit: (onRevocationSuccess: OnRevocationSuccess, emit: AuditEmitter) => (context: Parameters<NonNullable<OnRevocationSuccess>>[0]) => Promise<void | undefined>;
package/dist/index.js CHANGED
@@ -3009,14 +3009,28 @@ var createAuditEmitter = ({ auditStore, onAuditEvent, redact }) => async (event)
3009
3009
  await onAuditEvent?.(finalEvent);
3010
3010
  };
3011
3011
 
3012
+ // src/typeGuards.ts
3013
+ var isValidUser = (user) => {
3014
+ return true;
3015
+ };
3016
+ var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
3017
+ var isAuthIntent = (value) => value === "login" || value === "link_identity" || value === "link_connector";
3018
+ var isNonEmptyString = (str) => str !== null && str !== undefined && str.trim() !== "";
3019
+ var isStatusResponse = (value) => typeof value === "object" && value !== null && ("status" in value) && typeof Reflect.get(value, "status") === "number";
3020
+ var isUserSessionId = (key) => UUID_PATTERN.test(key);
3021
+
3012
3022
  // src/audit/wrap.ts
3013
3023
  var composeCallbackAudit = (onCallbackSuccess, emit) => async (context) => {
3024
+ const result = await onCallbackSuccess?.(context);
3025
+ const failed = result instanceof Response && result.status >= 400 || isStatusResponse(result) && Number(Reflect.get(result, "status")) >= 400;
3026
+ if (failed)
3027
+ return result;
3014
3028
  await emit({
3015
3029
  at: Date.now(),
3016
3030
  metadata: { authProvider: context.authProvider },
3017
3031
  type: "oauth_login"
3018
3032
  });
3019
- return onCallbackSuccess?.(context);
3033
+ return result;
3020
3034
  };
3021
3035
  var composeCredentialsAudit = (credentials, emit, getUserId) => ({
3022
3036
  ...credentials,
@@ -3109,16 +3123,6 @@ var composeSignOutAudit = (onSignOut, emit) => async (context) => {
3109
3123
  // src/authorization/protectPermission.ts
3110
3124
  import { Elysia as Elysia3, t as t3 } from "elysia";
3111
3125
 
3112
- // src/typeGuards.ts
3113
- var isValidUser = (user) => {
3114
- return true;
3115
- };
3116
- var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
3117
- var isAuthIntent = (value) => value === "login" || value === "link_identity" || value === "link_connector";
3118
- var isNonEmptyString = (str) => str !== null && str !== undefined && str.trim() !== "";
3119
- var isStatusResponse = (value) => typeof value === "object" && value !== null && ("status" in value) && typeof Reflect.get(value, "status") === "number";
3120
- var isUserSessionId = (key) => UUID_PATTERN.test(key);
3121
-
3122
3126
  // src/session/access.ts
3123
3127
  var collectSessionEntries = (session) => Object.entries(session).filter((entry) => isUserSessionId(entry[0]));
3124
3128
  var collectUnregisteredEntries = (unregisteredSession) => Object.entries(unregisteredSession).filter((entry) => isUserSessionId(entry[0]));
@@ -28096,5 +28100,5 @@ export {
28096
28100
  AuthIdentityConflictError
28097
28101
  };
28098
28102
 
28099
- //# debugId=7567903770EE8C9664756E2164756E21
28103
+ //# debugId=C02B3DE3688EC25964756E2164756E21
28100
28104
  //# sourceMappingURL=index.js.map