@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,6 +1,9 @@
|
|
|
1
1
|
type Letter = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
2
2
|
type Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
3
3
|
type ValidTail<Value extends string, Separator extends string> = Value extends "" ? true : Value extends `${Letter | Digit | Separator}${infer Rest}` ? ValidTail<Rest, Separator> : false;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Validates an ASCII identifier without changing its value.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
5
8
|
export type LowercaseIdentifier<Value extends string, Separator extends string> = Value extends `${string}--${string}` ? never : Value extends `${Letter}${infer Rest}` ? ValidTail<Rest, Separator> extends true ? Value : never : never;
|
|
6
9
|
export {};
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Hashes a high-entropy API credential for lookup.
|
|
3
|
+
* @param apiKey - API key whose metadata is being accessed.
|
|
4
|
+
* @returns Base64url-encoded SHA-256 hash of the API key.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
2
7
|
export declare function hashApiKey(apiKey: string): string;
|
|
3
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Generates a credential with a validated public prefix.
|
|
10
|
+
* @param prefix - Prefix prepended to the generated API key.
|
|
11
|
+
* @returns Random API key with the requested prefix.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
4
14
|
export declare function generateApiKey(prefix: string): string;
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { createHash, randomBytes } from "node:crypto";
|
|
2
2
|
import { BadRequestException } from "@nestjs/common";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Hashes a high-entropy API credential for lookup.
|
|
5
|
+
* @param apiKey - API key whose metadata is being accessed.
|
|
6
|
+
* @returns Base64url-encoded SHA-256 hash of the API key.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
4
9
|
export function hashApiKey(apiKey) {
|
|
5
10
|
return createHash("sha256").update(apiKey).digest("base64url");
|
|
6
11
|
}
|
|
7
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Generates a credential with a validated public prefix.
|
|
14
|
+
* @param prefix - Prefix prepended to the generated API key.
|
|
15
|
+
* @returns Random API key with the requested prefix.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
8
18
|
export function generateApiKey(prefix) {
|
|
9
19
|
if (prefix.length > 32 ||
|
|
10
20
|
!/^[a-z]/u.test(prefix) ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-key-credential.util.js","sourceRoot":"","sources":["../../src/utils/api-key-credential.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"api-key-credential.util.js","sourceRoot":"","sources":["../../src/utils/api-key-credential.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,IACE,MAAM,CAAC,MAAM,GAAG,EAAE;QAClB,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;QACvB,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,EAC3B,CAAC;QACD,MAAM,IAAI,mBAAmB,CAC3B,uHAAuH,CACxH,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import type { AuthModuleOptions } from "../auth-module-options.interface.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Returns the owner's complete enum catalog and the subset configurable on API keys.
|
|
4
|
+
* @param options - Authentication module configuration.
|
|
5
|
+
* @param scope - Authorization scope to apply.
|
|
6
|
+
* @returns Permission names available to keys in the requested scope.
|
|
7
|
+
*/
|
|
3
8
|
export declare function resolveApiKeyPermissionCatalog(options: AuthModuleOptions, scope: "user" | "member"): {
|
|
4
9
|
readonly permissions: readonly string[];
|
|
5
10
|
readonly allowed: readonly string[];
|
|
6
11
|
readonly defaults: readonly string[];
|
|
7
12
|
};
|
|
8
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Applies scope defaults, validates catalog values, and enforces the configured key ceiling.
|
|
15
|
+
* @param options - Authentication module configuration.
|
|
16
|
+
* @param scope - Authorization scope to apply.
|
|
17
|
+
* @param requested - Requested grants to validate.
|
|
18
|
+
* @returns Validated API key permission restriction list.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
9
21
|
export declare function normalizeApiKeyPermissions(options: AuthModuleOptions, scope: "user" | "member", requested: readonly string[] | null | undefined): string[];
|
|
@@ -2,7 +2,12 @@ import { normalizeAuthPermissions } from "./auth-role.util.js";
|
|
|
2
2
|
import { assertPermissionCeiling } from "./permission-grants.util.js";
|
|
3
3
|
import { resolveAuthCatalog } from "./resolve-auth-catalog.util.js";
|
|
4
4
|
const catalogs = new WeakMap();
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Returns the owner's complete enum catalog and the subset configurable on API keys.
|
|
7
|
+
* @param options - Authentication module configuration.
|
|
8
|
+
* @param scope - Authorization scope to apply.
|
|
9
|
+
* @returns Permission names available to keys in the requested scope.
|
|
10
|
+
*/
|
|
6
11
|
export function resolveApiKeyPermissionCatalog(options, scope) {
|
|
7
12
|
const scopes = catalogs.get(options) ?? {};
|
|
8
13
|
const cached = scopes[scope];
|
|
@@ -25,7 +30,14 @@ export function resolveApiKeyPermissionCatalog(options, scope) {
|
|
|
25
30
|
catalogs.set(options, scopes);
|
|
26
31
|
return catalog;
|
|
27
32
|
}
|
|
28
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Applies scope defaults, validates catalog values, and enforces the configured key ceiling.
|
|
35
|
+
* @param options - Authentication module configuration.
|
|
36
|
+
* @param scope - Authorization scope to apply.
|
|
37
|
+
* @param requested - Requested grants to validate.
|
|
38
|
+
* @returns Validated API key permission restriction list.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
29
41
|
export function normalizeApiKeyPermissions(options, scope, requested) {
|
|
30
42
|
const { permissions, allowed, defaults } = resolveApiKeyPermissionCatalog(options, scope);
|
|
31
43
|
const normalized = normalizeAuthPermissions(requested === undefined ? defaults : (requested ?? []), permissions, scope === "user" ? "User API key" : "Member API key");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-key-permissions.util.js","sourceRoot":"","sources":["../../src/utils/api-key-permissions.util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,QAAQ,GAAG,IAAI,OAAO,EAKzB,CAAC;AAEJ
|
|
1
|
+
{"version":3,"file":"api-key-permissions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;QACF,OAAO,EAAE,MAAM,CAAC,MAAM,CACpB,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAC9D;KACF,CAAC,CAAC;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;IACxB,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA0B,EAC1B,KAAwB,EACxB,SAA+C;IAE/C,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,8BAA8B,CACvE,OAAO,EACP,KAAK,CACN,CAAC;IACF,MAAM,UAAU,GAAG,wBAAwB,CACzC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,EACtD,WAAW,EACX,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,gBAAgB,CACrD,CAAC;IACF,uBAAuB,CACrB,UAAU,EACV,OAAO,EACP,0DAA0D,CAC3D,CAAC;IACF,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import type { CustomDecorator } from "@nestjs/common";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Appends one value to array metadata on a class or method.
|
|
5
|
+
* @param metadataKey - Key under which the metadata is stored.
|
|
6
|
+
* @param metadataValue - Metadata entries to append.
|
|
7
|
+
* @returns Decorator that appends values under the metadata key.
|
|
8
|
+
*/
|
|
4
9
|
export declare function appendMetadata<TKey>(metadataKey: TKey, metadataValue: unknown): CustomDecorator<TKey>;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Appends one value to array metadata on a class or method.
|
|
4
|
+
* @param metadataKey - Key under which the metadata is stored.
|
|
5
|
+
* @param metadataValue - Metadata entries to append.
|
|
6
|
+
* @returns Decorator that appends values under the metadata key.
|
|
7
|
+
*/
|
|
3
8
|
export function appendMetadata(metadataKey, metadataValue) {
|
|
4
9
|
const decorator = (target, _propertyKey, descriptor) => {
|
|
5
10
|
const metadataTarget = descriptor?.value ?? target;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"append-metadata.util.js","sourceRoot":"","sources":["../../src/utils/append-metadata.util.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAI1B
|
|
1
|
+
{"version":3,"file":"append-metadata.util.js","sourceRoot":"","sources":["../../src/utils/append-metadata.util.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAI1B;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,WAAiB,EACjB,aAAsB;IAEtB,MAAM,SAAS,GAAG,CAChB,MAAc,EACd,YAA8B,EAC9B,UAA+B,EAC/B,EAAE;QACF,MAAM,cAAc,GAAG,UAAU,EAAE,KAAK,IAAI,MAAM,CAAC;QACnD,MAAM,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAC1C,WAAW,EACX,cAAc,CACU,CAAC;QAE3B,OAAO,CAAC,cAAc,CACpB,WAAW,EACX,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,EAAE,aAAa,CAAC,EAC5C,cAAc,CACf,CAAC;QAEF,OAAO,UAAU,IAAI,MAAM,CAAC;IAC9B,CAAC,CAAC;IAEF,SAAS,CAAC,GAAG,GAAG,WAAW,CAAC;IAC5B,OAAO,SAAkC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Applies authentication cookies to the current HTTP response.
|
|
3
|
+
* @param responseHeaders - Headers returned by the authentication endpoint.
|
|
4
|
+
*/
|
|
2
5
|
export declare function applyAuthResponseCookies(responseHeaders: Headers): void;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { cookies } from "@nest-boot/request-context";
|
|
2
2
|
import { parseSetCookie } from "cookie";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Applies authentication cookies to the current HTTP response.
|
|
5
|
+
* @param responseHeaders - Headers returned by the authentication endpoint.
|
|
6
|
+
*/
|
|
4
7
|
export function applyAuthResponseCookies(responseHeaders) {
|
|
5
8
|
const values = responseHeaders.getSetCookie();
|
|
6
9
|
if (values.length === 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-auth-response-cookies.util.js","sourceRoot":"","sources":["../../src/utils/apply-auth-response-cookies.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"apply-auth-response-cookies.util.js","sourceRoot":"","sources":["../../src/utils/apply-auth-response-cookies.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,eAAwB;IAC/D,MAAM,MAAM,GAAG,eAAe,CAAC,YAAY,EAAE,CAAC;IAC9C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAEhC,MAAM,WAAW,GAAG,OAAO,EAAE,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QACrC,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
|
@@ -1,17 +1,59 @@
|
|
|
1
1
|
import type { AuthModuleRoles } from "../types/auth-module-roles.type.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Returns a deduplicated configured permission catalog.
|
|
4
|
+
* @param permissions - Permission names to apply.
|
|
5
|
+
* @returns Unique permission names in the catalog.
|
|
6
|
+
*/
|
|
3
7
|
export declare function listAuthPermissions(permissions: readonly string[]): string[];
|
|
4
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Validates permission values by exact, case-sensitive catalog membership.
|
|
10
|
+
* @param value - Value to inspect or transform.
|
|
11
|
+
* @param availablePermissions - Permission names available in the current catalog.
|
|
12
|
+
* @param label - Label used in validation errors.
|
|
13
|
+
* @returns Validated permission names.
|
|
14
|
+
*/
|
|
5
15
|
export declare function normalizeAuthPermissions(value: readonly string[], availablePermissions: readonly string[], label: string): string[];
|
|
6
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Ensures every role grant belongs to its scope's permission catalog.
|
|
18
|
+
* @param roles - Role names and their associated permissions.
|
|
19
|
+
* @param permissions - Permission names to apply.
|
|
20
|
+
* @param scope - Authorization scope to apply.
|
|
21
|
+
*/
|
|
7
22
|
export declare function assertAuthRolePermissions(roles: AuthModuleRoles, permissions: readonly string[], scope: "user" | "workspace"): void;
|
|
8
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Ensures one configured permission list belongs to the available catalog.
|
|
25
|
+
* @param permissions - Permission names to apply.
|
|
26
|
+
* @param availablePermissions - Permission names available in the current catalog.
|
|
27
|
+
* @param option - Configured option to validate.
|
|
28
|
+
*/
|
|
9
29
|
export declare function assertAuthPermissionList(permissions: readonly string[], availablePermissions: readonly string[], option: string): void;
|
|
10
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Ensures every permission in one configured list is allowed by another.
|
|
32
|
+
* @param permissions - Permission names to apply.
|
|
33
|
+
* @param allowedPermissions - Permission ceiling for the assignment.
|
|
34
|
+
* @param option - Configured option to validate.
|
|
35
|
+
* @param allowedOption - Option name used when reporting invalid grants.
|
|
36
|
+
*/
|
|
11
37
|
export declare function assertAuthPermissionSubset(permissions: readonly string[], allowedPermissions: readonly string[], option: string, allowedOption?: string): void;
|
|
12
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Ensures configured lifecycle roles exist in their role registry.
|
|
40
|
+
* @param roles - Role names and their associated permissions.
|
|
41
|
+
* @param roleNames - Role names to validate.
|
|
42
|
+
* @param option - Configured option to validate.
|
|
43
|
+
*/
|
|
13
44
|
export declare function assertAuthRolesExist(roles: AuthModuleRoles, roleNames: readonly string[], option: string): void;
|
|
14
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Validates and normalizes one or more assigned role names.
|
|
47
|
+
* @param value - Value to inspect or transform.
|
|
48
|
+
* @param roles - Role names and their associated permissions.
|
|
49
|
+
* @returns Validated role names.
|
|
50
|
+
*/
|
|
15
51
|
export declare function normalizeAuthRoles(value: string | readonly string[], roles: AuthModuleRoles): string[];
|
|
16
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Resolves role grants and direct permissions into one permission list.
|
|
54
|
+
* @param assignedRoles - Roles currently assigned to the principal.
|
|
55
|
+
* @param directPermissions - Permissions granted directly to the principal.
|
|
56
|
+
* @param roles - Role names and their associated permissions.
|
|
57
|
+
* @returns Unique permissions granted by assigned roles or direct grants.
|
|
58
|
+
*/
|
|
17
59
|
export declare function resolveAuthPermissions(assignedRoles: readonly string[], directPermissions: readonly string[], roles: AuthModuleRoles): string[];
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { BadRequestException } from "@nestjs/common";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Returns a deduplicated configured permission catalog.
|
|
4
|
+
* @param permissions - Permission names to apply.
|
|
5
|
+
* @returns Unique permission names in the catalog.
|
|
6
|
+
*/
|
|
3
7
|
export function listAuthPermissions(permissions) {
|
|
4
8
|
return [...new Set(permissions)];
|
|
5
9
|
}
|
|
6
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Validates permission values by exact, case-sensitive catalog membership.
|
|
12
|
+
* @param value - Value to inspect or transform.
|
|
13
|
+
* @param availablePermissions - Permission names available in the current catalog.
|
|
14
|
+
* @param label - Label used in validation errors.
|
|
15
|
+
* @returns Validated permission names.
|
|
16
|
+
*/
|
|
7
17
|
export function normalizeAuthPermissions(value, availablePermissions, label) {
|
|
8
18
|
if (!Array.isArray(value) ||
|
|
9
19
|
value.some((permission) => typeof permission !== "string" ||
|
|
@@ -24,7 +34,12 @@ export function normalizeAuthPermissions(value, availablePermissions, label) {
|
|
|
24
34
|
}
|
|
25
35
|
return [...value];
|
|
26
36
|
}
|
|
27
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Ensures every role grant belongs to its scope's permission catalog.
|
|
39
|
+
* @param roles - Role names and their associated permissions.
|
|
40
|
+
* @param permissions - Permission names to apply.
|
|
41
|
+
* @param scope - Authorization scope to apply.
|
|
42
|
+
*/
|
|
28
43
|
export function assertAuthRolePermissions(roles, permissions, scope) {
|
|
29
44
|
for (const permission of permissions) {
|
|
30
45
|
if (typeof permission !== "string" ||
|
|
@@ -48,7 +63,12 @@ export function assertAuthRolePermissions(roles, permissions, scope) {
|
|
|
48
63
|
}
|
|
49
64
|
}
|
|
50
65
|
}
|
|
51
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Ensures one configured permission list belongs to the available catalog.
|
|
68
|
+
* @param permissions - Permission names to apply.
|
|
69
|
+
* @param availablePermissions - Permission names available in the current catalog.
|
|
70
|
+
* @param option - Configured option to validate.
|
|
71
|
+
*/
|
|
52
72
|
export function assertAuthPermissionList(permissions, availablePermissions, option) {
|
|
53
73
|
try {
|
|
54
74
|
normalizeAuthPermissions(permissions, availablePermissions, option);
|
|
@@ -57,7 +77,13 @@ export function assertAuthPermissionList(permissions, availablePermissions, opti
|
|
|
57
77
|
throw new Error(error instanceof Error ? error.message : `${option} is invalid`, { cause: error });
|
|
58
78
|
}
|
|
59
79
|
}
|
|
60
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Ensures every permission in one configured list is allowed by another.
|
|
82
|
+
* @param permissions - Permission names to apply.
|
|
83
|
+
* @param allowedPermissions - Permission ceiling for the assignment.
|
|
84
|
+
* @param option - Configured option to validate.
|
|
85
|
+
* @param allowedOption - Option name used when reporting invalid grants.
|
|
86
|
+
*/
|
|
61
87
|
export function assertAuthPermissionSubset(permissions, allowedPermissions, option, allowedOption = "apiKey.allowedPermissions") {
|
|
62
88
|
const allowedPermissionSet = new Set(allowedPermissions);
|
|
63
89
|
const disallowedPermissions = permissions.filter((permission) => !allowedPermissionSet.has(permission));
|
|
@@ -65,7 +91,12 @@ export function assertAuthPermissionSubset(permissions, allowedPermissions, opti
|
|
|
65
91
|
throw new Error(`${option} contains permissions outside ${allowedOption}: ${disallowedPermissions.join(", ")}`);
|
|
66
92
|
}
|
|
67
93
|
}
|
|
68
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Ensures configured lifecycle roles exist in their role registry.
|
|
96
|
+
* @param roles - Role names and their associated permissions.
|
|
97
|
+
* @param roleNames - Role names to validate.
|
|
98
|
+
* @param option - Configured option to validate.
|
|
99
|
+
*/
|
|
69
100
|
export function assertAuthRolesExist(roles, roleNames, option) {
|
|
70
101
|
const invalidRoleNames = roleNames.filter((role) => typeof role !== "string" ||
|
|
71
102
|
role.length === 0 ||
|
|
@@ -75,7 +106,12 @@ export function assertAuthRolesExist(roles, roleNames, option) {
|
|
|
75
106
|
throw new Error(`${option} references unknown role${invalidRoleNames.length === 1 ? "" : "s"} ${invalidRoleNames.map((role) => JSON.stringify(role)).join(", ")}`);
|
|
76
107
|
}
|
|
77
108
|
}
|
|
78
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Validates and normalizes one or more assigned role names.
|
|
111
|
+
* @param value - Value to inspect or transform.
|
|
112
|
+
* @param roles - Role names and their associated permissions.
|
|
113
|
+
* @returns Validated role names.
|
|
114
|
+
*/
|
|
79
115
|
export function normalizeAuthRoles(value, roles) {
|
|
80
116
|
const normalized = [value]
|
|
81
117
|
.flat()
|
|
@@ -92,7 +128,13 @@ export function normalizeAuthRoles(value, roles) {
|
|
|
92
128
|
}
|
|
93
129
|
return normalized;
|
|
94
130
|
}
|
|
95
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* Resolves role grants and direct permissions into one permission list.
|
|
133
|
+
* @param assignedRoles - Roles currently assigned to the principal.
|
|
134
|
+
* @param directPermissions - Permissions granted directly to the principal.
|
|
135
|
+
* @param roles - Role names and their associated permissions.
|
|
136
|
+
* @returns Unique permissions granted by assigned roles or direct grants.
|
|
137
|
+
*/
|
|
96
138
|
export function resolveAuthPermissions(assignedRoles, directPermissions, roles) {
|
|
97
139
|
return [
|
|
98
140
|
...new Set([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-role.util.js","sourceRoot":"","sources":["../../src/utils/auth-role.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAIrD
|
|
1
|
+
{"version":3,"file":"auth-role.util.js","sourceRoot":"","sources":["../../src/utils/auth-role.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAIrD;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAA8B;IAChE,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAwB,EACxB,oBAAuC,EACvC,KAAa;IAEb,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,KAAK,CAAC,IAAI,CACR,CAAC,UAAU,EAAE,EAAE,CACb,OAAO,UAAU,KAAK,QAAQ;YAC9B,UAAU,CAAC,MAA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AAoC,EACpC,KAAsB;IAEtB,OAAO;QACL,GAAG,IAAI,GAAG,CAAC;YACT,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAChC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CACtD;YACD,GAAG,iBAAiB;SACrB,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { Subject } from "@casl/ability";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Throws ForbiddenException unless the current request permits the action.
|
|
4
|
+
* @param action - Permission action to check.
|
|
5
|
+
* @param subject - Resource instance or type to authorize.
|
|
6
|
+
* @param field - Field name to inspect.
|
|
7
|
+
*/
|
|
3
8
|
export declare function authorize(action: string, subject: Subject, field?: string): void;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { getAuthAbility } from "./get-auth-ability.util.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Throws ForbiddenException unless the current request permits the action.
|
|
4
|
+
* @param action - Permission action to check.
|
|
5
|
+
* @param subject - Resource instance or type to authorize.
|
|
6
|
+
* @param field - Field name to inspect.
|
|
7
|
+
*/
|
|
3
8
|
export function authorize(action, subject, field) {
|
|
4
9
|
getAuthAbility().authorize(action, subject, field);
|
|
5
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize.util.js","sourceRoot":"","sources":["../../src/utils/authorize.util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D
|
|
1
|
+
{"version":3,"file":"authorize.util.js","sourceRoot":"","sources":["../../src/utils/authorize.util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CACvB,MAAc,EACd,OAAgB,EAChB,KAAc;IAEd,cAAc,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { AuthAbility } from "../auth.ability.js";
|
|
2
2
|
import type { AuthModuleOptions } from "../auth-module-options.interface.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Builds one ability from the current identity and credential-limited permission snapshot.
|
|
5
|
+
* @param options - Authentication module configuration.
|
|
6
|
+
* @returns Ability for the supplied identity and resolved request permissions.
|
|
7
|
+
*/
|
|
4
8
|
export declare function buildRequestAbility(options: AuthModuleOptions): AuthAbility;
|
|
@@ -6,7 +6,11 @@ import { AuthAbilityFactory } from "../infrastructure/auth-ability.factory.js";
|
|
|
6
6
|
import { getCurrentApiKey } from "./get-current-api-key.util.js";
|
|
7
7
|
import { resolveRequestMember } from "./resolve-request-member.util.js";
|
|
8
8
|
import { resolveRequestPermissions } from "./resolve-request-permissions.util.js";
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Builds one ability from the current identity and credential-limited permission snapshot.
|
|
11
|
+
* @param options - Authentication module configuration.
|
|
12
|
+
* @returns Ability for the supplied identity and resolved request permissions.
|
|
13
|
+
*/
|
|
10
14
|
export function buildRequestAbility(options) {
|
|
11
15
|
const apiKey = getCurrentApiKey();
|
|
12
16
|
const memberKey = apiKey instanceof MemberApiKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request-ability.util.js","sourceRoot":"","sources":["../../src/utils/build-request-ability.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI5D,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACl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IAAI,CAAC;IAC1E,MAAM,WAAW,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACvD,OAAO,kBAAkB,CAAC,aAAa,CACrC;QACE,IAAI;QACJ,SAAS;QACT,MAAM;QACN,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;QAC7C,oBAAoB,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;KAC7D,EACD,OAAO,CACR,CAAC;AACJ,CAAC"}
|
package/dist/utils/can.util.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Subject } from "@casl/ability";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Checks the current request's ability on every call.
|
|
4
|
+
* @param action - Permission action to check.
|
|
5
|
+
* @param subject - Resource instance or type to authorize.
|
|
6
|
+
* @param field - Field name to inspect.
|
|
7
|
+
* @returns Whether the current ability permits the action on the subject and field.
|
|
8
|
+
*/
|
|
3
9
|
export declare function can(action: string, subject: Subject, field?: string): boolean;
|
package/dist/utils/can.util.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { getAuthAbility } from "./get-auth-ability.util.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Checks the current request's ability on every call.
|
|
4
|
+
* @param action - Permission action to check.
|
|
5
|
+
* @param subject - Resource instance or type to authorize.
|
|
6
|
+
* @param field - Field name to inspect.
|
|
7
|
+
* @returns Whether the current ability permits the action on the subject and field.
|
|
8
|
+
*/
|
|
3
9
|
export function can(action, subject, field) {
|
|
4
10
|
const ability = getAuthAbility();
|
|
5
11
|
return field === undefined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"can.util.js","sourceRoot":"","sources":["../../src/utils/can.util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D
|
|
1
|
+
{"version":3,"file":"can.util.js","sourceRoot":"","sources":["../../src/utils/can.util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,OAAgB,EAAE,KAAc;IAClE,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,OAAO,KAAK,KAAK,SAAS;QACxB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;QAC9B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -4,5 +4,13 @@ import type { BetterAuthOptions } from "better-auth";
|
|
|
4
4
|
import type { AuthModuleOptions } from "../auth-module-options.interface.js";
|
|
5
5
|
type EmailAndPasswordConfig = NonNullable<BetterAuthOptions["emailAndPassword"]>;
|
|
6
6
|
type EmailAndPasswordOptions = AuthModuleOptions["emailAndPassword"];
|
|
7
|
+
/**
|
|
8
|
+
* Returns email and password options with hashing and reset-email hooks.
|
|
9
|
+
* @param disableSignUp - Whether provider-based registration is disabled.
|
|
10
|
+
* @param mailer - Mailer used to deliver authentication emails.
|
|
11
|
+
* @param hashService - Service for hashing and verifying passwords.
|
|
12
|
+
* @param options - Configuration for this operation.
|
|
13
|
+
* @returns Email and password options with hashing and reset-email hooks.
|
|
14
|
+
*/
|
|
7
15
|
export declare function createEmailAndPasswordConfig(disableSignUp: boolean, mailer: Mailer, hashService: HashService, options?: EmailAndPasswordOptions): EmailAndPasswordConfig;
|
|
8
16
|
export {};
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { isEnvTrue } from "./is-env-true.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns email and password options with hashing and reset-email hooks.
|
|
4
|
+
* @param disableSignUp - Whether provider-based registration is disabled.
|
|
5
|
+
* @param mailer - Mailer used to deliver authentication emails.
|
|
6
|
+
* @param hashService - Service for hashing and verifying passwords.
|
|
7
|
+
* @param options - Configuration for this operation.
|
|
8
|
+
* @returns Email and password options with hashing and reset-email hooks.
|
|
9
|
+
*/
|
|
2
10
|
export function createEmailAndPasswordConfig(disableSignUp, mailer, hashService, options) {
|
|
3
11
|
const hasEnabledEnv = process.env.AUTH_EMAIL_ENABLED !== undefined;
|
|
4
12
|
const hasRequireVerificationEnv = process.env.AUTH_EMAIL_REQUIRE_VERIFICATION !== undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-email-and-password-config.js","sourceRoot":"","sources":["../../src/utils/create-email-and-password-config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAO7C,MAAM,UAAU,4BAA4B,CAC1C,aAAsB,EACtB,MAAc,EACd,WAAwB,EACxB,OAAiC;IAEjC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,SAAS,CAAC;IACnE,MAAM,yBAAyB,GAC7B,OAAO,CAAC,GAAG,CAAC,+BAA+B,KAAK,SAAS,CAAC;IAC5D,MAAM,mBAAmB,GACvB,aAAa,IAAI,SAAS,CAAC,4BAA4B,CAAC,CAAC;IAC3D,MAAM,OAAO,GAAG,aAAa;QAC3B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,OAAO;QAC5C,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC;IAC/B,MAAM,wBAAwB,GAAG,yBAAyB;QACxD,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,+BAA+B,KAAK,OAAO;QACzD,CAAC,CAAC,CAAC,OAAO,EAAE,wBAAwB,IAAI,IAAI,CAAC,CAAC;IAChD,MAAM,iBAAiB,GAEnB,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE;QAC1B,MAAM,MAAM,CAAC,QAAQ,CAAC;YACpB,EAAE,EAAE,IAAI,CAAC,KAAK;YACd,OAAO,EAAE,qBAAqB;YAC9B,IAAI,EAAE,0CAA0C,GAAG,EAAE;SACtD,CAAC,CAAC;IACL,CAAC,CAAC;IACF,MAAM,QAAQ,GAAoD;QAChE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;QACpD,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAC1C,MAAM,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC;KACxC,CAAC;IAEF,OAAO;QACL,GAAG,OAAO;QACV,OAAO;QACP,wBAAwB;QACxB,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,IAAI,iBAAiB;QAClE,QAAQ,EAAE;YACR,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,IAAI,QAAQ,CAAC,IAAI;YAC9C,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,QAAQ,CAAC,MAAM;SACrD;QACD,aAAa,EAAE,mBAAmB,IAAI,OAAO,EAAE,aAAa,KAAK,IAAI;KACtE,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"create-email-and-password-config.js","sourceRoot":"","sources":["../../src/utils/create-email-and-password-config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAO7C;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,aAAsB,EACtB,MAAc,EACd,WAAwB,EACxB,OAAiC;IAEjC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,SAAS,CAAC;IACnE,MAAM,yBAAyB,GAC7B,OAAO,CAAC,GAAG,CAAC,+BAA+B,KAAK,SAAS,CAAC;IAC5D,MAAM,mBAAmB,GACvB,aAAa,IAAI,SAAS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IAAI;KACtE,CAAC;AACJ,CAAC"}
|
|
@@ -3,6 +3,11 @@ import type { BetterAuthOptions } from "better-auth";
|
|
|
3
3
|
import type { AuthModuleOptions } from "../auth-module-options.interface.js";
|
|
4
4
|
type EmailVerificationConfig = NonNullable<BetterAuthOptions["emailVerification"]>;
|
|
5
5
|
type EmailVerificationOptions = AuthModuleOptions["emailVerification"];
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Creates the email verification configuration backed by the application mailer.
|
|
8
|
+
* @param mailer - Mailer used to deliver authentication emails.
|
|
9
|
+
* @param options - Configuration for this operation.
|
|
10
|
+
* @returns Email verification options with the configured delivery hook.
|
|
11
|
+
*/
|
|
7
12
|
export declare function createEmailVerificationConfig(mailer: Mailer, options?: EmailVerificationOptions): EmailVerificationConfig;
|
|
8
13
|
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Creates the email verification configuration backed by the application mailer.
|
|
3
|
+
* @param mailer - Mailer used to deliver authentication emails.
|
|
4
|
+
* @param options - Configuration for this operation.
|
|
5
|
+
* @returns Email verification options with the configured delivery hook.
|
|
6
|
+
*/
|
|
2
7
|
export function createEmailVerificationConfig(mailer, options) {
|
|
3
8
|
const sendVerificationEmail = async ({ user, url }) => {
|
|
4
9
|
await mailer.sendMail({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-email-verification-config.js","sourceRoot":"","sources":["../../src/utils/create-email-verification-config.ts"],"names":[],"mappings":"AAUA
|
|
1
|
+
{"version":3,"file":"create-email-verification-config.js","sourceRoot":"","sources":["../../src/utils/create-email-verification-config.ts"],"names":[],"mappings":"AAUA;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAC3C,MAAc,EACd,OAAkC;IAElC,MAAM,qBAAqB,GAEvB,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE;QAC1B,MAAM,MAAM,CAAC,QAAQ,CAAC;YACpB,EAAE,EAAE,IAAI,CAAC,KAAK;YACd,OAAO,EAAE,2BAA2B;YACpC,IAAI,EAAE,wCAAwC,GAAG,EAAE;SACpD,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,OAAO;QACV,qBAAqB,EACnB,OAAO,EAAE,qBAAqB,IAAI,qBAAqB;KAC1D,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { GenericOAuthProviderConfig } from "./generic-oauth-provider-config.type.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Combines custom Generic OAuth providers with the environment OIDC provider.
|
|
4
|
+
* @param disableSignUp - Whether provider-based registration is disabled.
|
|
5
|
+
* @param configuredProviders - Providers configured by the application.
|
|
6
|
+
* @param oidcConfig - OIDC provider configuration.
|
|
7
|
+
* @returns Generic OAuth providers with environment defaults and sign-up policy applied.
|
|
8
|
+
*/
|
|
3
9
|
export declare function createGenericOAuthConfig(disableSignUp: boolean, configuredProviders?: readonly GenericOAuthProviderConfig[], oidcConfig?: GenericOAuthProviderConfig): GenericOAuthProviderConfig[];
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Combines custom Generic OAuth providers with the environment OIDC provider.
|
|
3
|
+
* @param disableSignUp - Whether provider-based registration is disabled.
|
|
4
|
+
* @param configuredProviders - Providers configured by the application.
|
|
5
|
+
* @param oidcConfig - OIDC provider configuration.
|
|
6
|
+
* @returns Generic OAuth providers with environment defaults and sign-up policy applied.
|
|
7
|
+
*/
|
|
2
8
|
export function createGenericOAuthConfig(disableSignUp, configuredProviders = [], oidcConfig) {
|
|
3
9
|
const providers = [
|
|
4
10
|
...configuredProviders,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-generic-oauth-config.js","sourceRoot":"","sources":["../../src/utils/create-generic-oauth-config.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"create-generic-oauth-config.js","sourceRoot":"","sources":["../../src/utils/create-generic-oauth-config.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,aAAsB,EACtB,sBAA6D,EAAE,EAC/D,UAAuC;IAEvC,MAAM,SAAS,GAAG;QAChB,GAAG,mBAAmB;QACtB,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACpC,CAAC;IACF,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAChC,IAAI,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CACb,8BAA8B,QAAQ,CAAC,UAAU,iCAAiC,CACnF,CAAC;QACJ,CAAC;QACD,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAErC,OAAO,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { GenericOAuthProviderConfig } from "./generic-oauth-provider-config.type.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns environment-derived OIDC configuration, or undefined when disabled.
|
|
4
|
+
* @param disableSignUp - Whether provider-based registration is disabled.
|
|
5
|
+
* @returns Environment-derived OIDC configuration, or undefined when disabled.
|
|
6
|
+
*/
|
|
2
7
|
export declare function createOidcConfig(disableSignUp: boolean): GenericOAuthProviderConfig | undefined;
|
|
@@ -2,6 +2,11 @@ import { isEnvTrue } from "./is-env-true.js";
|
|
|
2
2
|
import { resolveOidcPrompt } from "./resolve-oidc-prompt.js";
|
|
3
3
|
import { resolveOidcScopes } from "./resolve-oidc-scopes.js";
|
|
4
4
|
import { resolveRequiredOidcEnv } from "./resolve-required-oidc-env.js";
|
|
5
|
+
/**
|
|
6
|
+
* Returns environment-derived OIDC configuration, or undefined when disabled.
|
|
7
|
+
* @param disableSignUp - Whether provider-based registration is disabled.
|
|
8
|
+
* @returns Environment-derived OIDC configuration, or undefined when disabled.
|
|
9
|
+
*/
|
|
5
10
|
export function createOidcConfig(disableSignUp) {
|
|
6
11
|
if (!isEnvTrue("AUTH_OIDC_ENABLED")) {
|
|
7
12
|
return undefined;
|