@absolutejs/auth 0.26.0-beta.2 → 0.26.0-beta.3

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.
Files changed (39) hide show
  1. package/dist/audit/config.d.ts +2 -1
  2. package/dist/audit/types.d.ts +1 -1
  3. package/dist/authorization/config.d.ts +19 -0
  4. package/dist/authorization/protectPermission.d.ts +52 -0
  5. package/dist/compliance/cipher.d.ts +5 -0
  6. package/dist/compliance/config.d.ts +18 -0
  7. package/dist/compliance/redaction.d.ts +8 -0
  8. package/dist/compliance/routes.d.ts +89 -0
  9. package/dist/htmx/index.js +494 -98
  10. package/dist/htmx/index.js.map +3 -3
  11. package/dist/index.d.ts +2537 -344
  12. package/dist/index.js +3516 -1504
  13. package/dist/index.js.map +32 -13
  14. package/dist/providers/clients.d.ts +3 -3
  15. package/dist/routes/authorize.d.ts +2 -2
  16. package/dist/routes/protectRoute.d.ts +2 -2
  17. package/dist/scim/config.d.ts +55 -0
  18. package/dist/scim/inMemoryScimTokenStore.d.ts +2 -0
  19. package/dist/scim/postgresScimTokenStore.d.ts +102 -0
  20. package/dist/scim/routes.d.ts +296 -0
  21. package/dist/scim/serialize.d.ts +45 -0
  22. package/dist/scim/types.d.ts +52 -0
  23. package/dist/session/promote.d.ts +9 -2
  24. package/dist/sso/config.d.ts +104 -0
  25. package/dist/sso/discoveryRoute.d.ts +63 -0
  26. package/dist/sso/inMemorySsoConnectionStore.d.ts +2 -0
  27. package/dist/sso/oidcRoutes.d.ts +97 -0
  28. package/dist/sso/postgresSsoConnectionStore.d.ts +139 -0
  29. package/dist/sso/samlRoutes.d.ts +176 -0
  30. package/dist/sso/types.d.ts +39 -0
  31. package/dist/typebox.d.ts +1 -1
  32. package/dist/types.d.ts +36 -0
  33. package/dist/webauthn/adapter.d.ts +59 -0
  34. package/dist/webauthn/config.d.ts +35 -0
  35. package/dist/webauthn/inMemoryWebAuthnCredentialStore.d.ts +2 -0
  36. package/dist/webauthn/postgresWebAuthnCredentialStore.d.ts +172 -0
  37. package/dist/webauthn/routes.d.ts +155 -0
  38. package/dist/webauthn/types.d.ts +17 -0
  39. package/package.json +2 -2
@@ -3,6 +3,7 @@ export type AuditConfig<UserType> = {
3
3
  auditStore?: AuditSink;
4
4
  getUserId?: (user: UserType) => string;
5
5
  onAuditEvent?: (event: AuditEvent) => void | Promise<void>;
6
+ redact?: (event: AuditEvent) => AuditEvent | Promise<AuditEvent>;
6
7
  };
7
8
  export type AuditEmitter = (event: AuditEvent) => Promise<void>;
8
- export declare const createAuditEmitter: <UserType>({ auditStore, onAuditEvent }: AuditConfig<UserType>) => (event: AuditEvent) => Promise<void>;
9
+ export declare const createAuditEmitter: <UserType>({ auditStore, onAuditEvent, redact }: AuditConfig<UserType>) => (event: AuditEvent) => Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import type { OrganizationId } from '../tenancy';
2
- export type AuditEventType = 'credentials_login' | 'credentials_login_failed' | 'email_verified' | 'identity_conflict' | 'logout' | 'mfa_challenge' | 'mfa_challenge_failed' | 'mfa_enrolled' | 'oauth_login' | 'password_reset' | 'register' | 'scim_provision' | 'session_revoked' | 'sso_login' | 'token_refreshed' | 'token_revoked';
2
+ export type AuditEventType = 'account_deleted' | 'authorization_denied' | 'credentials_login' | 'credentials_login_failed' | 'data_exported' | 'email_verified' | 'identity_conflict' | 'logout' | 'mfa_challenge' | 'mfa_challenge_failed' | 'mfa_enrolled' | 'oauth_login' | 'password_reset' | 'register' | 'scim_provision' | 'session_revoked' | 'sso_login' | 'token_refreshed' | 'token_revoked' | 'webauthn_authenticated' | 'webauthn_registered';
3
3
  export type AuditEvent = {
4
4
  at: number;
5
5
  ip?: string;
@@ -0,0 +1,19 @@
1
+ import type { AuditEmitter } from '../audit/config';
2
+ import type { AuthSessionStore } from '../session/types';
3
+ import type { OrganizationId } from '../tenancy';
4
+ export type PermissionContext<UserType> = {
5
+ organizationId?: OrganizationId;
6
+ permission: string;
7
+ user: UserType;
8
+ };
9
+ export type AuthorizationConfig<UserType> = {
10
+ hasPermission: (context: PermissionContext<UserType>) => boolean | Promise<boolean>;
11
+ };
12
+ export type PermissionCheck = {
13
+ organizationId?: OrganizationId;
14
+ permission: string;
15
+ };
16
+ export type AuthorizationPluginProps<UserType> = AuthorizationConfig<UserType> & {
17
+ authSessionStore?: AuthSessionStore<UserType>;
18
+ emit?: AuditEmitter;
19
+ };
@@ -0,0 +1,52 @@
1
+ import { Elysia } from 'elysia';
2
+ import type { AuthorizationPluginProps, PermissionCheck } from './config';
3
+ type PermissionFailError = {
4
+ readonly code: 'Bad Request';
5
+ readonly message: 'Cookies are missing';
6
+ } | {
7
+ readonly code: 'Forbidden';
8
+ readonly message: 'Insufficient permissions';
9
+ } | {
10
+ readonly code: 'Unauthorized';
11
+ readonly message: 'User is not authenticated';
12
+ };
13
+ export declare const protectPermissionPlugin: <UserType>({ authSessionStore, emit, hasPermission }: AuthorizationPluginProps<UserType>) => Elysia<"", {
14
+ decorator: {};
15
+ store: {
16
+ session: import("..").SessionRecord<UserType>;
17
+ unregisteredSession: import("..").UnregisteredSessionRecord;
18
+ };
19
+ derive: {
20
+ readonly protectPermission: <AuthReturn, AuthFailReturn>(check: PermissionCheck, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: PermissionFailError) => AuthFailReturn) => Promise<AuthReturn | import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | NonNullable<AuthFailReturn> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | import("elysia").ElysiaCustomStatusResponse<"Forbidden", "Insufficient permissions", 403>>;
21
+ };
22
+ resolve: {};
23
+ }, {
24
+ typebox: {};
25
+ error: {};
26
+ }, {
27
+ schema: import("elysia").UnwrapRoute<{
28
+ cookie: import("@sinclair/typebox").TObject<{
29
+ user_session_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTemplateLiteralSyntax<"${string}-${string}-${string}-${string}-${string}">>;
30
+ }>;
31
+ }, {}, "">;
32
+ standaloneSchema: {};
33
+ macro: {};
34
+ macroFn: {};
35
+ parser: {};
36
+ response: import("elysia").ExtractErrorFromHandle<{
37
+ readonly protectPermission: <AuthReturn, AuthFailReturn>(check: PermissionCheck, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: PermissionFailError) => AuthFailReturn) => Promise<AuthReturn | import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | NonNullable<AuthFailReturn> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | import("elysia").ElysiaCustomStatusResponse<"Forbidden", "Insufficient permissions", 403>>;
38
+ }>;
39
+ }, {}, {
40
+ derive: {};
41
+ resolve: {};
42
+ schema: {};
43
+ standaloneSchema: {};
44
+ response: {};
45
+ }, {
46
+ derive: {};
47
+ resolve: {};
48
+ schema: {};
49
+ standaloneSchema: {};
50
+ response: {};
51
+ }>;
52
+ export {};
@@ -0,0 +1,5 @@
1
+ export type SecretCipher = {
2
+ decrypt: (ciphertext: string) => Promise<string>;
3
+ encrypt: (plaintext: string) => Promise<string>;
4
+ };
5
+ export declare const createSecretCipher: (keyMaterial: string) => SecretCipher;
@@ -0,0 +1,18 @@
1
+ import type { AuditEmitter } from '../audit/config';
2
+ import type { AuthSessionStore } from '../session/types';
3
+ import type { RouteString } from '../types';
4
+ export type ComplianceConfig<UserType> = {
5
+ complianceRoute?: RouteString;
6
+ deleteUserData: (context: {
7
+ user: UserType;
8
+ userId?: string;
9
+ }) => void | Promise<void>;
10
+ exportUserData: (context: {
11
+ user: UserType;
12
+ }) => Record<string, unknown> | Promise<Record<string, unknown>>;
13
+ getUserId?: (user: UserType) => string;
14
+ };
15
+ export type CompliancePluginProps<UserType> = ComplianceConfig<UserType> & {
16
+ authSessionStore?: AuthSessionStore<UserType>;
17
+ emit?: AuditEmitter;
18
+ };
@@ -0,0 +1,8 @@
1
+ import type { AuditEvent } from '../audit/types';
2
+ type AuditRedactorOptions = {
3
+ dropFields?: string[];
4
+ hashFields?: string[];
5
+ redactIp?: boolean;
6
+ };
7
+ export declare const createAuditRedactor: ({ dropFields, hashFields, redactIp }: AuditRedactorOptions) => (event: AuditEvent) => Promise<AuditEvent>;
8
+ export {};
@@ -0,0 +1,89 @@
1
+ import { Elysia } from 'elysia';
2
+ import type { CompliancePluginProps } from './config';
3
+ export declare const complianceRoutes: <UserType>({ authSessionStore, complianceRoute, deleteUserData, emit, exportUserData, getUserId }: CompliancePluginProps<UserType>) => Elysia<"", {
4
+ decorator: {};
5
+ store: {
6
+ session: import("..").SessionRecord<UserType>;
7
+ unregisteredSession: import("..").UnregisteredSessionRecord;
8
+ };
9
+ derive: {};
10
+ resolve: {};
11
+ }, {
12
+ typebox: {};
13
+ error: {};
14
+ }, {
15
+ schema: {};
16
+ standaloneSchema: {};
17
+ macro: {};
18
+ macroFn: {};
19
+ parser: {};
20
+ response: {};
21
+ }, {
22
+ [x: string]: {
23
+ export: {
24
+ get: {
25
+ body: unknown;
26
+ params: {};
27
+ query: unknown;
28
+ headers: unknown;
29
+ response: {
30
+ 200: {
31
+ [x: string]: unknown;
32
+ };
33
+ 401: "Authentication required";
34
+ 422: {
35
+ type: "validation";
36
+ on: string;
37
+ summary?: string;
38
+ message?: string;
39
+ found?: unknown;
40
+ property?: string;
41
+ expected?: string;
42
+ };
43
+ };
44
+ };
45
+ };
46
+ };
47
+ } & {
48
+ [x: string]: {
49
+ delete: {
50
+ body: unknown;
51
+ params: {};
52
+ query: unknown;
53
+ headers: unknown;
54
+ response: {
55
+ 200: {
56
+ readonly deleted: true;
57
+ };
58
+ 401: "Authentication required";
59
+ 422: {
60
+ type: "validation";
61
+ on: string;
62
+ summary?: string;
63
+ message?: string;
64
+ found?: unknown;
65
+ property?: string;
66
+ expected?: string;
67
+ };
68
+ };
69
+ };
70
+ };
71
+ }, {
72
+ derive: {};
73
+ resolve: {};
74
+ schema: {};
75
+ standaloneSchema: {};
76
+ response: {};
77
+ }, {
78
+ derive: {};
79
+ resolve: {};
80
+ schema: {};
81
+ standaloneSchema: {};
82
+ response: {};
83
+ } & {
84
+ derive: {};
85
+ resolve: {};
86
+ schema: {};
87
+ standaloneSchema: {};
88
+ response: {};
89
+ }>;