@nest-boot/auth 8.0.3-beta.0 → 8.0.3-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/README.md +538 -2
- package/dist/abilities/user.ability.d.ts +3 -0
- package/dist/abilities/user.ability.js +2 -0
- package/dist/abilities/user.ability.js.map +1 -1
- package/dist/abilities/workspace.ability.d.ts +3 -0
- package/dist/abilities/workspace.ability.js +2 -0
- package/dist/abilities/workspace.ability.js.map +1 -1
- package/dist/adapters/mikro-orm/adapter-config.js +1 -0
- package/dist/adapters/mikro-orm/adapter-config.js.map +1 -1
- package/dist/adapters/mikro-orm/create-custom-adapter.d.ts +3 -2
- package/dist/adapters/mikro-orm/create-custom-adapter.js +13 -22
- package/dist/adapters/mikro-orm/create-custom-adapter.js.map +1 -1
- package/dist/adapters/mikro-orm/entity-metadata-resolver.d.ts +2 -2
- package/dist/adapters/mikro-orm/entity-metadata-resolver.js +22 -0
- package/dist/adapters/mikro-orm/entity-metadata-resolver.js.map +1 -1
- package/dist/adapters/mikro-orm/where-compiler.d.ts +24 -24
- package/dist/adapters/mikro-orm-adapter.d.ts +6 -2
- package/dist/adapters/mikro-orm-adapter.js +5 -3
- package/dist/adapters/mikro-orm-adapter.js.map +1 -1
- package/dist/api-key-usage.interceptor.d.ts +5 -2
- package/dist/api-key-usage.interceptor.js +10 -8
- package/dist/api-key-usage.interceptor.js.map +1 -1
- package/dist/auth-handler.middleware.d.ts +3 -0
- package/dist/auth-handler.middleware.js +3 -0
- package/dist/auth-handler.middleware.js.map +1 -1
- package/dist/auth-module-options.interface.d.ts +31 -338
- package/dist/auth.constants.d.ts +4 -0
- package/dist/auth.constants.js +4 -0
- package/dist/auth.constants.js.map +1 -1
- package/dist/auth.guard.d.ts +31 -9
- package/dist/auth.guard.js +49 -106
- package/dist/auth.guard.js.map +1 -1
- package/dist/auth.middleware.d.ts +21 -6
- package/dist/auth.middleware.js +124 -36
- package/dist/auth.middleware.js.map +1 -1
- package/dist/auth.module-definition.d.ts +1 -1
- package/dist/auth.module.d.ts +28 -5
- package/dist/auth.module.js +87 -64
- package/dist/auth.module.js.map +1 -1
- package/dist/connections/account.connection-definition.d.ts +9 -0
- package/dist/connections/account.connection-definition.js +38 -0
- package/dist/connections/account.connection-definition.js.map +1 -0
- package/dist/connections/index.d.ts +8 -0
- package/dist/connections/index.js +9 -0
- package/dist/connections/index.js.map +1 -0
- package/dist/connections/invitation.connection-definition.d.ts +9 -0
- package/dist/connections/invitation.connection-definition.js +40 -0
- package/dist/connections/invitation.connection-definition.js.map +1 -0
- package/dist/connections/member.connection-definition.d.ts +9 -0
- package/dist/connections/member.connection-definition.js +52 -0
- package/dist/connections/member.connection-definition.js.map +1 -0
- package/dist/connections/session.connection-definition.d.ts +9 -0
- package/dist/connections/session.connection-definition.js +32 -0
- package/dist/connections/session.connection-definition.js.map +1 -0
- package/dist/connections/user-api-key.connection-definition.d.ts +13 -0
- package/dist/connections/user-api-key.connection-definition.js +60 -0
- package/dist/connections/user-api-key.connection-definition.js.map +1 -0
- package/dist/connections/user.connection-definition.d.ts +9 -0
- package/dist/connections/user.connection-definition.js +46 -0
- package/dist/connections/user.connection-definition.js.map +1 -0
- package/dist/connections/workspace-api-key.connection-definition.d.ts +13 -0
- package/dist/connections/workspace-api-key.connection-definition.js +60 -0
- package/dist/connections/workspace-api-key.connection-definition.js.map +1 -0
- package/dist/connections/workspace.connection-definition.d.ts +13 -0
- package/dist/connections/workspace.connection-definition.js +43 -0
- package/dist/connections/workspace.connection-definition.js.map +1 -0
- package/dist/decorators/can.decorator.d.ts +8 -0
- package/dist/decorators/can.decorator.js +8 -0
- package/dist/decorators/can.decorator.js.map +1 -1
- package/dist/decorators/current-api-key.decorator.d.ts +1 -0
- package/dist/decorators/current-api-key.decorator.js +3 -3
- package/dist/decorators/current-api-key.decorator.js.map +1 -1
- package/dist/decorators/current-member.decorator.d.ts +2 -0
- package/dist/decorators/current-member.decorator.js +6 -0
- package/dist/decorators/current-member.decorator.js.map +1 -0
- package/dist/decorators/current-session.decorator.d.ts +1 -0
- package/dist/decorators/current-session.decorator.js +3 -2
- package/dist/decorators/current-session.decorator.js.map +1 -1
- package/dist/decorators/current-user.decorator.d.ts +1 -0
- package/dist/decorators/current-user.decorator.js +3 -2
- package/dist/decorators/current-user.decorator.js.map +1 -1
- package/dist/decorators/current-workspace.decorator.d.ts +1 -0
- package/dist/decorators/current-workspace.decorator.js +3 -2
- package/dist/decorators/current-workspace.decorator.js.map +1 -1
- package/dist/decorators/index.d.ts +1 -1
- package/dist/decorators/index.js +1 -1
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/public.decorator.d.ts +1 -0
- package/dist/decorators/public.decorator.js +1 -0
- package/dist/decorators/public.decorator.js.map +1 -1
- package/dist/decorators/user-can.decorator.d.ts +8 -0
- package/dist/decorators/user-can.decorator.js +8 -0
- package/dist/decorators/user-can.decorator.js.map +1 -1
- package/dist/decorators/workspace-can.decorator.d.ts +8 -0
- package/dist/decorators/workspace-can.decorator.js +8 -0
- package/dist/decorators/workspace-can.decorator.js.map +1 -1
- package/dist/entities/account.entity.d.ts +21 -3
- package/dist/entities/account.entity.js +67 -29
- package/dist/entities/account.entity.js.map +1 -1
- package/dist/entities/auth-entity-map.d.ts +21 -0
- package/dist/entities/auth-entity-map.js +22 -0
- package/dist/entities/auth-entity-map.js.map +1 -0
- package/dist/entities/index.d.ts +14 -3
- package/dist/entities/index.js +25 -3
- package/dist/entities/index.js.map +1 -1
- package/dist/entities/invitation.entity.d.ts +24 -0
- package/dist/entities/invitation.entity.js +117 -0
- package/dist/entities/invitation.entity.js.map +1 -0
- package/dist/entities/member.entity.d.ts +28 -0
- package/dist/entities/member.entity.js +126 -0
- package/dist/entities/member.entity.js.map +1 -0
- package/dist/entities/session.entity.d.ts +16 -6
- package/dist/entities/session.entity.js +57 -27
- package/dist/entities/session.entity.js.map +1 -1
- package/dist/entities/user-api-key.entity.d.ts +29 -0
- package/dist/entities/user-api-key.entity.js +147 -0
- package/dist/entities/user-api-key.entity.js.map +1 -0
- package/dist/entities/user.entity.d.ts +18 -2
- package/dist/entities/user.entity.js +104 -29
- package/dist/entities/user.entity.js.map +1 -1
- package/dist/entities/verification.entity.d.ts +8 -1
- package/dist/entities/verification.entity.js +27 -11
- package/dist/entities/verification.entity.js.map +1 -1
- package/dist/entities/workspace-api-key.entity.d.ts +29 -0
- package/dist/entities/workspace-api-key.entity.js +147 -0
- package/dist/entities/workspace-api-key.entity.js.map +1 -0
- package/dist/entities/workspace.entity.d.ts +10 -3
- package/dist/entities/workspace.entity.js +51 -20
- package/dist/entities/workspace.entity.js.map +1 -1
- package/dist/enums/index.d.ts +8 -0
- package/dist/enums/index.js +9 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/enums/invitation-status.enum.d.ts +11 -0
- package/dist/enums/invitation-status.enum.js +17 -0
- package/dist/enums/invitation-status.enum.js.map +1 -0
- package/dist/enums/member-status.enum.d.ts +9 -0
- package/dist/enums/member-status.enum.js +15 -0
- package/dist/enums/member-status.enum.js.map +1 -0
- package/dist/enums/user-api-key-permission.enum.d.ts +4 -0
- package/dist/enums/user-api-key-permission.enum.js +11 -0
- package/dist/enums/user-api-key-permission.enum.js.map +1 -0
- package/dist/enums/user-permission.enum.d.ts +4 -0
- package/dist/enums/user-permission.enum.js +7 -0
- package/dist/enums/user-permission.enum.js.map +1 -0
- package/dist/enums/user-role.enum.d.ts +4 -0
- package/dist/enums/user-role.enum.js +6 -0
- package/dist/enums/user-role.enum.js.map +1 -0
- package/dist/enums/workspace-api-key-permission.enum.d.ts +4 -0
- package/dist/enums/workspace-api-key-permission.enum.js +11 -0
- package/dist/enums/workspace-api-key-permission.enum.js.map +1 -0
- package/dist/enums/workspace-permission.enum.d.ts +4 -0
- package/dist/enums/workspace-permission.enum.js +7 -0
- package/dist/enums/workspace-permission.enum.js.map +1 -0
- package/dist/enums/workspace-role.enum.d.ts +4 -0
- package/dist/enums/workspace-role.enum.js +9 -0
- package/dist/enums/workspace-role.enum.js.map +1 -0
- package/dist/index.d.ts +184 -12
- package/dist/index.js +183 -12
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/api-key-authentication.service.d.ts +14 -0
- package/dist/infrastructure/api-key-authentication.service.js +78 -0
- package/dist/infrastructure/api-key-authentication.service.js.map +1 -0
- package/dist/infrastructure/auth-ability.factory.d.ts +15 -0
- package/dist/infrastructure/auth-ability.factory.js +91 -0
- package/dist/infrastructure/auth-ability.factory.js.map +1 -0
- package/dist/infrastructure/auth-enum-registry.d.ts +8 -0
- package/dist/infrastructure/auth-enum-registry.js +48 -0
- package/dist/infrastructure/auth-enum-registry.js.map +1 -0
- package/dist/infrastructure/auth-service.providers.d.ts +3 -0
- package/dist/infrastructure/auth-service.providers.js +72 -0
- package/dist/infrastructure/auth-service.providers.js.map +1 -0
- package/dist/infrastructure/create-contextual-auth-service.d.ts +10 -0
- package/dist/infrastructure/create-contextual-auth-service.js +50 -0
- package/dist/infrastructure/create-contextual-auth-service.js.map +1 -0
- package/dist/infrastructure/request-identity.d.ts +34 -0
- package/dist/infrastructure/request-identity.js +174 -0
- package/dist/infrastructure/request-identity.js.map +1 -0
- package/dist/infrastructure/revoked-authentication.exception.d.ts +4 -0
- package/dist/infrastructure/revoked-authentication.exception.js +5 -0
- package/dist/infrastructure/revoked-authentication.exception.js.map +1 -0
- package/dist/inputs/add-member.input.d.ts +5 -0
- package/dist/inputs/add-member.input.js +26 -0
- package/dist/inputs/add-member.input.js.map +1 -0
- package/dist/inputs/auth-change-email.input.d.ts +7 -0
- package/dist/inputs/auth-change-email.input.js +33 -0
- package/dist/inputs/auth-change-email.input.js.map +1 -0
- package/dist/inputs/auth-change-password.input.d.ts +9 -0
- package/dist/inputs/auth-change-password.input.js +40 -0
- package/dist/inputs/auth-change-password.input.js.map +1 -0
- package/dist/inputs/auth-delete-user.input.d.ts +9 -0
- package/dist/inputs/auth-delete-user.input.js +40 -0
- package/dist/inputs/auth-delete-user.input.js.map +1 -0
- package/dist/inputs/auth-link-social-account.input.d.ts +13 -0
- package/dist/inputs/auth-link-social-account.input.js +54 -0
- package/dist/inputs/auth-link-social-account.input.js.map +1 -0
- package/dist/inputs/auth-request-password-reset.input.d.ts +7 -0
- package/dist/inputs/auth-request-password-reset.input.js +33 -0
- package/dist/inputs/auth-request-password-reset.input.js.map +1 -0
- package/dist/inputs/auth-reset-password.input.d.ts +7 -0
- package/dist/inputs/auth-reset-password.input.js +33 -0
- package/dist/inputs/auth-reset-password.input.js.map +1 -0
- package/dist/inputs/auth-send-verification-email.input.d.ts +7 -0
- package/dist/inputs/auth-send-verification-email.input.js +33 -0
- package/dist/inputs/auth-send-verification-email.input.js.map +1 -0
- package/dist/inputs/auth-sign-in-social.input.d.ts +17 -0
- package/dist/inputs/auth-sign-in-social.input.js +68 -0
- package/dist/inputs/auth-sign-in-social.input.js.map +1 -0
- package/dist/inputs/auth-sign-in.input.d.ts +11 -0
- package/dist/inputs/auth-sign-in.input.js +47 -0
- package/dist/inputs/auth-sign-in.input.js.map +1 -0
- package/dist/inputs/auth-sign-up.input.d.ts +15 -0
- package/dist/inputs/auth-sign-up.input.js +61 -0
- package/dist/inputs/auth-sign-up.input.js.map +1 -0
- package/dist/inputs/auth-update-user.input.d.ts +7 -0
- package/dist/inputs/auth-update-user.input.js +33 -0
- package/dist/inputs/auth-update-user.input.js.map +1 -0
- package/dist/inputs/ban-user.input.d.ts +7 -0
- package/dist/inputs/ban-user.input.js +33 -0
- package/dist/inputs/ban-user.input.js.map +1 -0
- package/dist/inputs/create-invitation.input.d.ts +10 -0
- package/dist/inputs/create-invitation.input.js +41 -0
- package/dist/inputs/create-invitation.input.js.map +1 -0
- package/dist/inputs/create-user-api-key.input.d.ts +14 -0
- package/dist/inputs/create-user-api-key.input.js +55 -0
- package/dist/inputs/create-user-api-key.input.js.map +1 -0
- package/dist/inputs/create-user.input.d.ts +15 -0
- package/dist/inputs/create-user.input.js +56 -0
- package/dist/inputs/create-user.input.js.map +1 -0
- package/dist/inputs/create-workspace-api-key.input.d.ts +14 -0
- package/dist/inputs/create-workspace-api-key.input.js +55 -0
- package/dist/inputs/create-workspace-api-key.input.js.map +1 -0
- package/dist/inputs/create-workspace.input.d.ts +7 -0
- package/dist/inputs/create-workspace.input.js +28 -0
- package/dist/inputs/create-workspace.input.js.map +1 -0
- package/dist/inputs/set-member-permissions.input.d.ts +6 -0
- package/dist/inputs/set-member-permissions.input.js +27 -0
- package/dist/inputs/set-member-permissions.input.js.map +1 -0
- package/dist/inputs/set-member-roles.input.d.ts +6 -0
- package/dist/inputs/set-member-roles.input.js +27 -0
- package/dist/inputs/set-member-roles.input.js.map +1 -0
- package/dist/inputs/set-user-password.input.d.ts +5 -0
- package/dist/inputs/set-user-password.input.js +26 -0
- package/dist/inputs/set-user-password.input.js.map +1 -0
- package/dist/inputs/set-user-permissions.input.d.ts +6 -0
- package/dist/inputs/set-user-permissions.input.js +27 -0
- package/dist/inputs/set-user-permissions.input.js.map +1 -0
- package/dist/inputs/set-user-roles.input.d.ts +6 -0
- package/dist/inputs/set-user-roles.input.js +27 -0
- package/dist/inputs/set-user-roles.input.js.map +1 -0
- package/dist/inputs/update-member.input.d.ts +10 -0
- package/dist/inputs/update-member.input.js +43 -0
- package/dist/inputs/update-member.input.js.map +1 -0
- package/dist/inputs/update-user-api-key.input.d.ts +14 -0
- package/dist/inputs/update-user-api-key.input.js +50 -0
- package/dist/inputs/update-user-api-key.input.js.map +1 -0
- package/dist/inputs/update-user.input.d.ts +11 -0
- package/dist/inputs/update-user.input.js +47 -0
- package/dist/inputs/update-user.input.js.map +1 -0
- package/dist/inputs/update-workspace-api-key.input.d.ts +14 -0
- package/dist/inputs/update-workspace-api-key.input.js +50 -0
- package/dist/inputs/update-workspace-api-key.input.js.map +1 -0
- package/dist/inputs/update-workspace.input.d.ts +7 -0
- package/dist/inputs/update-workspace.input.js +28 -0
- package/dist/inputs/update-workspace.input.js.map +1 -0
- package/dist/inputs/user-id.input.d.ts +5 -0
- package/dist/inputs/user-id.input.js +26 -0
- package/dist/inputs/user-id.input.js.map +1 -0
- package/dist/interfaces/ability-rules.interface.d.ts +8 -0
- package/dist/interfaces/ability-rules.interface.js +2 -0
- package/dist/interfaces/ability-rules.interface.js.map +1 -0
- package/dist/interfaces/accept-invitation-result.interface.d.ts +9 -0
- package/dist/interfaces/accept-invitation-result.interface.js +2 -0
- package/dist/interfaces/accept-invitation-result.interface.js.map +1 -0
- package/dist/interfaces/add-member-options.interface.d.ts +7 -0
- package/dist/interfaces/add-member-options.interface.js +2 -0
- package/dist/interfaces/add-member-options.interface.js.map +1 -0
- package/dist/interfaces/auth-access-token.interface.d.ts +11 -0
- package/dist/interfaces/auth-access-token.interface.js +2 -0
- package/dist/interfaces/auth-access-token.interface.js.map +1 -0
- package/dist/interfaces/auth-account-info.interface.d.ts +11 -0
- package/dist/interfaces/auth-account-info.interface.js +2 -0
- package/dist/interfaces/auth-account-info.interface.js.map +1 -0
- package/dist/interfaces/auth-account.interface.d.ts +19 -0
- package/dist/interfaces/auth-account.interface.js +2 -0
- package/dist/interfaces/auth-account.interface.js.map +1 -0
- package/dist/interfaces/auth-change-email-confirmation-data.interface.d.ts +12 -0
- package/dist/interfaces/auth-change-email-confirmation-data.interface.js +2 -0
- package/dist/interfaces/auth-change-email-confirmation-data.interface.js.map +1 -0
- package/dist/interfaces/auth-delete-account-verification-data.interface.d.ts +10 -0
- package/dist/interfaces/auth-delete-account-verification-data.interface.js +2 -0
- package/dist/interfaces/auth-delete-account-verification-data.interface.js.map +1 -0
- package/dist/interfaces/auth-email-verification-data.interface.d.ts +10 -0
- package/dist/interfaces/auth-email-verification-data.interface.js +2 -0
- package/dist/interfaces/auth-email-verification-data.interface.js.map +1 -0
- package/dist/interfaces/auth-invitation-email-data.interface.d.ts +18 -0
- package/dist/interfaces/auth-invitation-email-data.interface.js +2 -0
- package/dist/interfaces/auth-invitation-email-data.interface.js.map +1 -0
- package/dist/interfaces/auth-module-account-linking-options.interface.d.ts +18 -0
- package/dist/interfaces/auth-module-account-linking-options.interface.js +2 -0
- package/dist/interfaces/auth-module-account-linking-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-account-options.interface.d.ts +16 -0
- package/dist/interfaces/auth-module-account-options.interface.js +2 -0
- package/dist/interfaces/auth-module-account-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-api-key-options.interface.d.ts +15 -0
- package/dist/interfaces/auth-module-api-key-options.interface.js +2 -0
- package/dist/interfaces/auth-module-api-key-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-change-email-options.interface.d.ts +10 -0
- package/dist/interfaces/auth-module-change-email-options.interface.js +2 -0
- package/dist/interfaces/auth-module-change-email-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-delete-user-options.interface.d.ts +15 -0
- package/dist/interfaces/auth-module-delete-user-options.interface.js +2 -0
- package/dist/interfaces/auth-module-delete-user-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-email-and-password-options.interface.d.ts +34 -0
- package/dist/interfaces/auth-module-email-and-password-options.interface.js +2 -0
- package/dist/interfaces/auth-module-email-and-password-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-email-verification-options.interface.d.ts +19 -0
- package/dist/interfaces/auth-module-email-verification-options.interface.js +2 -0
- package/dist/interfaces/auth-module-email-verification-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-middleware-options.interface.d.ts +11 -0
- package/dist/interfaces/auth-module-middleware-options.interface.js +2 -0
- package/dist/interfaces/auth-module-middleware-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-oauth-provider.interface.d.ts +91 -0
- package/dist/interfaces/auth-module-oauth-provider.interface.js +2 -0
- package/dist/interfaces/auth-module-oauth-provider.interface.js.map +1 -0
- package/dist/interfaces/auth-module-password-options.interface.d.ts +10 -0
- package/dist/interfaces/auth-module-password-options.interface.js +2 -0
- package/dist/interfaces/auth-module-password-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-session-cookie-cache-options.interface.d.ts +14 -0
- package/dist/interfaces/auth-module-session-cookie-cache-options.interface.js +2 -0
- package/dist/interfaces/auth-module-session-cookie-cache-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-session-cookie-cache-refresh-options.interface.d.ts +5 -0
- package/dist/interfaces/auth-module-session-cookie-cache-refresh-options.interface.js +2 -0
- package/dist/interfaces/auth-module-session-cookie-cache-refresh-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-session-options.interface.d.ts +16 -0
- package/dist/interfaces/auth-module-session-options.interface.js +2 -0
- package/dist/interfaces/auth-module-session-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-social-provider.interface.d.ts +109 -0
- package/dist/interfaces/auth-module-social-provider.interface.js +2 -0
- package/dist/interfaces/auth-module-social-provider.interface.js.map +1 -0
- package/dist/interfaces/auth-module-user-options.interface.d.ts +22 -0
- package/dist/interfaces/auth-module-user-options.interface.js +2 -0
- package/dist/interfaces/auth-module-user-options.interface.js.map +1 -0
- package/dist/interfaces/auth-module-workspace-options.interface.d.ts +19 -0
- package/dist/interfaces/auth-module-workspace-options.interface.js +2 -0
- package/dist/interfaces/auth-module-workspace-options.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-basic-token-endpoint-auth.interface.d.ts +5 -0
- package/dist/interfaces/auth-oauth-basic-token-endpoint-auth.interface.js +2 -0
- package/dist/interfaces/auth-oauth-basic-token-endpoint-auth.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-client-assertion-context.interface.d.ts +9 -0
- package/dist/interfaces/auth-oauth-client-assertion-context.interface.js +2 -0
- package/dist/interfaces/auth-oauth-client-assertion-context.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-custom-token-endpoint-auth.interface.d.ts +8 -0
- package/dist/interfaces/auth-oauth-custom-token-endpoint-auth.interface.js +2 -0
- package/dist/interfaces/auth-oauth-custom-token-endpoint-auth.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-mapped-user.interface.d.ts +15 -0
- package/dist/interfaces/auth-oauth-mapped-user.interface.js +2 -0
- package/dist/interfaces/auth-oauth-mapped-user.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-no-token-endpoint-auth.interface.d.ts +5 -0
- package/dist/interfaces/auth-oauth-no-token-endpoint-auth.interface.js +2 -0
- package/dist/interfaces/auth-oauth-no-token-endpoint-auth.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-post-token-endpoint-auth.interface.d.ts +5 -0
- package/dist/interfaces/auth-oauth-post-token-endpoint-auth.interface.js +2 -0
- package/dist/interfaces/auth-oauth-post-token-endpoint-auth.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-private-key-jwt-token-endpoint-auth.interface.d.ts +9 -0
- package/dist/interfaces/auth-oauth-private-key-jwt-token-endpoint-auth.interface.js +2 -0
- package/dist/interfaces/auth-oauth-private-key-jwt-token-endpoint-auth.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-profile.interface.d.ts +9 -0
- package/dist/interfaces/auth-oauth-profile.interface.js +2 -0
- package/dist/interfaces/auth-oauth-profile.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-refresh-context.interface.d.ts +7 -0
- package/dist/interfaces/auth-oauth-refresh-context.interface.js +2 -0
- package/dist/interfaces/auth-oauth-refresh-context.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-token-request-client-options.interface.d.ts +7 -0
- package/dist/interfaces/auth-oauth-token-request-client-options.interface.js +2 -0
- package/dist/interfaces/auth-oauth-token-request-client-options.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-token-request-context.interface.d.ts +15 -0
- package/dist/interfaces/auth-oauth-token-request-context.interface.js +2 -0
- package/dist/interfaces/auth-oauth-token-request-context.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-tokens.interface.d.ts +19 -0
- package/dist/interfaces/auth-oauth-tokens.interface.js +2 -0
- package/dist/interfaces/auth-oauth-tokens.interface.js.map +1 -0
- package/dist/interfaces/auth-oauth-user-info.interface.d.ts +13 -0
- package/dist/interfaces/auth-oauth-user-info.interface.js +2 -0
- package/dist/interfaces/auth-oauth-user-info.interface.js.map +1 -0
- package/dist/interfaces/auth-provider-user-info.interface.d.ts +13 -0
- package/dist/interfaces/auth-provider-user-info.interface.js +2 -0
- package/dist/interfaces/auth-provider-user-info.interface.js.map +1 -0
- package/dist/interfaces/auth-refreshed-token.interface.d.ts +19 -0
- package/dist/interfaces/auth-refreshed-token.interface.js +2 -0
- package/dist/interfaces/auth-refreshed-token.interface.js.map +1 -0
- package/dist/interfaces/auth-reset-password-data.interface.d.ts +10 -0
- package/dist/interfaces/auth-reset-password-data.interface.js +2 -0
- package/dist/interfaces/auth-reset-password-data.interface.js.map +1 -0
- package/dist/interfaces/auth-social-provider-user-info.interface.d.ts +8 -0
- package/dist/interfaces/auth-social-provider-user-info.interface.js +2 -0
- package/dist/interfaces/auth-social-provider-user-info.interface.js.map +1 -0
- package/dist/interfaces/auth-social-provider.interface.d.ts +7 -0
- package/dist/interfaces/auth-social-provider.interface.js +2 -0
- package/dist/interfaces/auth-social-provider.interface.js.map +1 -0
- package/dist/interfaces/auth-user.interface.d.ts +19 -0
- package/dist/interfaces/auth-user.interface.js +2 -0
- package/dist/interfaces/auth-user.interface.js.map +1 -0
- package/dist/interfaces/authenticated-session.interface.d.ts +9 -0
- package/dist/interfaces/authenticated-session.interface.js +2 -0
- package/dist/interfaces/authenticated-session.interface.js.map +1 -0
- package/dist/interfaces/ban-user-options.interface.d.ts +7 -0
- package/dist/interfaces/ban-user-options.interface.js +2 -0
- package/dist/interfaces/ban-user-options.interface.js.map +1 -0
- package/dist/interfaces/can-options.interface.d.ts +2 -0
- package/dist/interfaces/change-auth-email-options.interface.d.ts +7 -0
- package/dist/interfaces/change-auth-email-options.interface.js +2 -0
- package/dist/interfaces/change-auth-email-options.interface.js.map +1 -0
- package/dist/interfaces/change-auth-password-options.interface.d.ts +9 -0
- package/dist/interfaces/change-auth-password-options.interface.js +2 -0
- package/dist/interfaces/change-auth-password-options.interface.js.map +1 -0
- package/dist/interfaces/change-auth-password-result.interface.d.ts +5 -0
- package/dist/interfaces/change-auth-password-result.interface.js +2 -0
- package/dist/interfaces/change-auth-password-result.interface.js.map +1 -0
- package/dist/interfaces/create-api-key-options.interface.d.ts +14 -0
- package/dist/interfaces/create-api-key-options.interface.js +2 -0
- package/dist/interfaces/create-api-key-options.interface.js.map +1 -0
- package/dist/interfaces/create-invitation-options.interface.d.ts +9 -0
- package/dist/interfaces/create-invitation-options.interface.js +2 -0
- package/dist/interfaces/create-invitation-options.interface.js.map +1 -0
- package/dist/interfaces/create-user-options.interface.d.ts +13 -0
- package/dist/interfaces/create-user-options.interface.js +2 -0
- package/dist/interfaces/create-user-options.interface.js.map +1 -0
- package/dist/interfaces/create-workspace-options.interface.d.ts +5 -0
- package/dist/interfaces/create-workspace-options.interface.js +2 -0
- package/dist/interfaces/create-workspace-options.interface.js.map +1 -0
- package/dist/interfaces/created-api-key.interface.d.ts +8 -0
- package/dist/interfaces/created-api-key.interface.js +2 -0
- package/dist/interfaces/created-api-key.interface.js.map +1 -0
- package/dist/interfaces/delete-auth-user-options.interface.d.ts +9 -0
- package/dist/interfaces/delete-auth-user-options.interface.js +2 -0
- package/dist/interfaces/delete-auth-user-options.interface.js.map +1 -0
- package/dist/interfaces/delete-auth-user-result.interface.d.ts +7 -0
- package/dist/interfaces/delete-auth-user-result.interface.js +2 -0
- package/dist/interfaces/delete-auth-user-result.interface.js.map +1 -0
- package/dist/interfaces/impersonation-options.interface.d.ts +7 -0
- package/dist/interfaces/impersonation-options.interface.js +2 -0
- package/dist/interfaces/impersonation-options.interface.js.map +1 -0
- package/dist/interfaces/link-auth-social-account-options.interface.d.ts +21 -0
- package/dist/interfaces/link-auth-social-account-options.interface.js +2 -0
- package/dist/interfaces/link-auth-social-account-options.interface.js.map +1 -0
- package/dist/interfaces/link-auth-social-account-result.interface.d.ts +7 -0
- package/dist/interfaces/link-auth-social-account-result.interface.js +2 -0
- package/dist/interfaces/link-auth-social-account-result.interface.js.map +1 -0
- package/dist/interfaces/request-identity-patch.interface.d.ts +13 -0
- package/dist/interfaces/request-identity-patch.interface.js +2 -0
- package/dist/interfaces/request-identity-patch.interface.js.map +1 -0
- package/dist/interfaces/request-password-reset-options.interface.d.ts +7 -0
- package/dist/interfaces/request-password-reset-options.interface.js +2 -0
- package/dist/interfaces/request-password-reset-options.interface.js.map +1 -0
- package/dist/interfaces/request-password-reset-result.interface.d.ts +7 -0
- package/dist/interfaces/request-password-reset-result.interface.js +2 -0
- package/dist/interfaces/request-password-reset-result.interface.js.map +1 -0
- package/dist/interfaces/request-permissions.interface.d.ts +7 -0
- package/dist/interfaces/request-permissions.interface.js +2 -0
- package/dist/interfaces/request-permissions.interface.js.map +1 -0
- package/dist/interfaces/reset-password-options.interface.d.ts +7 -0
- package/dist/interfaces/reset-password-options.interface.js +2 -0
- package/dist/interfaces/reset-password-options.interface.js.map +1 -0
- package/dist/interfaces/route-argument-metadata-value.interface.d.ts +4 -0
- package/dist/interfaces/scope-policy-options.interface.d.ts +14 -0
- package/dist/interfaces/scope-policy-options.interface.js +2 -0
- package/dist/interfaces/scope-policy-options.interface.js.map +1 -0
- package/dist/interfaces/send-verification-email-options.interface.d.ts +7 -0
- package/dist/interfaces/send-verification-email-options.interface.js +2 -0
- package/dist/interfaces/send-verification-email-options.interface.js.map +1 -0
- package/dist/interfaces/serialized-ability-rule.interface.d.ts +7 -0
- package/dist/interfaces/sign-in-entity-result.interface.d.ts +7 -0
- package/dist/interfaces/sign-in-entity-result.interface.js +2 -0
- package/dist/interfaces/sign-in-entity-result.interface.js.map +1 -0
- package/dist/interfaces/sign-in-options.interface.d.ts +11 -0
- package/dist/interfaces/sign-in-options.interface.js +2 -0
- package/dist/interfaces/sign-in-options.interface.js.map +1 -0
- package/dist/interfaces/sign-in-result.interface.d.ts +12 -0
- package/dist/interfaces/sign-in-result.interface.js +2 -0
- package/dist/interfaces/sign-in-result.interface.js.map +1 -0
- package/dist/interfaces/sign-in-social-entity-result.interface.d.ts +7 -0
- package/dist/interfaces/sign-in-social-entity-result.interface.js +2 -0
- package/dist/interfaces/sign-in-social-entity-result.interface.js.map +1 -0
- package/dist/interfaces/sign-in-social-options.interface.d.ts +23 -0
- package/dist/interfaces/sign-in-social-options.interface.js +2 -0
- package/dist/interfaces/sign-in-social-options.interface.js.map +1 -0
- package/dist/interfaces/sign-in-social-result.interface.d.ts +12 -0
- package/dist/interfaces/sign-in-social-result.interface.js +2 -0
- package/dist/interfaces/sign-in-social-result.interface.js.map +1 -0
- package/dist/interfaces/sign-up-options.interface.d.ts +15 -0
- package/dist/interfaces/sign-up-options.interface.js +2 -0
- package/dist/interfaces/sign-up-options.interface.js.map +1 -0
- package/dist/interfaces/sign-up-result.interface.d.ts +8 -0
- package/dist/interfaces/sign-up-result.interface.js +2 -0
- package/dist/interfaces/sign-up-result.interface.js.map +1 -0
- package/dist/interfaces/unlink-auth-account-options.interface.d.ts +5 -0
- package/dist/interfaces/unlink-auth-account-options.interface.js +2 -0
- package/dist/interfaces/unlink-auth-account-options.interface.js.map +1 -0
- package/dist/interfaces/update-api-key-options.interface.d.ts +14 -0
- package/dist/interfaces/update-api-key-options.interface.js +2 -0
- package/dist/interfaces/update-api-key-options.interface.js.map +1 -0
- package/dist/interfaces/update-auth-user-options.interface.d.ts +7 -0
- package/dist/interfaces/update-auth-user-options.interface.js +2 -0
- package/dist/interfaces/update-auth-user-options.interface.js.map +1 -0
- package/dist/interfaces/update-member-options.interface.d.ts +10 -0
- package/dist/interfaces/update-member-options.interface.js +2 -0
- package/dist/interfaces/update-member-options.interface.js.map +1 -0
- package/dist/interfaces/update-user-options.interface.d.ts +11 -0
- package/dist/interfaces/update-user-options.interface.js +2 -0
- package/dist/interfaces/update-user-options.interface.js.map +1 -0
- package/dist/interfaces/update-workspace-options.interface.d.ts +5 -0
- package/dist/interfaces/update-workspace-options.interface.js +2 -0
- package/dist/interfaces/update-workspace-options.interface.js.map +1 -0
- package/dist/interfaces/user-api-key-validation.interface.d.ts +11 -0
- package/dist/interfaces/user-api-key-validation.interface.js +2 -0
- package/dist/interfaces/user-api-key-validation.interface.js.map +1 -0
- package/dist/interfaces/user-can-metadata.interface.d.ts +3 -0
- package/dist/interfaces/user-has-permissions-options.interface.d.ts +5 -0
- package/dist/interfaces/user-has-permissions-options.interface.js +2 -0
- package/dist/interfaces/user-has-permissions-options.interface.js.map +1 -0
- package/dist/interfaces/workspace-api-key-validation.interface.d.ts +11 -0
- package/dist/interfaces/workspace-api-key-validation.interface.js +2 -0
- package/dist/interfaces/workspace-api-key-validation.interface.js.map +1 -0
- package/dist/interfaces/workspace-can-metadata.interface.d.ts +3 -0
- package/dist/interfaces/workspace-has-permissions-options.interface.d.ts +5 -0
- package/dist/interfaces/workspace-has-permissions-options.interface.js +2 -0
- package/dist/interfaces/workspace-has-permissions-options.interface.js.map +1 -0
- package/dist/objects/accept-invitation-payload.object.d.ts +9 -0
- package/dist/objects/accept-invitation-payload.object.js +36 -0
- package/dist/objects/accept-invitation-payload.object.js.map +1 -0
- package/dist/objects/add-member-payload.object.d.ts +5 -0
- package/dist/objects/add-member-payload.object.js +24 -0
- package/dist/objects/add-member-payload.object.js.map +1 -0
- package/dist/objects/auth-ability-rule.object.d.ts +15 -0
- package/dist/objects/auth-ability-rule.object.js +55 -0
- package/dist/objects/auth-ability-rule.object.js.map +1 -0
- package/dist/objects/auth-change-password-result.object.d.ts +5 -0
- package/dist/objects/auth-change-password-result.object.js +24 -0
- package/dist/objects/auth-change-password-result.object.js.map +1 -0
- package/dist/objects/auth-delete-user-result.object.d.ts +7 -0
- package/dist/objects/auth-delete-user-result.object.js +30 -0
- package/dist/objects/auth-delete-user-result.object.js.map +1 -0
- package/dist/objects/auth-link-social-account-result.object.d.ts +7 -0
- package/dist/objects/auth-link-social-account-result.object.js +30 -0
- package/dist/objects/auth-link-social-account-result.object.js.map +1 -0
- package/dist/objects/auth-request-password-reset-result.object.d.ts +7 -0
- package/dist/objects/auth-request-password-reset-result.object.js +30 -0
- package/dist/objects/auth-request-password-reset-result.object.js.map +1 -0
- package/dist/objects/auth-sign-in-result.object.d.ts +12 -0
- package/dist/objects/auth-sign-in-result.object.js +43 -0
- package/dist/objects/auth-sign-in-result.object.js.map +1 -0
- package/dist/objects/auth-sign-in-social-result.object.d.ts +12 -0
- package/dist/objects/auth-sign-in-social-result.object.js +43 -0
- package/dist/objects/auth-sign-in-social-result.object.js.map +1 -0
- package/dist/objects/auth-social-provider.object.d.ts +7 -0
- package/dist/objects/auth-social-provider.object.js +30 -0
- package/dist/objects/auth-social-provider.object.js.map +1 -0
- package/dist/objects/ban-user-payload.object.d.ts +5 -0
- package/dist/objects/ban-user-payload.object.js +24 -0
- package/dist/objects/ban-user-payload.object.js.map +1 -0
- package/dist/objects/cancel-invitation-payload.object.d.ts +5 -0
- package/dist/objects/cancel-invitation-payload.object.js +24 -0
- package/dist/objects/cancel-invitation-payload.object.js.map +1 -0
- package/dist/objects/create-invitation-payload.object.d.ts +5 -0
- package/dist/objects/create-invitation-payload.object.js +24 -0
- package/dist/objects/create-invitation-payload.object.js.map +1 -0
- package/dist/objects/create-user-api-key-result.object.d.ts +10 -0
- package/dist/objects/create-user-api-key-result.object.js +33 -0
- package/dist/objects/create-user-api-key-result.object.js.map +1 -0
- package/dist/objects/create-user-payload.object.d.ts +5 -0
- package/dist/objects/create-user-payload.object.js +24 -0
- package/dist/objects/create-user-payload.object.js.map +1 -0
- package/dist/objects/create-workspace-api-key-result.object.d.ts +10 -0
- package/dist/objects/create-workspace-api-key-result.object.js +33 -0
- package/dist/objects/create-workspace-api-key-result.object.js.map +1 -0
- package/dist/objects/create-workspace-payload.object.d.ts +5 -0
- package/dist/objects/create-workspace-payload.object.js +24 -0
- package/dist/objects/create-workspace-payload.object.js.map +1 -0
- package/dist/objects/delete-user-payload.object.d.ts +5 -0
- package/dist/objects/delete-user-payload.object.js +24 -0
- package/dist/objects/delete-user-payload.object.js.map +1 -0
- package/dist/objects/delete-workspace-payload.object.d.ts +5 -0
- package/dist/objects/delete-workspace-payload.object.js +24 -0
- package/dist/objects/delete-workspace-payload.object.js.map +1 -0
- package/dist/objects/leave-workspace-payload.object.d.ts +5 -0
- package/dist/objects/leave-workspace-payload.object.js +24 -0
- package/dist/objects/leave-workspace-payload.object.js.map +1 -0
- package/dist/objects/reject-invitation-payload.object.d.ts +5 -0
- package/dist/objects/reject-invitation-payload.object.js +24 -0
- package/dist/objects/reject-invitation-payload.object.js.map +1 -0
- package/dist/objects/remove-member-payload.object.d.ts +5 -0
- package/dist/objects/remove-member-payload.object.js +24 -0
- package/dist/objects/remove-member-payload.object.js.map +1 -0
- package/dist/objects/set-member-permissions-payload.object.d.ts +5 -0
- package/dist/objects/set-member-permissions-payload.object.js +24 -0
- package/dist/objects/set-member-permissions-payload.object.js.map +1 -0
- package/dist/objects/set-member-roles-payload.object.d.ts +5 -0
- package/dist/objects/set-member-roles-payload.object.js +24 -0
- package/dist/objects/set-member-roles-payload.object.js.map +1 -0
- package/dist/objects/set-user-permissions-payload.object.d.ts +5 -0
- package/dist/objects/set-user-permissions-payload.object.js +24 -0
- package/dist/objects/set-user-permissions-payload.object.js.map +1 -0
- package/dist/objects/set-user-roles-payload.object.d.ts +5 -0
- package/dist/objects/set-user-roles-payload.object.js +24 -0
- package/dist/objects/set-user-roles-payload.object.js.map +1 -0
- package/dist/objects/sign-up-payload.object.d.ts +7 -0
- package/dist/objects/sign-up-payload.object.js +30 -0
- package/dist/objects/sign-up-payload.object.js.map +1 -0
- package/dist/objects/unban-user-payload.object.d.ts +5 -0
- package/dist/objects/unban-user-payload.object.js +24 -0
- package/dist/objects/unban-user-payload.object.js.map +1 -0
- package/dist/objects/update-member-payload.object.d.ts +5 -0
- package/dist/objects/update-member-payload.object.js +24 -0
- package/dist/objects/update-member-payload.object.js.map +1 -0
- package/dist/objects/update-user-payload.object.d.ts +5 -0
- package/dist/objects/update-user-payload.object.js +24 -0
- package/dist/objects/update-user-payload.object.js.map +1 -0
- package/dist/objects/update-workspace-payload.object.d.ts +5 -0
- package/dist/objects/update-workspace-payload.object.js +24 -0
- package/dist/objects/update-workspace-payload.object.js.map +1 -0
- package/dist/objects/user-api-key-permission-option.object.d.ts +8 -0
- package/dist/objects/user-api-key-permission-option.object.js +31 -0
- package/dist/objects/user-api-key-permission-option.object.js.map +1 -0
- package/dist/objects/user-permission-option.object.d.ts +8 -0
- package/dist/objects/user-permission-option.object.js +31 -0
- package/dist/objects/user-permission-option.object.js.map +1 -0
- package/dist/objects/user-role-option.object.d.ts +8 -0
- package/dist/objects/user-role-option.object.js +31 -0
- package/dist/objects/user-role-option.object.js.map +1 -0
- package/dist/objects/workspace-api-key-permission-option.object.d.ts +8 -0
- package/dist/objects/workspace-api-key-permission-option.object.js +31 -0
- package/dist/objects/workspace-api-key-permission-option.object.js.map +1 -0
- package/dist/objects/workspace-permission-option.object.d.ts +8 -0
- package/dist/objects/workspace-permission-option.object.js +31 -0
- package/dist/objects/workspace-permission-option.object.js.map +1 -0
- package/dist/objects/workspace-role-option.object.d.ts +8 -0
- package/dist/objects/workspace-role-option.object.js +31 -0
- package/dist/objects/workspace-role-option.object.js.map +1 -0
- package/dist/permission.constants.d.ts +23 -0
- package/dist/permission.constants.js +23 -0
- package/dist/permission.constants.js.map +1 -1
- package/dist/policies/create-scope-policy.d.ts +4 -0
- package/dist/policies/create-scope-policy.js +38 -0
- package/dist/policies/create-scope-policy.js.map +1 -0
- package/dist/policies/index.d.ts +2 -0
- package/dist/policies/index.js +3 -0
- package/dist/policies/index.js.map +1 -0
- package/dist/policies/user-scope.policy.d.ts +11 -0
- package/dist/policies/user-scope.policy.js +13 -0
- package/dist/policies/user-scope.policy.js.map +1 -0
- package/dist/policies/workspace-scope.policy.d.ts +11 -0
- package/dist/policies/workspace-scope.policy.js +13 -0
- package/dist/policies/workspace-scope.policy.js.map +1 -0
- package/dist/resolvers/auth.resolver.d.ts +67 -0
- package/dist/resolvers/auth.resolver.js +279 -0
- package/dist/resolvers/auth.resolver.js.map +1 -0
- package/dist/resolvers/invitation.resolver.d.ts +32 -0
- package/dist/resolvers/invitation.resolver.js +134 -0
- package/dist/resolvers/invitation.resolver.js.map +1 -0
- package/dist/resolvers/member.resolver.d.ts +73 -0
- package/dist/resolvers/member.resolver.js +191 -0
- package/dist/resolvers/member.resolver.js.map +1 -0
- package/dist/resolvers/session.resolver.d.ts +33 -0
- package/dist/resolvers/session.resolver.js +156 -0
- package/dist/resolvers/session.resolver.js.map +1 -0
- package/dist/resolvers/user-api-key.resolver.d.ts +24 -0
- package/dist/resolvers/user-api-key.resolver.js +84 -0
- package/dist/resolvers/user-api-key.resolver.js.map +1 -0
- package/dist/resolvers/user.resolver.d.ts +75 -0
- package/dist/resolvers/user.resolver.js +289 -0
- package/dist/resolvers/user.resolver.js.map +1 -0
- package/dist/resolvers/workspace-api-key.resolver.d.ts +24 -0
- package/dist/resolvers/workspace-api-key.resolver.js +84 -0
- package/dist/resolvers/workspace-api-key.resolver.js.map +1 -0
- package/dist/resolvers/workspace.resolver.d.ts +80 -0
- package/dist/resolvers/workspace.resolver.js +211 -0
- package/dist/resolvers/workspace.resolver.js.map +1 -0
- package/dist/services/access-control.service.d.ts +52 -0
- package/dist/services/access-control.service.js +201 -0
- package/dist/services/access-control.service.js.map +1 -0
- package/dist/services/account.service.d.ts +14 -0
- package/dist/services/account.service.js +43 -0
- package/dist/services/account.service.js.map +1 -0
- package/dist/services/auth.service.d.ts +101 -0
- package/dist/services/auth.service.js +333 -0
- package/dist/services/auth.service.js.map +1 -0
- package/dist/services/invitation.service.d.ts +58 -0
- package/dist/services/invitation.service.js +386 -0
- package/dist/services/invitation.service.js.map +1 -0
- package/dist/services/member.service.d.ts +75 -0
- package/dist/services/member.service.js +390 -0
- package/dist/services/member.service.js.map +1 -0
- package/dist/services/session.service.d.ts +58 -0
- package/dist/services/session.service.js +313 -0
- package/dist/services/session.service.js.map +1 -0
- package/dist/services/user-api-key.service.d.ts +48 -0
- package/dist/services/user-api-key.service.js +260 -0
- package/dist/services/user-api-key.service.js.map +1 -0
- package/dist/services/user-deletion.service.d.ts +15 -0
- package/dist/services/user-deletion.service.js +50 -0
- package/dist/services/user-deletion.service.js.map +1 -0
- package/dist/services/user.service.d.ts +81 -0
- package/dist/services/user.service.js +479 -0
- package/dist/services/user.service.js.map +1 -0
- package/dist/services/workspace-api-key.service.d.ts +49 -0
- package/dist/services/workspace-api-key.service.js +272 -0
- package/dist/services/workspace-api-key.service.js.map +1 -0
- package/dist/services/workspace.service.d.ts +40 -0
- package/dist/services/workspace.service.js +202 -0
- package/dist/services/workspace.service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/api-key-validation.type.d.ts +4 -0
- package/dist/types/api-key-validation.type.js +2 -0
- package/dist/types/api-key-validation.type.js.map +1 -0
- package/dist/types/api-key.type.d.ts +4 -0
- package/dist/types/api-key.type.js +2 -0
- package/dist/types/api-key.type.js.map +1 -0
- package/dist/types/auth-account-selector.type.d.ts +12 -0
- package/dist/types/auth-account-selector.type.js +2 -0
- package/dist/types/auth-account-selector.type.js.map +1 -0
- package/dist/types/auth-invitation-email-inviter.type.d.ts +7 -0
- package/dist/types/auth-invitation-email-inviter.type.js +2 -0
- package/dist/types/auth-invitation-email-inviter.type.js.map +1 -0
- package/dist/types/auth-maybe-promise.type.d.ts +2 -0
- package/dist/types/auth-maybe-promise.type.js +2 -0
- package/dist/types/auth-maybe-promise.type.js.map +1 -0
- package/dist/types/auth-module-provider.type.d.ts +4 -0
- package/dist/types/auth-module-provider.type.js +2 -0
- package/dist/types/auth-module-provider.type.js.map +1 -0
- package/dist/types/auth-module-roles.type.d.ts +3 -1
- package/dist/types/auth-module-social-provider-id.type.d.ts +2 -0
- package/dist/types/auth-module-social-provider-id.type.js +2 -0
- package/dist/types/auth-module-social-provider-id.type.js.map +1 -0
- package/dist/types/auth-oauth-token-endpoint-auth.type.d.ts +7 -0
- package/dist/types/auth-oauth-token-endpoint-auth.type.js +2 -0
- package/dist/types/auth-oauth-token-endpoint-auth.type.js.map +1 -0
- package/dist/types/auth-send-invitation-email.type.d.ts +7 -0
- package/dist/types/auth-send-invitation-email.type.js +2 -0
- package/dist/types/auth-send-invitation-email.type.js.map +1 -0
- package/dist/types/auth-send-reset-password.type.d.ts +7 -0
- package/dist/types/auth-send-reset-password.type.js +2 -0
- package/dist/types/auth-send-reset-password.type.js.map +1 -0
- package/dist/types/auth-send-verification-email.type.d.ts +7 -0
- package/dist/types/auth-send-verification-email.type.js +2 -0
- package/dist/types/auth-send-verification-email.type.js.map +1 -0
- package/dist/types/build-user-ability-callback.type.d.ts +10 -4
- package/dist/types/build-workspace-ability-callback.type.d.ts +10 -4
- package/dist/types/can-subject-factory.type.d.ts +1 -0
- package/dist/types/can-subject.type.d.ts +1 -0
- package/dist/types/lowercase-identifier.type.d.ts +6 -0
- package/dist/types/lowercase-identifier.type.js +2 -0
- package/dist/types/lowercase-identifier.type.js.map +1 -0
- package/dist/types/permission-name.type.d.ts +3 -0
- package/dist/types/permission-name.type.js +2 -0
- package/dist/types/permission-name.type.js.map +1 -0
- package/dist/types/role-name.type.d.ts +3 -0
- package/dist/types/role-name.type.js +2 -0
- package/dist/types/role-name.type.js.map +1 -0
- package/dist/types/route-argument-metadata.type.d.ts +1 -0
- package/dist/user.constants.d.ts +8 -2
- package/dist/user.constants.js +24 -14
- package/dist/user.constants.js.map +1 -1
- package/dist/utils/api-key-credential.util.d.ts +4 -0
- package/dist/utils/api-key-credential.util.js +16 -0
- package/dist/utils/api-key-credential.util.js.map +1 -0
- package/dist/utils/api-key-permissions.util.d.ts +6 -0
- package/dist/utils/api-key-permissions.util.js +16 -0
- package/dist/utils/api-key-permissions.util.js.map +1 -0
- package/dist/utils/append-metadata.util.d.ts +1 -0
- package/dist/utils/append-metadata.util.js +1 -0
- package/dist/utils/append-metadata.util.js.map +1 -1
- package/dist/utils/apply-auth-response-cookies.util.d.ts +1 -0
- package/dist/utils/apply-auth-response-cookies.util.js +1 -0
- package/dist/utils/apply-auth-response-cookies.util.js.map +1 -1
- package/dist/utils/auth-role.util.d.ts +8 -2
- package/dist/utils/auth-role.util.js +22 -6
- package/dist/utils/auth-role.util.js.map +1 -1
- package/dist/utils/build-request-ability.util.d.ts +7 -0
- package/dist/utils/build-request-ability.util.js +25 -0
- package/dist/utils/build-request-ability.util.js.map +1 -0
- package/dist/utils/can.util.d.ts +1 -0
- package/dist/utils/can.util.js +1 -0
- package/dist/utils/can.util.js.map +1 -1
- package/dist/utils/create-email-verification-config.d.ts +1 -0
- package/dist/utils/create-email-verification-config.js +1 -0
- package/dist/utils/create-email-verification-config.js.map +1 -1
- package/dist/utils/create-generic-oauth-config.d.ts +1 -0
- package/dist/utils/create-generic-oauth-config.js +1 -0
- package/dist/utils/create-generic-oauth-config.js.map +1 -1
- package/dist/utils/create-permission-enum.util.d.ts +2 -0
- package/dist/utils/create-permission-enum.util.js +16 -0
- package/dist/utils/create-permission-enum.util.js.map +1 -0
- package/dist/utils/create-user-config.d.ts +2 -1
- package/dist/utils/create-user-config.js +1 -0
- package/dist/utils/create-user-config.js.map +1 -1
- package/dist/utils/estimate-entropy.d.ts +7 -0
- package/dist/utils/estimate-entropy.js +7 -0
- package/dist/utils/estimate-entropy.js.map +1 -1
- package/dist/utils/extend-ability.util.d.ts +4 -0
- package/dist/utils/extend-ability.util.js +62 -0
- package/dist/utils/extend-ability.util.js.map +1 -0
- package/dist/utils/extract-api-key.util.d.ts +1 -0
- package/dist/utils/extract-api-key.util.js +1 -0
- package/dist/utils/extract-api-key.util.js.map +1 -1
- package/dist/utils/get-current-api-key.util.d.ts +3 -0
- package/dist/utils/get-current-api-key.util.js +9 -0
- package/dist/utils/get-current-api-key.util.js.map +1 -0
- package/dist/utils/get-user-ability.util.d.ts +2 -1
- package/dist/utils/get-user-ability.util.js +5 -2
- package/dist/utils/get-user-ability.util.js.map +1 -1
- package/dist/utils/get-workspace-ability.util.d.ts +2 -1
- package/dist/utils/get-workspace-ability.util.js +5 -2
- package/dist/utils/get-workspace-ability.util.js.map +1 -1
- package/dist/utils/resolve-auth-catalog.util.d.ts +7 -0
- package/dist/utils/resolve-auth-catalog.util.js +34 -0
- package/dist/utils/resolve-auth-catalog.util.js.map +1 -0
- package/dist/utils/resolve-effective-permissions.util.d.ts +9 -0
- package/dist/utils/resolve-effective-permissions.util.js +18 -0
- package/dist/utils/resolve-effective-permissions.util.js.map +1 -0
- package/dist/utils/resolve-request-permissions.util.d.ts +6 -0
- package/dist/utils/resolve-request-permissions.util.js +44 -0
- package/dist/utils/resolve-request-permissions.util.js.map +1 -0
- package/dist/utils/run-auth-query.d.ts +6 -0
- package/dist/utils/run-auth-query.js +51 -0
- package/dist/utils/run-auth-query.js.map +1 -0
- package/dist/utils/serialize-ability-rules.util.d.ts +1 -0
- package/dist/utils/serialize-ability-rules.util.js +2 -1
- package/dist/utils/serialize-ability-rules.util.js.map +1 -1
- package/dist/utils/split-auth-providers.d.ts +2 -1
- package/dist/utils/split-auth-providers.js +1 -0
- package/dist/utils/split-auth-providers.js.map +1 -1
- package/dist/utils/user-can.util.d.ts +1 -0
- package/dist/utils/user-can.util.js +3 -12
- package/dist/utils/user-can.util.js.map +1 -1
- package/dist/utils/workspace-can.util.d.ts +1 -0
- package/dist/utils/workspace-can.util.js +4 -12
- package/dist/utils/workspace-can.util.js.map +1 -1
- package/dist/workspace.constants.d.ts +10 -3
- package/dist/workspace.constants.js +24 -13
- package/dist/workspace.constants.js.map +1 -1
- package/package.json +41 -19
- package/dist/access-control.service.d.ts +0 -18
- package/dist/access-control.service.js +0 -153
- package/dist/access-control.service.js.map +0 -1
- package/dist/api-key.service.d.ts +0 -75
- package/dist/api-key.service.js +0 -336
- package/dist/api-key.service.js.map +0 -1
- package/dist/auth.service.d.ts +0 -27
- package/dist/auth.service.js +0 -199
- package/dist/auth.service.js.map +0 -1
- package/dist/decorators/current-workspace-member.decorator.d.ts +0 -1
- package/dist/decorators/current-workspace-member.decorator.js +0 -5
- package/dist/decorators/current-workspace-member.decorator.js.map +0 -1
- package/dist/entities/api-key.entity.d.ts +0 -17
- package/dist/entities/api-key.entity.js +0 -92
- package/dist/entities/api-key.entity.js.map +0 -1
- package/dist/entities/resolve-auth-relation-target.d.ts +0 -3
- package/dist/entities/resolve-auth-relation-target.js +0 -30
- package/dist/entities/resolve-auth-relation-target.js.map +0 -1
- package/dist/entities/workspace-invitation.entity.d.ts +0 -14
- package/dist/entities/workspace-invitation.entity.js +0 -74
- package/dist/entities/workspace-invitation.entity.js.map +0 -1
- package/dist/entities/workspace-member.entity.d.ts +0 -16
- package/dist/entities/workspace-member.entity.js +0 -86
- package/dist/entities/workspace-member.entity.js.map +0 -1
- package/dist/interfaces/auth-role.interface.d.ts +0 -4
- package/dist/interfaces/auth-role.interface.js +0 -2
- package/dist/interfaces/auth-role.interface.js.map +0 -1
- package/dist/interfaces/auth-service.interface.d.ts +0 -160
- package/dist/interfaces/auth-service.interface.js +0 -2
- package/dist/interfaces/auth-service.interface.js.map +0 -1
- package/dist/interfaces/session-service.interface.d.ts +0 -5
- package/dist/interfaces/session-service.interface.js +0 -2
- package/dist/interfaces/session-service.interface.js.map +0 -1
- package/dist/interfaces/user-service.interface.d.ts +0 -44
- package/dist/interfaces/user-service.interface.js +0 -2
- package/dist/interfaces/user-service.interface.js.map +0 -1
- package/dist/interfaces/workspace-service.interface.d.ts +0 -37
- package/dist/interfaces/workspace-service.interface.js +0 -2
- package/dist/interfaces/workspace-service.interface.js.map +0 -1
- package/dist/session.service.d.ts +0 -18
- package/dist/session.service.js +0 -171
- package/dist/session.service.js.map +0 -1
- package/dist/user-deletion.service.d.ts +0 -19
- package/dist/user-deletion.service.js +0 -103
- package/dist/user-deletion.service.js.map +0 -1
- package/dist/user.service.d.ts +0 -54
- package/dist/user.service.js +0 -386
- package/dist/user.service.js.map +0 -1
- package/dist/workspace.service.d.ts +0 -59
- package/dist/workspace.service.js +0 -611
- package/dist/workspace.service.js.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EntityManager } from "@mikro-orm/core";
|
|
2
|
+
import { User } from "../entities/user.entity.js";
|
|
3
|
+
/** Coordinates transactional deletion of users and auth-owned dependants. */
|
|
4
|
+
export declare class UserDeletionService {
|
|
5
|
+
private readonly em;
|
|
6
|
+
/** Creates the internal user-deletion coordinator. */
|
|
7
|
+
constructor(em: EntityManager);
|
|
8
|
+
/**
|
|
9
|
+
* Deletes one user and all auth-owned dependent records atomically.
|
|
10
|
+
* Workspaces survive user deletion, even when no owner remains.
|
|
11
|
+
* When the injected manager has a session, root deletion retains RLS and the
|
|
12
|
+
* built-in foreign keys cascade deletion to auth dependants.
|
|
13
|
+
*/
|
|
14
|
+
deleteUser(userId: string, beforeDelete?: () => Promise<void>): Promise<User | null>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { EntityManager, LockMode } from "@mikro-orm/core";
|
|
11
|
+
import { Injectable, NotFoundException } from "@nestjs/common";
|
|
12
|
+
import { User } from "../entities/user.entity.js";
|
|
13
|
+
/** Coordinates transactional deletion of users and auth-owned dependants. */
|
|
14
|
+
let UserDeletionService = class UserDeletionService {
|
|
15
|
+
em;
|
|
16
|
+
/** Creates the internal user-deletion coordinator. */
|
|
17
|
+
constructor(em) {
|
|
18
|
+
this.em = em;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Deletes one user and all auth-owned dependent records atomically.
|
|
22
|
+
* Workspaces survive user deletion, even when no owner remains.
|
|
23
|
+
* When the injected manager has a session, root deletion retains RLS and the
|
|
24
|
+
* built-in foreign keys cascade deletion to auth dependants.
|
|
25
|
+
*/
|
|
26
|
+
async deleteUser(userId, beforeDelete) {
|
|
27
|
+
const scoped = !!this.em.getContext(false).getSessionContext();
|
|
28
|
+
return await this.em.transactional(async (em) => {
|
|
29
|
+
const user = await em.findOne(User, { id: userId }, scoped
|
|
30
|
+
? { refresh: true }
|
|
31
|
+
: { filters: false, lockMode: LockMode.PESSIMISTIC_WRITE });
|
|
32
|
+
if (!user)
|
|
33
|
+
return null;
|
|
34
|
+
await beforeDelete?.();
|
|
35
|
+
// Delete only the root; foreign keys clean up dependants even under RLS.
|
|
36
|
+
const count = await em.nativeDelete(User, {
|
|
37
|
+
id: userId,
|
|
38
|
+
});
|
|
39
|
+
if (count !== 1)
|
|
40
|
+
throw new NotFoundException("User not found");
|
|
41
|
+
return user;
|
|
42
|
+
}, scoped ? { clear: true } : {});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
UserDeletionService = __decorate([
|
|
46
|
+
Injectable(),
|
|
47
|
+
__metadata("design:paramtypes", [EntityManager])
|
|
48
|
+
], UserDeletionService);
|
|
49
|
+
export { UserDeletionService };
|
|
50
|
+
//# sourceMappingURL=user-deletion.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-deletion.service.js","sourceRoot":"","sources":["../../src/services/user-deletion.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAoB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,6EAA6E;AAEtE,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAED;IAD7B,sDAAsD;IACtD,YAA6B,EAAiB;QAAjB,OAAE,GAAF,EAAE,CAAe;IAAG,CAAC;IAElD;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CACd,MAAc,EACd,YAAkC;QAElC,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAC/D,OAAO,MAAM,IAAI,CAAC,EAAE,CAAC,aAAa,CAChC,KAAK,EAAE,EAAE,EAAE,EAAE;YACX,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,OAAO,CAC3B,IAAI,EACJ,EAAE,EAAE,EAAE,MAAM,EAAuB,EACnC,MAAM;gBACJ,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;gBACnB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,iBAAiB,EAAE,CAC7D,CAAC;YACF,IAAI,CAAC,IAAI;gBAAE,OAAO,IAAI,CAAC;YAEvB,MAAM,YAAY,EAAE,EAAE,CAAC;YACvB,yEAAyE;YACzE,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE;gBACxC,EAAE,EAAE,MAAM;aACU,CAAC,CAAC;YACxB,IAAI,KAAK,KAAK,CAAC;gBAAE,MAAM,IAAI,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;YAC/D,OAAO,IAAI,CAAC;QACd,CAAC,EACD,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAC9B,CAAC;IACJ,CAAC;CACF,CAAA;AArCY,mBAAmB;IAD/B,UAAU,EAAE;qCAGsB,aAAa;GAFnC,mBAAmB,CAqC/B"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { EntityManager } from "@mikro-orm/core";
|
|
2
|
+
import { type ConnectionArgsInterface, type ConnectionInterface } from "@nest-boot/graphql-connection";
|
|
3
|
+
import { HashService } from "@nest-boot/hash";
|
|
4
|
+
import type { AuthModuleOptions } from "../auth-module-options.interface.js";
|
|
5
|
+
import { Session } from "../entities/session.entity.js";
|
|
6
|
+
import { User } from "../entities/user.entity.js";
|
|
7
|
+
import type { AuthenticatedSession } from "../interfaces/authenticated-session.interface.js";
|
|
8
|
+
import type { BanUserOptions } from "../interfaces/ban-user-options.interface.js";
|
|
9
|
+
import type { CreateUserOptions } from "../interfaces/create-user-options.interface.js";
|
|
10
|
+
import type { ImpersonationOptions } from "../interfaces/impersonation-options.interface.js";
|
|
11
|
+
import type { UpdateUserOptions } from "../interfaces/update-user-options.interface.js";
|
|
12
|
+
import type { UserHasPermissionsOptions } from "../interfaces/user-has-permissions-options.interface.js";
|
|
13
|
+
import type { UserPermissionOption } from "../objects/user-permission-option.object.js";
|
|
14
|
+
import type { UserRoleOption } from "../objects/user-role-option.object.js";
|
|
15
|
+
import { AccessControlService } from "./access-control.service.js";
|
|
16
|
+
/** User management implemented with the built-in MikroORM entities. */
|
|
17
|
+
export declare class UserService {
|
|
18
|
+
/** MikroORM entity manager used for authentication persistence. */
|
|
19
|
+
private readonly em;
|
|
20
|
+
private readonly options;
|
|
21
|
+
private readonly hashService;
|
|
22
|
+
private readonly accessControlService;
|
|
23
|
+
private readonly userDeletionService;
|
|
24
|
+
/** Creates a new UserService instance. */
|
|
25
|
+
constructor(
|
|
26
|
+
/** MikroORM entity manager used for authentication persistence. */
|
|
27
|
+
em: EntityManager, options: AuthModuleOptions, hashService: HashService, accessControlService: AccessControlService, userDeletionService: {
|
|
28
|
+
deleteUser(userId: string, beforeDelete?: () => Promise<void>): Promise<User | null>;
|
|
29
|
+
});
|
|
30
|
+
/** Creates a user and its credential account atomically. */
|
|
31
|
+
createUser(input: CreateUserOptions): Promise<User>;
|
|
32
|
+
/** Gets a user by identifier within the request's RLS scope. */
|
|
33
|
+
getUser(userId: string): Promise<User | null>;
|
|
34
|
+
/** Gets a user by normalized email within the request's RLS scope. */
|
|
35
|
+
getUserByEmail(email: string): Promise<User | null>;
|
|
36
|
+
/** Updates mutable user fields. */
|
|
37
|
+
updateUser(user: User | string, input: UpdateUserOptions): Promise<User>;
|
|
38
|
+
/** Replaces a user's application permissions. */
|
|
39
|
+
setUserPermissions(user: User | string, permissions: string[]): Promise<User>;
|
|
40
|
+
/** Replaces the roles assigned to a user. */
|
|
41
|
+
setUserRoles(user: User | string, roleNames: string | readonly string[]): Promise<User>;
|
|
42
|
+
private isCurrentUser;
|
|
43
|
+
private affectsCurrentAuthentication;
|
|
44
|
+
private assertIdentityRevocationCanCommit;
|
|
45
|
+
private assertAuthorizationCanCommit;
|
|
46
|
+
private resolveUserForAction;
|
|
47
|
+
/** Lists all configured roles with the current principal's grant availability. */
|
|
48
|
+
listRoles(): UserRoleOption[];
|
|
49
|
+
/** Lists all configured permissions with the current principal's grant availability. */
|
|
50
|
+
listPermissions(): UserPermissionOption[];
|
|
51
|
+
/** Resolves permissions inherited from roles plus direct user permissions. */
|
|
52
|
+
getEffectiveUserPermissions(user: User): string[];
|
|
53
|
+
/** Paginates users without bypassing application RLS. */
|
|
54
|
+
getUserConnection(args: ConnectionArgsInterface<User>): Promise<ConnectionInterface<User>>;
|
|
55
|
+
/** Bans a user and immediately revokes all of their sessions. */
|
|
56
|
+
banUser(user: User | string, input?: BanUserOptions): Promise<User>;
|
|
57
|
+
/** Removes a user's ban. */
|
|
58
|
+
unbanUser(user: User | string): Promise<User>;
|
|
59
|
+
/** Creates a session that impersonates another user. */
|
|
60
|
+
impersonateUser(administrator: User, user: User | string, input?: ImpersonationOptions): Promise<AuthenticatedSession>;
|
|
61
|
+
/** Ends impersonation and creates a replacement administrator session. */
|
|
62
|
+
stopImpersonating(currentSession: Session, input?: ImpersonationOptions): Promise<AuthenticatedSession | null>;
|
|
63
|
+
/** Permanently deletes a user and all dependent authentication records. */
|
|
64
|
+
deleteUser(user: User | string): Promise<User>;
|
|
65
|
+
/** Sets or replaces a user's credential password. */
|
|
66
|
+
setUserPassword(user: User | string, newPassword: string): Promise<void>;
|
|
67
|
+
/** Checks flattened `subject:action` values against a user's permissions. */
|
|
68
|
+
hasPermissions(user: User, input: UserHasPermissionsOptions): boolean;
|
|
69
|
+
/** Returns whether any assigned role is classified as administrative. */
|
|
70
|
+
isAdmin(user: User): boolean;
|
|
71
|
+
private normalizeRoles;
|
|
72
|
+
private normalizePermissions;
|
|
73
|
+
private createUserUpdateData;
|
|
74
|
+
private get roles();
|
|
75
|
+
private get defaultRole();
|
|
76
|
+
private get permissions();
|
|
77
|
+
private createSession;
|
|
78
|
+
private hashPassword;
|
|
79
|
+
private assertPasswordLength;
|
|
80
|
+
private isActivelyBanned;
|
|
81
|
+
}
|
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { randomBytes } from "node:crypto";
|
|
14
|
+
import { EntityManager, Reference, } from "@mikro-orm/core";
|
|
15
|
+
import { ConnectionManager, } from "@nest-boot/graphql-connection";
|
|
16
|
+
import { HashService } from "@nest-boot/hash";
|
|
17
|
+
import { RequestContext } from "@nest-boot/request-context";
|
|
18
|
+
import { BadRequestException, ForbiddenException, Inject, Injectable, NotFoundException, } from "@nestjs/common";
|
|
19
|
+
import { MODULE_OPTIONS_TOKEN } from "../auth.module-definition.js";
|
|
20
|
+
import { UserConnection } from "../connections/user.connection-definition.js";
|
|
21
|
+
import { Account } from "../entities/account.entity.js";
|
|
22
|
+
import { Session } from "../entities/session.entity.js";
|
|
23
|
+
import { User } from "../entities/user.entity.js";
|
|
24
|
+
import { UserApiKey } from "../entities/user-api-key.entity.js";
|
|
25
|
+
import { RequestIdentity } from "../infrastructure/request-identity.js";
|
|
26
|
+
import { RevokedAuthenticationException } from "../infrastructure/revoked-authentication.exception.js";
|
|
27
|
+
import { DEFAULT_USER_ADMIN_ROLES, DEFAULT_USER_ROLE, } from "../user.constants.js";
|
|
28
|
+
import { listAuthPermissions, normalizeAuthPermissions, normalizeAuthRoles, resolveAuthPermissions, } from "../utils/auth-role.util.js";
|
|
29
|
+
import { getCurrentApiKey } from "../utils/get-current-api-key.util.js";
|
|
30
|
+
import { resolveAuthCatalog } from "../utils/resolve-auth-catalog.util.js";
|
|
31
|
+
import { resolveUserPermissions } from "../utils/resolve-effective-permissions.util.js";
|
|
32
|
+
import { AccessControlService } from "./access-control.service.js";
|
|
33
|
+
import { UserDeletionService } from "./user-deletion.service.js";
|
|
34
|
+
const CREDENTIAL_ISSUER = "local:credential";
|
|
35
|
+
const CREDENTIAL_PROVIDER_ID = "credential";
|
|
36
|
+
const MUTABLE_USER_FIELDS = new Set([
|
|
37
|
+
"email",
|
|
38
|
+
"emailVerified",
|
|
39
|
+
"image",
|
|
40
|
+
"name",
|
|
41
|
+
]);
|
|
42
|
+
/** User management implemented with the built-in MikroORM entities. */
|
|
43
|
+
let UserService = class UserService {
|
|
44
|
+
em;
|
|
45
|
+
options;
|
|
46
|
+
hashService;
|
|
47
|
+
accessControlService;
|
|
48
|
+
userDeletionService;
|
|
49
|
+
/** Creates a new UserService instance. */
|
|
50
|
+
constructor(
|
|
51
|
+
/** MikroORM entity manager used for authentication persistence. */
|
|
52
|
+
em, options, hashService, accessControlService, userDeletionService) {
|
|
53
|
+
this.em = em;
|
|
54
|
+
this.options = options;
|
|
55
|
+
this.hashService = hashService;
|
|
56
|
+
this.accessControlService = accessControlService;
|
|
57
|
+
this.userDeletionService = userDeletionService;
|
|
58
|
+
}
|
|
59
|
+
/** Creates a user and its credential account atomically. */
|
|
60
|
+
async createUser(input) {
|
|
61
|
+
this.accessControlService.assertUserCan("create", User);
|
|
62
|
+
if (input.roles !== undefined || input.permissions !== undefined) {
|
|
63
|
+
this.accessControlService.assertUserCan("set-role", User);
|
|
64
|
+
}
|
|
65
|
+
this.assertPasswordLength(input.password);
|
|
66
|
+
const permissions = this.normalizePermissions(input.permissions ?? []);
|
|
67
|
+
const roles = this.normalizeRoles(input.roles ?? [this.defaultRole]);
|
|
68
|
+
this.accessControlService.assertCanGrantUserPermissions(resolveAuthPermissions(roles, permissions, this.roles));
|
|
69
|
+
const email = input.email.trim().toLowerCase();
|
|
70
|
+
const password = await this.hashPassword(input.password);
|
|
71
|
+
return await this.em.transactional(async (em) => {
|
|
72
|
+
const user = em.create(User, {
|
|
73
|
+
email,
|
|
74
|
+
emailVerified: false,
|
|
75
|
+
name: input.name,
|
|
76
|
+
permissions,
|
|
77
|
+
roles,
|
|
78
|
+
});
|
|
79
|
+
this.accessControlService.assertUserCan("create", user);
|
|
80
|
+
if (input.roles !== undefined || input.permissions !== undefined) {
|
|
81
|
+
this.accessControlService.assertUserCan("set-role", user);
|
|
82
|
+
}
|
|
83
|
+
em.persist(user);
|
|
84
|
+
await em.flush();
|
|
85
|
+
const userId = String(user.id);
|
|
86
|
+
const account = em.create(Account, {
|
|
87
|
+
accountId: userId,
|
|
88
|
+
issuer: CREDENTIAL_ISSUER,
|
|
89
|
+
password,
|
|
90
|
+
providerId: CREDENTIAL_PROVIDER_ID,
|
|
91
|
+
user,
|
|
92
|
+
});
|
|
93
|
+
em.persist(account);
|
|
94
|
+
await em.flush();
|
|
95
|
+
return user;
|
|
96
|
+
}, { clear: true });
|
|
97
|
+
}
|
|
98
|
+
/** Gets a user by identifier within the request's RLS scope. */
|
|
99
|
+
async getUser(userId) {
|
|
100
|
+
this.accessControlService.assertUserCan("get", User);
|
|
101
|
+
const user = await this.em.findOne(User, {
|
|
102
|
+
id: userId,
|
|
103
|
+
});
|
|
104
|
+
if (user)
|
|
105
|
+
this.accessControlService.assertUserCan("get", user);
|
|
106
|
+
return user;
|
|
107
|
+
}
|
|
108
|
+
/** Gets a user by normalized email within the request's RLS scope. */
|
|
109
|
+
async getUserByEmail(email) {
|
|
110
|
+
this.accessControlService.assertUserCan("get", User);
|
|
111
|
+
const user = await this.em.findOne(User, {
|
|
112
|
+
email: email.trim().toLowerCase(),
|
|
113
|
+
});
|
|
114
|
+
if (user)
|
|
115
|
+
this.accessControlService.assertUserCan("get", user);
|
|
116
|
+
return user;
|
|
117
|
+
}
|
|
118
|
+
/** Updates mutable user fields. */
|
|
119
|
+
async updateUser(user, input) {
|
|
120
|
+
user = await this.resolveUserForAction(user, "update");
|
|
121
|
+
this.accessControlService.assertUserCan("update", user);
|
|
122
|
+
const data = this.createUserUpdateData(input);
|
|
123
|
+
if (input.email !== undefined || input.emailVerified !== undefined) {
|
|
124
|
+
this.accessControlService.assertUserCan("set-email", user);
|
|
125
|
+
}
|
|
126
|
+
this.assertAuthorizationCanCommit(user);
|
|
127
|
+
const previous = {
|
|
128
|
+
email: user.email,
|
|
129
|
+
emailVerified: user.emailVerified,
|
|
130
|
+
image: user.image,
|
|
131
|
+
name: user.name,
|
|
132
|
+
};
|
|
133
|
+
try {
|
|
134
|
+
this.em.assign(user, data);
|
|
135
|
+
await this.em.persist(user).flush();
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
Object.assign(user, previous);
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
RequestIdentity.updateUser(this.em, this.options, user);
|
|
142
|
+
return user;
|
|
143
|
+
}
|
|
144
|
+
/** Replaces a user's application permissions. */
|
|
145
|
+
async setUserPermissions(user, permissions) {
|
|
146
|
+
user = await this.resolveUserForAction(user, "set-role");
|
|
147
|
+
this.accessControlService.assertUserCan("set-role", user);
|
|
148
|
+
const normalized = this.normalizePermissions(permissions);
|
|
149
|
+
this.accessControlService.assertCanGrantUserPermissions(normalized);
|
|
150
|
+
this.assertAuthorizationCanCommit(user);
|
|
151
|
+
const previous = user.permissions;
|
|
152
|
+
user.permissions = normalized;
|
|
153
|
+
try {
|
|
154
|
+
await this.em.persist(user).flush();
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
user.permissions = previous;
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
RequestIdentity.updateUser(this.em, this.options, user);
|
|
161
|
+
return user;
|
|
162
|
+
}
|
|
163
|
+
/** Replaces the roles assigned to a user. */
|
|
164
|
+
async setUserRoles(user, roleNames) {
|
|
165
|
+
user = await this.resolveUserForAction(user, "set-role");
|
|
166
|
+
this.accessControlService.assertUserCan("set-role", user);
|
|
167
|
+
const roles = this.normalizeRoles(roleNames);
|
|
168
|
+
this.accessControlService.assertCanGrantUserPermissions(resolveAuthPermissions(roles, [], this.roles));
|
|
169
|
+
this.assertAuthorizationCanCommit(user);
|
|
170
|
+
const previous = user.roles;
|
|
171
|
+
user.roles = roles;
|
|
172
|
+
try {
|
|
173
|
+
await this.em.persist(user).flush();
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
user.roles = previous;
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
RequestIdentity.updateUser(this.em, this.options, user);
|
|
180
|
+
return user;
|
|
181
|
+
}
|
|
182
|
+
isCurrentUser(user) {
|
|
183
|
+
const current = RequestContext.isActive() ? RequestContext.get(User) : null;
|
|
184
|
+
return !!current && current.id === user.id;
|
|
185
|
+
}
|
|
186
|
+
affectsCurrentAuthentication(user) {
|
|
187
|
+
const session = RequestContext.isActive()
|
|
188
|
+
? RequestContext.get(Session)
|
|
189
|
+
: null;
|
|
190
|
+
return this.isCurrentUser(user) || session?.impersonatedBy?.id === user.id;
|
|
191
|
+
}
|
|
192
|
+
assertIdentityRevocationCanCommit(user) {
|
|
193
|
+
if (this.affectsCurrentAuthentication(user) && this.em.isInTransaction()) {
|
|
194
|
+
throw new BadRequestException("Revoke your own identity outside an active transaction");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
assertAuthorizationCanCommit(user) {
|
|
198
|
+
if (this.isCurrentUser(user) && this.em.isInTransaction()) {
|
|
199
|
+
throw new BadRequestException("Change your own authorization outside an active transaction");
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async resolveUserForAction(user, action) {
|
|
203
|
+
if (typeof user !== "string")
|
|
204
|
+
return user;
|
|
205
|
+
this.accessControlService.assertUserCan(action, User);
|
|
206
|
+
const entity = await this.em.findOne(User, { id: user }, { refresh: true });
|
|
207
|
+
if (!entity)
|
|
208
|
+
throw new NotFoundException("User not found");
|
|
209
|
+
return entity;
|
|
210
|
+
}
|
|
211
|
+
/** Lists all configured roles with the current principal's grant availability. */
|
|
212
|
+
listRoles() {
|
|
213
|
+
this.accessControlService.assertUserCan("set-role", User);
|
|
214
|
+
return Object.entries(this.roles).map(([role, permissions]) => ({
|
|
215
|
+
role,
|
|
216
|
+
grantable: this.accessControlService.canGrantUserPermissions(permissions),
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
/** Lists all configured permissions with the current principal's grant availability. */
|
|
220
|
+
listPermissions() {
|
|
221
|
+
this.accessControlService.assertUserCan("set-role", User);
|
|
222
|
+
return listAuthPermissions(this.permissions).map((permission) => ({
|
|
223
|
+
permission,
|
|
224
|
+
grantable: this.accessControlService.canGrantUserPermissions([
|
|
225
|
+
permission,
|
|
226
|
+
]),
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
/** Resolves permissions inherited from roles plus direct user permissions. */
|
|
230
|
+
getEffectiveUserPermissions(user) {
|
|
231
|
+
return resolveUserPermissions(this.options, user);
|
|
232
|
+
}
|
|
233
|
+
/** Paginates users without bypassing application RLS. */
|
|
234
|
+
async getUserConnection(args) {
|
|
235
|
+
this.accessControlService.assertUserCan("list", User);
|
|
236
|
+
const connection = await new ConnectionManager(this.em).find(UserConnection, args);
|
|
237
|
+
for (const { node } of connection.edges) {
|
|
238
|
+
this.accessControlService.assertUserCan("list", node);
|
|
239
|
+
}
|
|
240
|
+
return connection;
|
|
241
|
+
}
|
|
242
|
+
/** Bans a user and immediately revokes all of their sessions. */
|
|
243
|
+
async banUser(user, input = {}) {
|
|
244
|
+
user = await this.resolveUserForAction(user, "ban");
|
|
245
|
+
this.accessControlService.assertUserCan("ban", user);
|
|
246
|
+
this.assertIdentityRevocationCanCommit(user);
|
|
247
|
+
const banExpiresAt = input.banExpiresIn === undefined
|
|
248
|
+
? null
|
|
249
|
+
: new Date(Date.now() + input.banExpiresIn * 1000);
|
|
250
|
+
if (input.banExpiresIn !== undefined &&
|
|
251
|
+
(!Number.isSafeInteger(input.banExpiresIn) ||
|
|
252
|
+
input.banExpiresIn <= 0 ||
|
|
253
|
+
Number.isNaN(banExpiresAt?.getTime()))) {
|
|
254
|
+
throw new BadRequestException("Ban duration must be a positive integer number of seconds");
|
|
255
|
+
}
|
|
256
|
+
const previous = {
|
|
257
|
+
banned: user.banned,
|
|
258
|
+
banReason: user.banReason,
|
|
259
|
+
banExpiresAt: user.banExpiresAt,
|
|
260
|
+
};
|
|
261
|
+
user.banned = true;
|
|
262
|
+
user.banReason = input.banReason ?? null;
|
|
263
|
+
user.banExpiresAt = banExpiresAt;
|
|
264
|
+
const apiKey = getCurrentApiKey();
|
|
265
|
+
try {
|
|
266
|
+
await this.em.transactional(async (em) => {
|
|
267
|
+
// Persist the final use in the same transaction before revoking identity.
|
|
268
|
+
if (apiKey instanceof UserApiKey && apiKey.user.id === user.id) {
|
|
269
|
+
const now = new Date();
|
|
270
|
+
await em.nativeUpdate(UserApiKey, { id: apiKey.id }, {
|
|
271
|
+
lastUsedAt: now,
|
|
272
|
+
updatedAt: now,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
await em.nativeDelete(Session, {
|
|
276
|
+
$or: [{ user: String(user.id) }, { impersonatedBy: user }],
|
|
277
|
+
});
|
|
278
|
+
await em.persist(user).flush();
|
|
279
|
+
}, { clear: true });
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
Object.assign(user, previous);
|
|
283
|
+
throw error;
|
|
284
|
+
}
|
|
285
|
+
if (this.affectsCurrentAuthentication(user))
|
|
286
|
+
RequestIdentity.clear(this.em);
|
|
287
|
+
return user;
|
|
288
|
+
}
|
|
289
|
+
/** Removes a user's ban. */
|
|
290
|
+
async unbanUser(user) {
|
|
291
|
+
user = await this.resolveUserForAction(user, "ban");
|
|
292
|
+
this.accessControlService.assertUserCan("ban", user);
|
|
293
|
+
this.assertAuthorizationCanCommit(user);
|
|
294
|
+
const previous = {
|
|
295
|
+
banned: user.banned,
|
|
296
|
+
banReason: user.banReason,
|
|
297
|
+
banExpiresAt: user.banExpiresAt,
|
|
298
|
+
};
|
|
299
|
+
user.banned = false;
|
|
300
|
+
user.banReason = null;
|
|
301
|
+
user.banExpiresAt = null;
|
|
302
|
+
try {
|
|
303
|
+
await this.em.persist(user).flush();
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
Object.assign(user, previous);
|
|
307
|
+
throw error;
|
|
308
|
+
}
|
|
309
|
+
RequestIdentity.updateUser(this.em, this.options, user);
|
|
310
|
+
return user;
|
|
311
|
+
}
|
|
312
|
+
/** Creates a session that impersonates another user. */
|
|
313
|
+
async impersonateUser(administrator, user, input = {}) {
|
|
314
|
+
this.accessControlService.assertCurrentUser(administrator);
|
|
315
|
+
user = await this.resolveUserForAction(user, "impersonate");
|
|
316
|
+
this.accessControlService.assertUserCan("impersonate", user);
|
|
317
|
+
if (this.isAdmin(user)) {
|
|
318
|
+
this.accessControlService.assertUserCan("impersonate-admins", user);
|
|
319
|
+
}
|
|
320
|
+
if (this.isActivelyBanned(user)) {
|
|
321
|
+
throw new ForbiddenException("Banned users cannot be impersonated");
|
|
322
|
+
}
|
|
323
|
+
const session = await this.em.transactional(async (em) => {
|
|
324
|
+
const session = this.createSession(em, user, {
|
|
325
|
+
...input,
|
|
326
|
+
impersonatedBy: administrator,
|
|
327
|
+
});
|
|
328
|
+
await em.persist(session).flush();
|
|
329
|
+
return session;
|
|
330
|
+
}, { clear: true });
|
|
331
|
+
return { session, user };
|
|
332
|
+
}
|
|
333
|
+
/** Ends impersonation and creates a replacement administrator session. */
|
|
334
|
+
async stopImpersonating(currentSession, input = {}) {
|
|
335
|
+
this.accessControlService.assertCurrentSession(currentSession);
|
|
336
|
+
const impersonatedByReference = currentSession.impersonatedBy;
|
|
337
|
+
if (!impersonatedByReference)
|
|
338
|
+
return null;
|
|
339
|
+
this.assertIdentityRevocationCanCommit(Reference.unwrapReference(impersonatedByReference));
|
|
340
|
+
const result = await this.em.transactional(async (em) => {
|
|
341
|
+
const impersonatedBy = Reference.unwrapReference(impersonatedByReference);
|
|
342
|
+
const administrator = await em.findOne(User, { id: String(impersonatedBy.id) }, { filters: false });
|
|
343
|
+
if (!administrator)
|
|
344
|
+
return null;
|
|
345
|
+
if (this.isActivelyBanned(administrator)) {
|
|
346
|
+
await em.remove(currentSession).flush();
|
|
347
|
+
return "banned-administrator";
|
|
348
|
+
}
|
|
349
|
+
const session = this.createSession(em, administrator, input);
|
|
350
|
+
em.remove(currentSession).persist(session);
|
|
351
|
+
await em.flush();
|
|
352
|
+
return { session, user: administrator };
|
|
353
|
+
}, { clear: true });
|
|
354
|
+
// A missing administrator has already cascaded deletion to this session.
|
|
355
|
+
if (result === null)
|
|
356
|
+
RequestIdentity.clear(this.em);
|
|
357
|
+
// Publish the committed revocation even when restoration returns an error.
|
|
358
|
+
if (result === "banned-administrator") {
|
|
359
|
+
RequestIdentity.clear(this.em);
|
|
360
|
+
throw new RevokedAuthenticationException("Banned administrators cannot restore their session");
|
|
361
|
+
}
|
|
362
|
+
return result;
|
|
363
|
+
}
|
|
364
|
+
/** Permanently deletes a user and all dependent authentication records. */
|
|
365
|
+
async deleteUser(user) {
|
|
366
|
+
user = await this.resolveUserForAction(user, "delete");
|
|
367
|
+
this.accessControlService.assertUserCan("delete", user);
|
|
368
|
+
this.assertIdentityRevocationCanCommit(user);
|
|
369
|
+
const deleted = await this.userDeletionService.deleteUser(String(user.id));
|
|
370
|
+
if (deleted === null)
|
|
371
|
+
throw new NotFoundException("User not found");
|
|
372
|
+
if (this.affectsCurrentAuthentication(user))
|
|
373
|
+
RequestIdentity.clear(this.em);
|
|
374
|
+
return user;
|
|
375
|
+
}
|
|
376
|
+
/** Sets or replaces a user's credential password. */
|
|
377
|
+
async setUserPassword(user, newPassword) {
|
|
378
|
+
user = await this.resolveUserForAction(user, "set-password");
|
|
379
|
+
this.accessControlService.assertUserCan("set-password", user);
|
|
380
|
+
this.assertPasswordLength(newPassword);
|
|
381
|
+
const password = await this.hashPassword(newPassword);
|
|
382
|
+
await this.em.transactional(async (em) => {
|
|
383
|
+
const account = await em.findOne(Account, {
|
|
384
|
+
issuer: CREDENTIAL_ISSUER,
|
|
385
|
+
accountId: String(user.id),
|
|
386
|
+
providerId: CREDENTIAL_PROVIDER_ID,
|
|
387
|
+
user: String(user.id),
|
|
388
|
+
}, { filters: false });
|
|
389
|
+
if (account) {
|
|
390
|
+
account.password = password;
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
em.persist(em.create(Account, {
|
|
394
|
+
accountId: String(user.id),
|
|
395
|
+
issuer: CREDENTIAL_ISSUER,
|
|
396
|
+
password,
|
|
397
|
+
providerId: CREDENTIAL_PROVIDER_ID,
|
|
398
|
+
user,
|
|
399
|
+
}));
|
|
400
|
+
}
|
|
401
|
+
await em.flush();
|
|
402
|
+
}, { clear: true });
|
|
403
|
+
}
|
|
404
|
+
/** Checks flattened `subject:action` values against a user's permissions. */
|
|
405
|
+
hasPermissions(user, input) {
|
|
406
|
+
const permissions = new Set(this.getEffectiveUserPermissions(user));
|
|
407
|
+
return Object.entries(input.permissions).every(([subject, actions]) => actions.every((action) => permissions.has(`${subject}:${action}`)));
|
|
408
|
+
}
|
|
409
|
+
/** Returns whether any assigned role is classified as administrative. */
|
|
410
|
+
isAdmin(user) {
|
|
411
|
+
const adminRoles = new Set(this.options.user?.adminRoles ?? DEFAULT_USER_ADMIN_ROLES);
|
|
412
|
+
return (user.roles ?? [this.defaultRole]).some((role) => adminRoles.has(role));
|
|
413
|
+
}
|
|
414
|
+
normalizeRoles(role) {
|
|
415
|
+
return normalizeAuthRoles(role, this.roles);
|
|
416
|
+
}
|
|
417
|
+
normalizePermissions(permissions) {
|
|
418
|
+
return normalizeAuthPermissions(permissions, this.permissions, "User");
|
|
419
|
+
}
|
|
420
|
+
createUserUpdateData(input) {
|
|
421
|
+
const unsupportedFields = Object.keys(input).filter((field) => !MUTABLE_USER_FIELDS.has(field));
|
|
422
|
+
if (unsupportedFields.length > 0) {
|
|
423
|
+
throw new BadRequestException(`User update contains unsupported fields: ${unsupportedFields.join(", ")}`);
|
|
424
|
+
}
|
|
425
|
+
return {
|
|
426
|
+
...Object.fromEntries(Object.entries(input).filter(([, value]) => value !== undefined)),
|
|
427
|
+
...(input.email === undefined
|
|
428
|
+
? {}
|
|
429
|
+
: { email: input.email.trim().toLowerCase() }),
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
get roles() {
|
|
433
|
+
return resolveAuthCatalog(this.options, "user").roles;
|
|
434
|
+
}
|
|
435
|
+
get defaultRole() {
|
|
436
|
+
return this.options.user?.defaultRole ?? DEFAULT_USER_ROLE;
|
|
437
|
+
}
|
|
438
|
+
get permissions() {
|
|
439
|
+
return resolveAuthCatalog(this.options, "user").permissions;
|
|
440
|
+
}
|
|
441
|
+
createSession(em, user, input) {
|
|
442
|
+
const expiresIn = this.options.session?.expiresIn ?? 60 * 60 * 24 * 7;
|
|
443
|
+
return em.create(Session, {
|
|
444
|
+
expiresAt: new Date(Date.now() + expiresIn * 1000),
|
|
445
|
+
impersonatedBy: input.impersonatedBy ?? null,
|
|
446
|
+
ipAddress: input.ipAddress ?? null,
|
|
447
|
+
token: randomBytes(32).toString("base64url"),
|
|
448
|
+
userAgent: input.userAgent ?? null,
|
|
449
|
+
user,
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
async hashPassword(password) {
|
|
453
|
+
return await (this.options.emailAndPassword?.password?.hash ??
|
|
454
|
+
((value) => this.hashService.hash(value)))(password);
|
|
455
|
+
}
|
|
456
|
+
assertPasswordLength(password) {
|
|
457
|
+
const minimum = this.options.emailAndPassword?.minPasswordLength ?? 8;
|
|
458
|
+
const maximum = this.options.emailAndPassword?.maxPasswordLength ?? 128;
|
|
459
|
+
if (password.length < minimum) {
|
|
460
|
+
throw new BadRequestException(`Password must contain at least ${String(minimum)} characters`);
|
|
461
|
+
}
|
|
462
|
+
if (password.length > maximum) {
|
|
463
|
+
throw new BadRequestException(`Password must contain at most ${String(maximum)} characters`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
isActivelyBanned(user) {
|
|
467
|
+
return (user.banned &&
|
|
468
|
+
(!user.banExpiresAt || user.banExpiresAt.getTime() > Date.now()));
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
UserService = __decorate([
|
|
472
|
+
Injectable(),
|
|
473
|
+
__param(1, Inject(MODULE_OPTIONS_TOKEN)),
|
|
474
|
+
__param(4, Inject(UserDeletionService)),
|
|
475
|
+
__metadata("design:paramtypes", [EntityManager, Object, HashService,
|
|
476
|
+
AccessControlService, Object])
|
|
477
|
+
], UserService);
|
|
478
|
+
export { UserService };
|
|
479
|
+
//# sourceMappingURL=user.service.js.map
|