@nest-boot/auth 8.0.9-beta.1 → 8.0.9-beta.2
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/dist/adapters/mikro-orm/adapter-config.d.ts +5 -0
- package/dist/adapters/mikro-orm/adapter-config.js +5 -0
- package/dist/adapters/mikro-orm/adapter-config.js.map +1 -1
- package/dist/adapters/mikro-orm/create-custom-adapter.d.ts +9 -0
- package/dist/adapters/mikro-orm/create-custom-adapter.js +9 -0
- package/dist/adapters/mikro-orm/create-custom-adapter.js.map +1 -1
- package/dist/adapters/mikro-orm/entity-metadata-resolver.d.ts +7 -0
- package/dist/adapters/mikro-orm/entity-metadata-resolver.js +7 -0
- package/dist/adapters/mikro-orm/entity-metadata-resolver.js.map +1 -1
- package/dist/adapters/mikro-orm/where-compiler.d.ts +7 -0
- package/dist/adapters/mikro-orm/where-compiler.js +11 -0
- package/dist/adapters/mikro-orm/where-compiler.js.map +1 -1
- package/dist/api-key-usage.interceptor.d.ts +10 -2
- package/dist/api-key-usage.interceptor.js +10 -2
- package/dist/api-key-usage.interceptor.js.map +1 -1
- package/dist/auth-handler.middleware.d.ts +14 -3
- package/dist/auth-handler.middleware.js +14 -3
- package/dist/auth-handler.middleware.js.map +1 -1
- package/dist/auth.ability.d.ts +11 -2
- package/dist/auth.ability.js +11 -2
- package/dist/auth.ability.js.map +1 -1
- package/dist/auth.constants.d.ts +4 -1
- package/dist/auth.constants.js +4 -1
- package/dist/auth.constants.js.map +1 -1
- package/dist/auth.guard.d.ts +0 -4
- package/dist/auth.guard.js +0 -4
- package/dist/auth.guard.js.map +1 -1
- package/dist/auth.middleware.d.ts +24 -4
- package/dist/auth.middleware.js +24 -4
- package/dist/auth.middleware.js.map +1 -1
- package/dist/auth.module.d.ts +0 -1
- package/dist/auth.module.js +0 -1
- package/dist/auth.module.js.map +1 -1
- package/dist/decorators/can.decorator.d.ts +6 -1
- package/dist/decorators/can.decorator.js +6 -1
- package/dist/decorators/can.decorator.js.map +1 -1
- package/dist/decorators/public.decorator.d.ts +5 -1
- package/dist/decorators/public.decorator.js +5 -1
- package/dist/decorators/public.decorator.js.map +1 -1
- package/dist/entities/account.entity.d.ts +4 -1
- package/dist/entities/account.entity.js +4 -1
- package/dist/entities/account.entity.js.map +1 -1
- package/dist/entities/invitation.entity.d.ts +4 -1
- package/dist/entities/invitation.entity.js +4 -1
- package/dist/entities/invitation.entity.js.map +1 -1
- package/dist/entities/member-api-key.entity.d.ts +8 -2
- package/dist/entities/member-api-key.entity.js +8 -2
- package/dist/entities/member-api-key.entity.js.map +1 -1
- package/dist/entities/member.entity.d.ts +4 -1
- package/dist/entities/member.entity.js +4 -1
- package/dist/entities/member.entity.js.map +1 -1
- package/dist/features/invitations/invitation.resolver.d.ts +43 -8
- package/dist/features/invitations/invitation.resolver.js +43 -8
- package/dist/features/invitations/invitation.resolver.js.map +1 -1
- package/dist/features/invitations/invitation.service.d.ts +75 -12
- package/dist/features/invitations/invitation.service.js +75 -12
- package/dist/features/invitations/invitation.service.js.map +1 -1
- package/dist/infrastructure/api-key-authentication.service.d.ts +20 -4
- package/dist/infrastructure/api-key-authentication.service.js +20 -4
- package/dist/infrastructure/api-key-authentication.service.js.map +1 -1
- package/dist/infrastructure/api-key-lifecycle.d.ts +31 -5
- package/dist/infrastructure/api-key-lifecycle.js +31 -5
- package/dist/infrastructure/api-key-lifecycle.js.map +1 -1
- package/dist/infrastructure/auth-ability.factory.d.ts +14 -3
- package/dist/infrastructure/auth-ability.factory.js +14 -3
- package/dist/infrastructure/auth-ability.factory.js.map +1 -1
- package/dist/infrastructure/auth-enum-registry.d.ts +4 -1
- package/dist/infrastructure/auth-enum-registry.js +4 -1
- package/dist/infrastructure/auth-enum-registry.js.map +1 -1
- package/dist/infrastructure/auth-service.providers.d.ts +4 -1
- package/dist/infrastructure/auth-service.providers.js +4 -1
- package/dist/infrastructure/auth-service.providers.js.map +1 -1
- package/dist/infrastructure/better-auth-adapter.d.ts +6 -1
- package/dist/infrastructure/better-auth-adapter.js +2 -0
- package/dist/infrastructure/better-auth-adapter.js.map +1 -1
- package/dist/infrastructure/create-auth-instance.d.ts +20 -2
- package/dist/infrastructure/create-auth-instance.js +29 -2
- package/dist/infrastructure/create-auth-instance.js.map +1 -1
- package/dist/infrastructure/create-contextual-auth-service.d.ts +4 -0
- package/dist/infrastructure/create-contextual-auth-service.js +4 -0
- package/dist/infrastructure/create-contextual-auth-service.js.map +1 -1
- package/dist/infrastructure/request-identity.d.ts +88 -19
- package/dist/infrastructure/request-identity.js +88 -19
- package/dist/infrastructure/request-identity.js.map +1 -1
- package/dist/infrastructure/revoked-authentication.exception.d.ts +4 -1
- package/dist/infrastructure/revoked-authentication.exception.js +4 -1
- package/dist/infrastructure/revoked-authentication.exception.js.map +1 -1
- package/dist/interfaces/request-identity-patch.interface.d.ts +4 -1
- package/dist/interfaces/request-permissions.interface.d.ts +4 -1
- package/dist/policies/create-scope-policy.d.ts +7 -1
- package/dist/policies/create-scope-policy.js +7 -1
- package/dist/policies/create-scope-policy.js.map +1 -1
- package/dist/policies/user-scope.policy.d.ts +2 -0
- package/dist/policies/user-scope.policy.js +2 -0
- package/dist/policies/user-scope.policy.js.map +1 -1
- package/dist/policies/workspace-scope.policy.d.ts +2 -0
- package/dist/policies/workspace-scope.policy.js +2 -0
- package/dist/policies/workspace-scope.policy.js.map +1 -1
- package/dist/resolvers/auth.resolver.d.ts +85 -18
- package/dist/resolvers/auth.resolver.js +90 -18
- package/dist/resolvers/auth.resolver.js.map +1 -1
- package/dist/resolvers/member-api-key.resolver.d.ts +26 -5
- package/dist/resolvers/member-api-key.resolver.js +26 -5
- package/dist/resolvers/member-api-key.resolver.js.map +1 -1
- package/dist/resolvers/member.resolver.d.ts +26 -11
- package/dist/resolvers/member.resolver.js +26 -11
- package/dist/resolvers/member.resolver.js.map +1 -1
- package/dist/resolvers/session.resolver.d.ts +59 -12
- package/dist/resolvers/session.resolver.js +59 -12
- package/dist/resolvers/session.resolver.js.map +1 -1
- package/dist/resolvers/user-api-key.resolver.d.ts +26 -5
- package/dist/resolvers/user-api-key.resolver.js +26 -5
- package/dist/resolvers/user-api-key.resolver.js.map +1 -1
- package/dist/resolvers/user.resolver.d.ts +114 -19
- package/dist/resolvers/user.resolver.js +114 -19
- package/dist/resolvers/user.resolver.js.map +1 -1
- package/dist/resolvers/workspace.resolver.d.ts +33 -11
- package/dist/resolvers/workspace.resolver.js +33 -11
- package/dist/resolvers/workspace.resolver.js.map +1 -1
- package/dist/services/account.service.d.ts +11 -2
- package/dist/services/account.service.js +11 -2
- package/dist/services/account.service.js.map +1 -1
- package/dist/services/auth.service.d.ts +132 -27
- package/dist/services/auth.service.js +132 -27
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/member-api-key.service.d.ts +40 -7
- package/dist/services/member-api-key.service.js +40 -7
- package/dist/services/member-api-key.service.js.map +1 -1
- package/dist/services/member.service.d.ts +108 -19
- package/dist/services/member.service.js +108 -19
- package/dist/services/member.service.js.map +1 -1
- package/dist/services/session.service.d.ts +37 -10
- package/dist/services/session.service.js +69 -10
- package/dist/services/session.service.js.map +1 -1
- package/dist/services/user-api-key.service.d.ts +40 -7
- package/dist/services/user-api-key.service.js +40 -7
- package/dist/services/user-api-key.service.js.map +1 -1
- package/dist/services/user-deletion.service.d.ts +7 -1
- package/dist/services/user-deletion.service.js +7 -1
- package/dist/services/user-deletion.service.js.map +1 -1
- package/dist/services/user.service.d.ts +109 -20
- package/dist/services/user.service.js +109 -20
- package/dist/services/user.service.js.map +1 -1
- package/dist/services/workspace.service.d.ts +50 -9
- package/dist/services/workspace.service.js +50 -9
- package/dist/services/workspace.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/lowercase-identifier.type.d.ts +4 -1
- package/dist/utils/api-key-credential.util.d.ts +12 -2
- package/dist/utils/api-key-credential.util.js +12 -2
- package/dist/utils/api-key-credential.util.js.map +1 -1
- package/dist/utils/api-key-permissions.util.d.ts +14 -2
- package/dist/utils/api-key-permissions.util.js +14 -2
- package/dist/utils/api-key-permissions.util.js.map +1 -1
- package/dist/utils/append-metadata.util.d.ts +6 -1
- package/dist/utils/append-metadata.util.js +6 -1
- package/dist/utils/append-metadata.util.js.map +1 -1
- package/dist/utils/apply-auth-response-cookies.util.d.ts +4 -1
- package/dist/utils/apply-auth-response-cookies.util.js +4 -1
- package/dist/utils/apply-auth-response-cookies.util.js.map +1 -1
- package/dist/utils/auth-role.util.d.ts +50 -8
- package/dist/utils/auth-role.util.js +50 -8
- package/dist/utils/auth-role.util.js.map +1 -1
- package/dist/utils/authorize.util.d.ts +6 -1
- package/dist/utils/authorize.util.js +6 -1
- package/dist/utils/authorize.util.js.map +1 -1
- package/dist/utils/build-request-ability.util.d.ts +5 -1
- package/dist/utils/build-request-ability.util.js +5 -1
- package/dist/utils/build-request-ability.util.js.map +1 -1
- package/dist/utils/can.util.d.ts +7 -1
- package/dist/utils/can.util.js +7 -1
- package/dist/utils/can.util.js.map +1 -1
- package/dist/utils/create-email-and-password-config.d.ts +8 -0
- package/dist/utils/create-email-and-password-config.js +8 -0
- package/dist/utils/create-email-and-password-config.js.map +1 -1
- package/dist/utils/create-email-verification-config.d.ts +6 -1
- package/dist/utils/create-email-verification-config.js +6 -1
- package/dist/utils/create-email-verification-config.js.map +1 -1
- package/dist/utils/create-generic-oauth-config.d.ts +7 -1
- package/dist/utils/create-generic-oauth-config.js +7 -1
- package/dist/utils/create-generic-oauth-config.js.map +1 -1
- package/dist/utils/create-oidc-config.d.ts +5 -0
- package/dist/utils/create-oidc-config.js +5 -0
- package/dist/utils/create-oidc-config.js.map +1 -1
- package/dist/utils/create-permission-enum.util.d.ts +5 -1
- package/dist/utils/create-permission-enum.util.js +5 -1
- package/dist/utils/create-permission-enum.util.js.map +1 -1
- package/dist/utils/create-social-provider-config.d.ts +7 -0
- package/dist/utils/create-social-provider-config.js +7 -0
- package/dist/utils/create-social-provider-config.js.map +1 -1
- package/dist/utils/create-social-providers-config.d.ts +6 -0
- package/dist/utils/create-social-providers-config.js +6 -0
- package/dist/utils/create-social-providers-config.js.map +1 -1
- package/dist/utils/create-user-config.d.ts +7 -1
- package/dist/utils/create-user-config.js +7 -1
- package/dist/utils/create-user-config.js.map +1 -1
- package/dist/utils/estimate-entropy.d.ts +0 -1
- package/dist/utils/estimate-entropy.js +0 -1
- package/dist/utils/estimate-entropy.js.map +1 -1
- package/dist/utils/extend-ability.util.d.ts +9 -1
- package/dist/utils/extend-ability.util.js +24 -1
- package/dist/utils/extend-ability.util.js.map +1 -1
- package/dist/utils/extract-api-key.util.d.ts +5 -1
- package/dist/utils/extract-api-key.util.js +5 -1
- package/dist/utils/extract-api-key.util.js.map +1 -1
- package/dist/utils/get-auth-ability.util.d.ts +1 -0
- package/dist/utils/get-auth-ability.util.js +1 -0
- package/dist/utils/get-auth-ability.util.js.map +1 -1
- package/dist/utils/get-current-api-key.util.d.ts +5 -1
- package/dist/utils/get-current-api-key.util.js +5 -1
- package/dist/utils/get-current-api-key.util.js.map +1 -1
- package/dist/utils/has-oidc-env-config.d.ts +4 -0
- package/dist/utils/has-oidc-env-config.js +4 -0
- package/dist/utils/has-oidc-env-config.js.map +1 -1
- package/dist/utils/has-social-provider-credential-env-config.d.ts +5 -0
- package/dist/utils/has-social-provider-credential-env-config.js +5 -0
- package/dist/utils/has-social-provider-credential-env-config.js.map +1 -1
- package/dist/utils/has-social-provider-env-config.d.ts +5 -0
- package/dist/utils/has-social-provider-env-config.js +5 -0
- package/dist/utils/has-social-provider-env-config.js.map +1 -1
- package/dist/utils/is-env-true.d.ts +5 -0
- package/dist/utils/is-env-true.js +5 -0
- package/dist/utils/is-env-true.js.map +1 -1
- package/dist/utils/omit-credentials.util.d.ts +7 -1
- package/dist/utils/omit-credentials.util.js +7 -1
- package/dist/utils/omit-credentials.util.js.map +1 -1
- package/dist/utils/permission-grants.util.d.ts +28 -4
- package/dist/utils/permission-grants.util.js +28 -4
- package/dist/utils/permission-grants.util.js.map +1 -1
- package/dist/utils/resolve-auth-catalog.util.d.ts +6 -1
- package/dist/utils/resolve-auth-catalog.util.js +6 -1
- package/dist/utils/resolve-auth-catalog.util.js.map +1 -1
- package/dist/utils/resolve-effective-permissions.util.d.ts +21 -3
- package/dist/utils/resolve-effective-permissions.util.js +21 -3
- package/dist/utils/resolve-effective-permissions.util.js.map +1 -1
- package/dist/utils/resolve-oidc-prompt.d.ts +4 -0
- package/dist/utils/resolve-oidc-prompt.js +4 -0
- package/dist/utils/resolve-oidc-prompt.js.map +1 -1
- package/dist/utils/resolve-oidc-scopes.d.ts +4 -0
- package/dist/utils/resolve-oidc-scopes.js +4 -0
- package/dist/utils/resolve-oidc-scopes.js.map +1 -1
- package/dist/utils/resolve-request-member.util.d.ts +5 -1
- package/dist/utils/resolve-request-member.util.js +5 -1
- package/dist/utils/resolve-request-member.util.js.map +1 -1
- package/dist/utils/resolve-request-permissions.util.d.ts +10 -2
- package/dist/utils/resolve-request-permissions.util.js +10 -2
- package/dist/utils/resolve-request-permissions.util.js.map +1 -1
- package/dist/utils/resolve-required-oidc-env.d.ts +5 -0
- package/dist/utils/resolve-required-oidc-env.js +5 -0
- package/dist/utils/resolve-required-oidc-env.js.map +1 -1
- package/dist/utils/resolve-required-social-provider-env.d.ts +6 -0
- package/dist/utils/resolve-required-social-provider-env.js +6 -0
- package/dist/utils/resolve-required-social-provider-env.js.map +1 -1
- package/dist/utils/resolve-secret.d.ts +5 -0
- package/dist/utils/resolve-secret.js +5 -0
- package/dist/utils/resolve-secret.js.map +1 -1
- package/dist/utils/resolve-social-provider-enabled.d.ts +5 -0
- package/dist/utils/resolve-social-provider-enabled.js +5 -0
- package/dist/utils/resolve-social-provider-enabled.js.map +1 -1
- package/dist/utils/run-auth-query.d.ts +3 -0
- package/dist/utils/run-auth-query.js +3 -0
- package/dist/utils/run-auth-query.js.map +1 -1
- package/dist/utils/serialize-ability-rules.util.d.ts +5 -1
- package/dist/utils/serialize-ability-rules.util.js +15 -1
- package/dist/utils/serialize-ability-rules.util.js.map +1 -1
- package/dist/utils/split-auth-providers.d.ts +5 -1
- package/dist/utils/split-auth-providers.js +6 -4
- package/dist/utils/split-auth-providers.js.map +1 -1
- package/package.json +17 -23
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { createAuthInstance } from "./create-auth-instance.js";
|
|
2
2
|
type AuthInstance = ReturnType<typeof createAuthInstance>;
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* The upstream API surface consumed by application services.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
4
7
|
export type BetterAuthAdapter = Pick<AuthInstance, "$context"> & {
|
|
5
8
|
api: Pick<AuthInstance["api"], "accountInfo" | "changeEmail" | "changePassword" | "deleteUser" | "getAccessToken" | "getSession" | "linkSocialAccount" | "listSessions" | "listUserAccounts" | "refreshToken" | "requestPasswordReset" | "resetPassword" | "revokeOtherSessions" | "revokeSession" | "revokeSessions" | "sendVerificationEmail" | "setPassword" | "signInEmail" | "signInSocial" | "signOut" | "signUpEmail" | "unlinkAccount" | "updateUser" | "verifyPassword">;
|
|
6
9
|
};
|
|
7
10
|
/**
|
|
8
11
|
* Adapts the untyped Nest injection boundary once, using the factory's upstream types.
|
|
9
12
|
* Domain result normalization and response cookies remain in services and applyAuthResponseCookies.
|
|
13
|
+
* @param auth - Configured Better Auth instance.
|
|
14
|
+
* @returns Better Auth instance viewed through the internal adapter interface.
|
|
10
15
|
* @internal
|
|
11
16
|
*/
|
|
12
17
|
export declare function adaptBetterAuth(auth: unknown): BetterAuthAdapter;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Adapts the untyped Nest injection boundary once, using the factory's upstream types.
|
|
3
3
|
* Domain result normalization and response cookies remain in services and applyAuthResponseCookies.
|
|
4
|
+
* @param auth - Configured Better Auth instance.
|
|
5
|
+
* @returns Better Auth instance viewed through the internal adapter interface.
|
|
4
6
|
* @internal
|
|
5
7
|
*/
|
|
6
8
|
export function adaptBetterAuth(auth) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"better-auth-adapter.js","sourceRoot":"","sources":["../../src/infrastructure/better-auth-adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"better-auth-adapter.js","sourceRoot":"","sources":["../../src/infrastructure/better-auth-adapter.ts"],"names":[],"mappings":"AAsCA;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,OAAO,IAAyB,CAAC;AACnC,CAAC"}
|
|
@@ -4,7 +4,25 @@ import type { Mailer } from "@nest-boot/mailer";
|
|
|
4
4
|
import { betterAuth, type BetterAuthOptions } from "better-auth";
|
|
5
5
|
import { type AuthModuleOptions } from "../auth-module-options.interface.js";
|
|
6
6
|
import type { UserDeletionService } from "../services/user-deletion.service.js";
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Resolves framework configuration before constructing the upstream instance.
|
|
9
|
+
* @param options - Authentication module configuration.
|
|
10
|
+
* @param orm - MikroORM instance used for persistence.
|
|
11
|
+
* @param mailer - Mailer used to deliver authentication emails.
|
|
12
|
+
* @param hashService - Service for hashing and verifying passwords.
|
|
13
|
+
* @param userDeletionService - Service that deletes users and their related records.
|
|
14
|
+
* @returns Better Auth options assembled from the module configuration.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
8
17
|
export declare function resolveBetterAuthOptions(options: AuthModuleOptions, orm: MikroORM, mailer: Mailer, hashService: HashService, userDeletionService: UserDeletionService): BetterAuthOptions;
|
|
9
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Constructs the single BetterAuth instance used by Nest providers.
|
|
20
|
+
* @param options - Authentication module configuration.
|
|
21
|
+
* @param orm - MikroORM instance used for persistence.
|
|
22
|
+
* @param mailer - Mailer used to deliver authentication emails.
|
|
23
|
+
* @param hashService - Service for hashing and verifying passwords.
|
|
24
|
+
* @param userDeletionService - Service that deletes users and their related records.
|
|
25
|
+
* @returns Configured Better Auth instance.
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
10
28
|
export declare function createAuthInstance(options: AuthModuleOptions, orm: MikroORM, mailer: Mailer, hashService: HashService, userDeletionService: UserDeletionService): ReturnType<typeof betterAuth>;
|
|
@@ -20,7 +20,16 @@ import { runAuthQuery } from "../utils/run-auth-query.js";
|
|
|
20
20
|
import { splitAuthProviders } from "../utils/split-auth-providers.js";
|
|
21
21
|
import { DEFAULT_WORKSPACE_CREATOR_ROLE, DEFAULT_WORKSPACE_ROLE, } from "../workspace.constants.js";
|
|
22
22
|
import { RequestIdentity } from "./request-identity.js";
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Resolves framework configuration before constructing the upstream instance.
|
|
25
|
+
* @param options - Authentication module configuration.
|
|
26
|
+
* @param orm - MikroORM instance used for persistence.
|
|
27
|
+
* @param mailer - Mailer used to deliver authentication emails.
|
|
28
|
+
* @param hashService - Service for hashing and verifying passwords.
|
|
29
|
+
* @param userDeletionService - Service that deletes users and their related records.
|
|
30
|
+
* @returns Better Auth options assembled from the module configuration.
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
24
33
|
export function resolveBetterAuthOptions(options, orm, mailer, hashService, userDeletionService) {
|
|
25
34
|
validateAuthOptions(options);
|
|
26
35
|
const secret = resolveSecret(options);
|
|
@@ -66,10 +75,23 @@ export function resolveBetterAuthOptions(options, orm, mailer, hashService, user
|
|
|
66
75
|
copyBetterAuthOptions(betterAuthOptions, options);
|
|
67
76
|
return betterAuthOptions;
|
|
68
77
|
}
|
|
69
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Constructs the single BetterAuth instance used by Nest providers.
|
|
80
|
+
* @param options - Authentication module configuration.
|
|
81
|
+
* @param orm - MikroORM instance used for persistence.
|
|
82
|
+
* @param mailer - Mailer used to deliver authentication emails.
|
|
83
|
+
* @param hashService - Service for hashing and verifying passwords.
|
|
84
|
+
* @param userDeletionService - Service that deletes users and their related records.
|
|
85
|
+
* @returns Configured Better Auth instance.
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
70
88
|
export function createAuthInstance(options, orm, mailer, hashService, userDeletionService) {
|
|
71
89
|
return betterAuth(resolveBetterAuthOptions(options, orm, mailer, hashService, userDeletionService));
|
|
72
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Validates authentication options before constructing Better Auth.
|
|
93
|
+
* @param options - Authentication module configuration.
|
|
94
|
+
*/
|
|
73
95
|
function validateAuthOptions(options) {
|
|
74
96
|
const { roles: userRoles, permissions: userPermissions } = resolveAuthCatalog(options, "user");
|
|
75
97
|
const { roles: workspaceRoles, permissions: workspacePermissions } = resolveAuthCatalog(options, "workspace");
|
|
@@ -93,6 +115,11 @@ function validateAuthOptions(options) {
|
|
|
93
115
|
assertAuthRolesExist(workspaceRoles, [options.workspace?.defaultRole ?? DEFAULT_WORKSPACE_ROLE], "workspace.defaultRole");
|
|
94
116
|
assertAuthRolesExist(workspaceRoles, [options.workspace?.creatorRole ?? DEFAULT_WORKSPACE_CREATOR_ROLE], "workspace.creatorRole");
|
|
95
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Copies supported module options into the Better Auth configuration.
|
|
120
|
+
* @param target - Object that receives the configuration.
|
|
121
|
+
* @param source - Source value to read from.
|
|
122
|
+
*/
|
|
96
123
|
function copyBetterAuthOptions(target, source) {
|
|
97
124
|
if (source.basePath !== undefined)
|
|
98
125
|
target.basePath = source.basePath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-auth-instance.js","sourceRoot":"","sources":["../../src/infrastructure/create-auth-instance.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAA0B,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAE,6BAA6B,EAAE,MAAM,8CAA8C,CAAC;AAC7F,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EACL,8BAA8B,EAC9B,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD
|
|
1
|
+
{"version":3,"file":"create-auth-instance.js","sourceRoot":"","sources":["../../src/infrastructure/create-auth-instance.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAA0B,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,C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AClB,CAAC;IACF,oBAAoB,CAClB,cAAc,EACd,CAAC,OAAO,CAAC,SAAS,EAAE,WAAW,IAAI,sBAAsB,CAAC,EAC1D,uBAAuB,CACxB,CAAC;IACF,oBAAoB,CAClB,cAAc,EACd,CAAC,OAAO,CAAC,SAAS,EAAE,WAAW,IAAI,8BAA8B,CAAC,EAClE,uBAAuB,CACxB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,qBAAqB,CAC5B,MAAyB,EACzB,MAAyB;IAEzB,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS;QAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACrE,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS;QAAE,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAClE,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -4,6 +4,10 @@ type ExecutionContext = "authentication" | "invitation-identity";
|
|
|
4
4
|
* Installs the explicit infrastructure-owned execution boundaries for auth services.
|
|
5
5
|
* Domain methods only use their injected manager. Unlisted methods keep request RLS.
|
|
6
6
|
* Contextual instances are created per invocation, never by mutating a shared EM.
|
|
7
|
+
* @param em - Entity manager used for persistence.
|
|
8
|
+
* @param create - Mock implementation of the create operation.
|
|
9
|
+
* @param operations - Concurrent operations to execute.
|
|
10
|
+
* @returns Authentication service bound to the active request context.
|
|
7
11
|
* @internal
|
|
8
12
|
*/
|
|
9
13
|
export declare function createContextualAuthService<T extends object>(em: EntityManager, create: (em: EntityManager) => T, operations: Partial<Record<keyof T, ExecutionContext>>): T;
|
|
@@ -5,6 +5,10 @@ import { runAuthQuery } from "../utils/run-auth-query.js";
|
|
|
5
5
|
* Installs the explicit infrastructure-owned execution boundaries for auth services.
|
|
6
6
|
* Domain methods only use their injected manager. Unlisted methods keep request RLS.
|
|
7
7
|
* Contextual instances are created per invocation, never by mutating a shared EM.
|
|
8
|
+
* @param em - Entity manager used for persistence.
|
|
9
|
+
* @param create - Mock implementation of the create operation.
|
|
10
|
+
* @param operations - Concurrent operations to execute.
|
|
11
|
+
* @returns Authentication service bound to the active request context.
|
|
8
12
|
* @internal
|
|
9
13
|
*/
|
|
10
14
|
export function createContextualAuthService(em, create, operations) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-contextual-auth-service.js","sourceRoot":"","sources":["../../src/infrastructure/create-contextual-auth-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI1D
|
|
1
|
+
{"version":3,"file":"create-contextual-auth-service.js","sourceRoot":"","sources":["../../src/infrastructure/create-contextual-auth-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI1D;;;;;;;;;GASG;AACH,MAAM,UAAU,2BAA2B,CACzC,EAAiB,EACjB,MAAgC,EAChC,UAAsD;IAEtD,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACzD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE;YACnC,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,KAAK,EAAE,GAAG,IAAe,EAAE,EAAE;gBAClC,MAAM,MAAM,GAAG,KAAK,EAAE,OAAsB,EAAE,EAAE;oBAC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M,UAAU,CAAC,OAAO,CACtB,mBAAmB,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAChD,EAAE,EACF,KAAK,EACL,WAAW,CACZ,CAAC;oBACF,OAAO,MAAM,CAAC;gBAChB,CAAC,CAAC,CAAC;gBACL,OAAO,cAAc,CAAC,QAAQ,EAAE;oBAC9B,CAAC,CAAC,MAAM,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC;oBACjC,CAAC,CAAC,MAAM,cAAc,CAAC,GAAG,CACtB,IAAI,cAAc,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,EACnD,GAAG,CACJ,CAAC;YACR,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -6,43 +6,112 @@ import { User } from "../entities/user.entity.js";
|
|
|
6
6
|
import { Workspace } from "../entities/workspace.entity.js";
|
|
7
7
|
import type { RequestIdentityPatch } from "../interfaces/request-identity-patch.interface.js";
|
|
8
8
|
import type { ApiKeyMetadata } from "../types/api-key-metadata.type.js";
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Owns request identity publication, authorization invalidation, and database scope.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
10
13
|
export declare class RequestIdentity {
|
|
11
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Returns the active request member, rejecting user API keys outside their membership.
|
|
16
|
+
* @returns Active member in the selected workspace, or null if unavailable.
|
|
17
|
+
*/
|
|
12
18
|
static getCurrentMember(): Member | null;
|
|
13
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Throws unless the supplied user is the authenticated user.
|
|
21
|
+
* @param user - The user whose account is being accessed.
|
|
22
|
+
*/
|
|
14
23
|
static assertCurrentUser(user: User): void;
|
|
15
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Authorizes an explicit self-service path without granting a general resource ability.
|
|
26
|
+
* @param user - The user whose account is being accessed.
|
|
27
|
+
*/
|
|
16
28
|
static assertUserSession(user: User): void;
|
|
17
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Throws unless the supplied session is the authenticated session.
|
|
31
|
+
* @param session - Session whose metadata is being accessed.
|
|
32
|
+
*/
|
|
18
33
|
static assertCurrentSession(session: Session): void;
|
|
19
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Throws unless the supplied workspace is selected for the current request.
|
|
36
|
+
* @param workspace - The workspace that scopes this operation.
|
|
37
|
+
*/
|
|
20
38
|
static assertCurrentWorkspace(workspace: Workspace): void;
|
|
21
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Throws unless the supplied member is the current workspace member.
|
|
41
|
+
* @param member - The workspace membership to inspect or change.
|
|
42
|
+
*/
|
|
22
43
|
static assertCurrentMember(member: Member | null | undefined): void;
|
|
23
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Matches credentials by both table and ID.
|
|
46
|
+
* @param apiKey - API key whose metadata is being accessed.
|
|
47
|
+
* @returns Whether the key matches the credential authenticating this request.
|
|
48
|
+
*/
|
|
24
49
|
static isCurrentApiKey(apiKey: ApiKeyMetadata): boolean;
|
|
25
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Rejects publishing an authenticating credential before its outer transaction commits.
|
|
52
|
+
* @param em - Entity manager used for persistence.
|
|
53
|
+
* @param apiKey - API key whose metadata is being accessed.
|
|
54
|
+
*/
|
|
26
55
|
static assertApiKeyCanCommit(em: EntityManager, apiKey: ApiKeyMetadata): void;
|
|
27
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Publishes only changes to the user represented by this request.
|
|
58
|
+
* @param em - Entity manager used for persistence.
|
|
59
|
+
* @param options - Authentication module configuration.
|
|
60
|
+
* @param user - The user whose account is being accessed.
|
|
61
|
+
*/
|
|
28
62
|
static updateUser(em: EntityManager, options: AuthModuleOptions, user: User): void;
|
|
29
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Publishes only current membership changes, clearing departed workspace scope.
|
|
65
|
+
* @param em - Entity manager used for persistence.
|
|
66
|
+
* @param options - Authentication module configuration.
|
|
67
|
+
* @param member - The workspace membership to inspect or change.
|
|
68
|
+
*/
|
|
30
69
|
static updateMember(em: EntityManager, options: AuthModuleOptions, member: Member): void;
|
|
31
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Publishes committed credential changes or revokes the entire request.
|
|
72
|
+
* @param em - Entity manager used for persistence.
|
|
73
|
+
* @param options - Authentication module configuration.
|
|
74
|
+
* @param apiKey - API key whose metadata is being accessed.
|
|
75
|
+
* @param deleted - Whether the API key has been deleted.
|
|
76
|
+
*/
|
|
32
77
|
static updateApiKey(em: EntityManager, options: AuthModuleOptions, apiKey: ApiKeyMetadata, deleted?: boolean): void;
|
|
33
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Prepares the request ability once, failing closed when configuration rejects.
|
|
80
|
+
* @param options - Authentication module configuration.
|
|
81
|
+
*/
|
|
34
82
|
static prepare(options: AuthModuleOptions): void;
|
|
35
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Stages identity while authentication is being resolved, before a guard can run.
|
|
85
|
+
* @param patch - Identity fields to replace.
|
|
86
|
+
*/
|
|
36
87
|
static stage(patch: RequestIdentityPatch): void;
|
|
37
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Rebuilds one ability, never retaining old grants on failure.
|
|
90
|
+
* @param options - Authentication module configuration.
|
|
91
|
+
*/
|
|
38
92
|
static refresh(options: AuthModuleOptions): void;
|
|
39
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* Publishes a committed identity change; failures revoke the request instead of retaining stale grants.
|
|
95
|
+
* @param em - Entity manager used for persistence.
|
|
96
|
+
* @param options - Authentication module configuration.
|
|
97
|
+
* @param patch - Identity fields to replace.
|
|
98
|
+
*/
|
|
40
99
|
static update(em: EntityManager, options: AuthModuleOptions, patch: RequestIdentityPatch): void;
|
|
41
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Removes all credentials without falling back to another authentication method.
|
|
102
|
+
* @param em - Entity manager used for persistence.
|
|
103
|
+
*/
|
|
42
104
|
static clear(em: EntityManager): void;
|
|
43
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* Revokes workspace rules and rebuilds the remaining user ability after a committed change.
|
|
107
|
+
* @param em - Entity manager used for persistence.
|
|
108
|
+
* @param options - Authentication module configuration.
|
|
109
|
+
*/
|
|
44
110
|
static clearWorkspace(em: EntityManager, options: AuthModuleOptions): void;
|
|
45
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Synchronizes only identity values; database policies never receive application permissions.
|
|
113
|
+
* @param em - Entity manager used for persistence.
|
|
114
|
+
*/
|
|
46
115
|
static syncDatabase(em: EntityManager): void;
|
|
47
116
|
private static databaseScope;
|
|
48
117
|
}
|
|
@@ -11,9 +11,15 @@ import { buildRequestAbility } from "../utils/build-request-ability.util.js";
|
|
|
11
11
|
import { getCurrentApiKey } from "../utils/get-current-api-key.util.js";
|
|
12
12
|
import { resolveRequestMember } from "../utils/resolve-request-member.util.js";
|
|
13
13
|
import { invalidateRequestPermissions } from "../utils/resolve-request-permissions.util.js";
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Owns request identity publication, authorization invalidation, and database scope.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
15
18
|
export class RequestIdentity {
|
|
16
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Returns the active request member, rejecting user API keys outside their membership.
|
|
21
|
+
* @returns Active member in the selected workspace, or null if unavailable.
|
|
22
|
+
*/
|
|
17
23
|
static getCurrentMember() {
|
|
18
24
|
const member = resolveRequestMember();
|
|
19
25
|
if (getCurrentApiKey() && RequestContext.get(User) && !member) {
|
|
@@ -21,7 +27,10 @@ export class RequestIdentity {
|
|
|
21
27
|
}
|
|
22
28
|
return member;
|
|
23
29
|
}
|
|
24
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Throws unless the supplied user is the authenticated user.
|
|
32
|
+
* @param user - The user whose account is being accessed.
|
|
33
|
+
*/
|
|
25
34
|
static assertCurrentUser(user) {
|
|
26
35
|
const currentUser = RequestContext.isActive()
|
|
27
36
|
? RequestContext.get(User)
|
|
@@ -30,14 +39,20 @@ export class RequestIdentity {
|
|
|
30
39
|
throw new ForbiddenException("The operation belongs to another user");
|
|
31
40
|
}
|
|
32
41
|
}
|
|
33
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Authorizes an explicit self-service path without granting a general resource ability.
|
|
44
|
+
* @param user - The user whose account is being accessed.
|
|
45
|
+
*/
|
|
34
46
|
static assertUserSession(user) {
|
|
35
47
|
this.assertCurrentUser(user);
|
|
36
48
|
if (getCurrentApiKey()) {
|
|
37
49
|
throw new ForbiddenException("This self-service operation requires a user session");
|
|
38
50
|
}
|
|
39
51
|
}
|
|
40
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Throws unless the supplied session is the authenticated session.
|
|
54
|
+
* @param session - Session whose metadata is being accessed.
|
|
55
|
+
*/
|
|
41
56
|
static assertCurrentSession(session) {
|
|
42
57
|
const currentSession = RequestContext.isActive()
|
|
43
58
|
? RequestContext.get(Session)
|
|
@@ -46,7 +61,10 @@ export class RequestIdentity {
|
|
|
46
61
|
throw new ForbiddenException("The operation belongs to another session");
|
|
47
62
|
}
|
|
48
63
|
}
|
|
49
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Throws unless the supplied workspace is selected for the current request.
|
|
66
|
+
* @param workspace - The workspace that scopes this operation.
|
|
67
|
+
*/
|
|
50
68
|
static assertCurrentWorkspace(workspace) {
|
|
51
69
|
const currentWorkspace = RequestContext.isActive()
|
|
52
70
|
? RequestContext.get(Workspace)
|
|
@@ -56,7 +74,10 @@ export class RequestIdentity {
|
|
|
56
74
|
throw new ForbiddenException("The operation belongs to another workspace");
|
|
57
75
|
}
|
|
58
76
|
}
|
|
59
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Throws unless the supplied member is the current workspace member.
|
|
79
|
+
* @param member - The workspace membership to inspect or change.
|
|
80
|
+
*/
|
|
60
81
|
static assertCurrentMember(member) {
|
|
61
82
|
const currentMember = RequestContext.isActive()
|
|
62
83
|
? RequestContext.get(Member)
|
|
@@ -67,26 +88,44 @@ export class RequestIdentity {
|
|
|
67
88
|
throw new ForbiddenException("The operation belongs to another workspace member");
|
|
68
89
|
}
|
|
69
90
|
}
|
|
70
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Matches credentials by both table and ID.
|
|
93
|
+
* @param apiKey - API key whose metadata is being accessed.
|
|
94
|
+
* @returns Whether the key matches the credential authenticating this request.
|
|
95
|
+
*/
|
|
71
96
|
static isCurrentApiKey(apiKey) {
|
|
72
97
|
const current = getCurrentApiKey();
|
|
73
98
|
return (!!current &&
|
|
74
99
|
current.constructor === apiKey.constructor &&
|
|
75
100
|
current.id === apiKey.id);
|
|
76
101
|
}
|
|
77
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* Rejects publishing an authenticating credential before its outer transaction commits.
|
|
104
|
+
* @param em - Entity manager used for persistence.
|
|
105
|
+
* @param apiKey - API key whose metadata is being accessed.
|
|
106
|
+
*/
|
|
78
107
|
static assertApiKeyCanCommit(em, apiKey) {
|
|
79
108
|
if (this.isCurrentApiKey(apiKey) && em.isInTransaction()) {
|
|
80
109
|
throw new BadRequestException("Change the authenticating API key outside an active transaction");
|
|
81
110
|
}
|
|
82
111
|
}
|
|
83
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Publishes only changes to the user represented by this request.
|
|
114
|
+
* @param em - Entity manager used for persistence.
|
|
115
|
+
* @param options - Authentication module configuration.
|
|
116
|
+
* @param user - The user whose account is being accessed.
|
|
117
|
+
*/
|
|
84
118
|
static updateUser(em, options, user) {
|
|
85
119
|
if (!RequestContext.isActive() || RequestContext.get(User)?.id !== user.id)
|
|
86
120
|
return;
|
|
87
121
|
this.update(em, options, { user });
|
|
88
122
|
}
|
|
89
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Publishes only current membership changes, clearing departed workspace scope.
|
|
125
|
+
* @param em - Entity manager used for persistence.
|
|
126
|
+
* @param options - Authentication module configuration.
|
|
127
|
+
* @param member - The workspace membership to inspect or change.
|
|
128
|
+
*/
|
|
90
129
|
static updateMember(em, options, member) {
|
|
91
130
|
if (!RequestContext.isActive() ||
|
|
92
131
|
RequestContext.get(Member)?.id !== member.id)
|
|
@@ -96,7 +135,13 @@ export class RequestIdentity {
|
|
|
96
135
|
else
|
|
97
136
|
this.update(em, options, { member });
|
|
98
137
|
}
|
|
99
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Publishes committed credential changes or revokes the entire request.
|
|
140
|
+
* @param em - Entity manager used for persistence.
|
|
141
|
+
* @param options - Authentication module configuration.
|
|
142
|
+
* @param apiKey - API key whose metadata is being accessed.
|
|
143
|
+
* @param deleted - Whether the API key has been deleted.
|
|
144
|
+
*/
|
|
100
145
|
static updateApiKey(em, options, apiKey, deleted = false) {
|
|
101
146
|
if (!this.isCurrentApiKey(apiKey))
|
|
102
147
|
return;
|
|
@@ -107,13 +152,19 @@ export class RequestIdentity {
|
|
|
107
152
|
else
|
|
108
153
|
this.update(em, options, { apiKey });
|
|
109
154
|
}
|
|
110
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* Prepares the request ability once, failing closed when configuration rejects.
|
|
157
|
+
* @param options - Authentication module configuration.
|
|
158
|
+
*/
|
|
111
159
|
static prepare(options) {
|
|
112
160
|
if (!RequestContext.isActive() || RequestContext.get(AuthAbility))
|
|
113
161
|
return;
|
|
114
162
|
this.refresh(options);
|
|
115
163
|
}
|
|
116
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* Stages identity while authentication is being resolved, before a guard can run.
|
|
166
|
+
* @param patch - Identity fields to replace.
|
|
167
|
+
*/
|
|
117
168
|
static stage(patch) {
|
|
118
169
|
if (!RequestContext.isActive())
|
|
119
170
|
return;
|
|
@@ -130,7 +181,10 @@ export class RequestIdentity {
|
|
|
130
181
|
invalidateRequestPermissions();
|
|
131
182
|
RequestContext.set(AuthAbility, null);
|
|
132
183
|
}
|
|
133
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* Rebuilds one ability, never retaining old grants on failure.
|
|
186
|
+
* @param options - Authentication module configuration.
|
|
187
|
+
*/
|
|
134
188
|
static refresh(options) {
|
|
135
189
|
if (!RequestContext.isActive())
|
|
136
190
|
return;
|
|
@@ -138,7 +192,12 @@ export class RequestIdentity {
|
|
|
138
192
|
RequestContext.set(AuthAbility, new AuthAbility());
|
|
139
193
|
RequestContext.set(AuthAbility, buildRequestAbility(options));
|
|
140
194
|
}
|
|
141
|
-
/**
|
|
195
|
+
/**
|
|
196
|
+
* Publishes a committed identity change; failures revoke the request instead of retaining stale grants.
|
|
197
|
+
* @param em - Entity manager used for persistence.
|
|
198
|
+
* @param options - Authentication module configuration.
|
|
199
|
+
* @param patch - Identity fields to replace.
|
|
200
|
+
*/
|
|
142
201
|
static update(em, options, patch) {
|
|
143
202
|
if (!RequestContext.isActive())
|
|
144
203
|
return;
|
|
@@ -158,7 +217,10 @@ export class RequestIdentity {
|
|
|
158
217
|
throw error;
|
|
159
218
|
}
|
|
160
219
|
}
|
|
161
|
-
/**
|
|
220
|
+
/**
|
|
221
|
+
* Removes all credentials without falling back to another authentication method.
|
|
222
|
+
* @param em - Entity manager used for persistence.
|
|
223
|
+
*/
|
|
162
224
|
static clear(em) {
|
|
163
225
|
this.stage({
|
|
164
226
|
user: null,
|
|
@@ -180,7 +242,11 @@ export class RequestIdentity {
|
|
|
180
242
|
},
|
|
181
243
|
});
|
|
182
244
|
}
|
|
183
|
-
/**
|
|
245
|
+
/**
|
|
246
|
+
* Revokes workspace rules and rebuilds the remaining user ability after a committed change.
|
|
247
|
+
* @param em - Entity manager used for persistence.
|
|
248
|
+
* @param options - Authentication module configuration.
|
|
249
|
+
*/
|
|
184
250
|
static clearWorkspace(em, options) {
|
|
185
251
|
if (getCurrentApiKey() instanceof MemberApiKey) {
|
|
186
252
|
this.clear(em);
|
|
@@ -188,7 +254,10 @@ export class RequestIdentity {
|
|
|
188
254
|
}
|
|
189
255
|
this.update(em, options, { member: null, workspace: null });
|
|
190
256
|
}
|
|
191
|
-
/**
|
|
257
|
+
/**
|
|
258
|
+
* Synchronizes only identity values; database policies never receive application permissions.
|
|
259
|
+
* @param em - Entity manager used for persistence.
|
|
260
|
+
*/
|
|
192
261
|
static syncDatabase(em) {
|
|
193
262
|
em.setSessionContext(this.databaseScope());
|
|
194
263
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-identity.js","sourceRoot":"","sources":["../../src/infrastructure/request-identity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAE5F
|
|
1
|
+
{"version":3,"file":"request-identity.js","sourceRoot":"","sources":["../../src/infrastructure/request-identity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cA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OAGG;IACH,MAAM,CAAC,YAAY,CAAC,EAAiB;QACnC,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IAC7C,CAAC;IAEO,MAAM,CAAC,aAAa;QAC1B,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;QAClC,MAAM,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,oBAAoB,EAAE,CAAC;QACtC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC;QAC9C,OAAO;YACL,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW;YACnD,SAAS,EAAE;gBACT,aAAa,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE;gBAC7B,kBAAkB,EAChB,CAAC,aAAa,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE;gBACvD,eAAe,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE;aAClC;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { ForbiddenException } from "@nestjs/common";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Signals a committed credential revocation even though the operation is rejected.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
3
6
|
export declare class RevokedAuthenticationException extends ForbiddenException {
|
|
4
7
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ForbiddenException } from "@nestjs/common";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Signals a committed credential revocation even though the operation is rejected.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
3
6
|
export class RevokedAuthenticationException extends ForbiddenException {
|
|
4
7
|
}
|
|
5
8
|
//# sourceMappingURL=revoked-authentication.exception.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revoked-authentication.exception.js","sourceRoot":"","sources":["../../src/infrastructure/revoked-authentication.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD
|
|
1
|
+
{"version":3,"file":"revoked-authentication.exception.js","sourceRoot":"","sources":["../../src/infrastructure/revoked-authentication.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;GAGG;AACH,MAAM,OAAO,8BAA+B,SAAQ,kBAAkB;CAAG"}
|
|
@@ -3,7 +3,10 @@ import type { Session } from "../entities/session.entity.js";
|
|
|
3
3
|
import type { User } from "../entities/user.entity.js";
|
|
4
4
|
import type { Workspace } from "../entities/workspace.entity.js";
|
|
5
5
|
import type { ApiKeyMetadata } from "../types/api-key-metadata.type.js";
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Identity values staged together by the auth infrastructure.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
7
10
|
export interface RequestIdentityPatch {
|
|
8
11
|
user?: User | null;
|
|
9
12
|
member?: Member | null;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Shared permission snapshot for one request identity.
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
2
5
|
export interface RequestPermissions {
|
|
3
6
|
readonly user: readonly string[];
|
|
4
7
|
readonly workspace: readonly string[];
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { PolicyDef } from "@mikro-orm/core";
|
|
2
2
|
import type { ScopePolicyOptions } from "../interfaces/scope-policy-options.interface.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Builds the common native policy without discovery hooks.
|
|
5
|
+
* @param scope - User or workspace identifier stored in the database request context.
|
|
6
|
+
* @param options - Configuration for this operation.
|
|
7
|
+
* @returns Native database policy that compares the row with the request scope.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
4
10
|
export declare function createScopePolicy(scope: "user" | "workspace", options: ScopePolicyOptions): PolicyDef;
|