mongodb-dynamic-api 4.11.0 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +1 -1
  3. package/src/interfaces/dynamic-api-route-config.interface.d.ts +56 -8
  4. package/src/modules/auth/auth.helper.d.ts +13 -3
  5. package/src/modules/auth/auth.helper.js +20 -6
  6. package/src/modules/auth/auth.helper.js.map +1 -1
  7. package/src/modules/auth/auth.module.js +24 -3
  8. package/src/modules/auth/auth.module.js.map +1 -1
  9. package/src/modules/auth/dtos/send-otp-code.dto.d.ts +3 -0
  10. package/src/modules/auth/dtos/send-otp-code.dto.js +24 -0
  11. package/src/modules/auth/dtos/send-otp-code.dto.js.map +1 -0
  12. package/src/modules/auth/dtos/verify-otp-code.dto.d.ts +4 -0
  13. package/src/modules/auth/dtos/verify-otp-code.dto.js +31 -0
  14. package/src/modules/auth/dtos/verify-otp-code.dto.js.map +1 -0
  15. package/src/modules/auth/guards/index.d.ts +1 -0
  16. package/src/modules/auth/guards/index.js +1 -0
  17. package/src/modules/auth/guards/index.js.map +1 -1
  18. package/src/modules/auth/guards/passwordless/passwordless.guard.d.ts +6 -0
  19. package/src/modules/auth/guards/passwordless/passwordless.guard.js +30 -0
  20. package/src/modules/auth/guards/passwordless/passwordless.guard.js.map +1 -0
  21. package/src/modules/auth/interfaces/auth-controller.interface.d.ts +7 -0
  22. package/src/modules/auth/interfaces/auth-options.interface.d.ts +8 -1
  23. package/src/modules/auth/interfaces/auth-service.interface.d.ts +2 -0
  24. package/src/modules/auth/mixins/auth-controller.mixin.d.ts +11 -2
  25. package/src/modules/auth/mixins/auth-controller.mixin.js +39 -1
  26. package/src/modules/auth/mixins/auth-controller.mixin.js.map +1 -1
  27. package/src/modules/auth/models/otp-code.model.d.ts +15 -0
  28. package/src/modules/auth/models/otp-code.model.js +38 -0
  29. package/src/modules/auth/models/otp-code.model.js.map +1 -0
  30. package/src/modules/auth/services/base-auth.service.d.ts +7 -2
  31. package/src/modules/auth/services/base-auth.service.js +38 -1
  32. package/src/modules/auth/services/base-auth.service.js.map +1 -1
  33. package/src/routes/create-many/create-many.module.d.ts +2 -2
  34. package/src/routes/create-many/create-many.module.js.map +1 -1
  35. package/src/routes/create-one/create-one.module.d.ts +2 -2
  36. package/src/routes/create-one/create-one.module.js.map +1 -1
  37. package/src/routes/delete-many/delete-many.module.d.ts +2 -2
  38. package/src/routes/delete-many/delete-many.module.js.map +1 -1
  39. package/src/routes/delete-one/delete-one.module.d.ts +2 -2
  40. package/src/routes/delete-one/delete-one.module.js.map +1 -1
  41. package/src/routes/duplicate-many/duplicate-many.module.d.ts +2 -2
  42. package/src/routes/duplicate-many/duplicate-many.module.js.map +1 -1
  43. package/src/routes/duplicate-one/duplicate-one.module.d.ts +2 -2
  44. package/src/routes/duplicate-one/duplicate-one.module.js.map +1 -1
  45. package/src/routes/replace-one/replace-one.module.d.ts +2 -2
  46. package/src/routes/replace-one/replace-one.module.js.map +1 -1
  47. package/src/routes/update-many/update-many.module.d.ts +2 -2
  48. package/src/routes/update-many/update-many.module.js.map +1 -1
  49. package/src/routes/update-one/update-one.module.d.ts +2 -2
  50. package/src/routes/update-one/update-one.module.js.map +1 -1
  51. package/src/version.json +1 -1
  52. package/test/for-root/auth-api-passwordless.e2e-spec.d.ts +1 -0
  53. package/test/for-root/auth-api-passwordless.e2e-spec.js +150 -0
  54. package/test/for-root/auth-api-passwordless.e2e-spec.js.map +1 -0
  55. package/test/shared/entities/index.d.ts +1 -0
  56. package/test/shared/entities/index.js +1 -0
  57. package/test/shared/entities/index.js.map +1 -1
  58. package/test/shared/entities/passwordless-user.factory.d.ts +12 -0
  59. package/test/shared/entities/passwordless-user.factory.js +31 -0
  60. package/test/shared/entities/passwordless-user.factory.js.map +1 -0
  61. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  Changelog
2
2
 
3
+ ## [4.13.0](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v4.12.0...v4.13.0) (2026-05-26)
4
+
5
+ ### route-config
6
+
7
+ * **route-config:** replace flat DynamicApiRouteConfig with discriminated union ([6046c61](https://github.com/MikeDev75015/mongodb-dynamic-api/commit/6046c6159eb43e68d9efec5bc5890fd9f4c1aadb))
8
+
9
+ ## [4.12.0](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v4.11.0...v4.12.0) (2026-05-26)
10
+
11
+ ### auth
12
+
13
+ * **auth:** add passwordless OTP flow ([858cd49](https://github.com/MikeDev75015/mongodb-dynamic-api/commit/858cd49e348127412e8eaf86f06d94d0784bef63))
14
+
3
15
  ## [4.11.0](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v4.10.0...v4.11.0) (2026-05-25)
4
16
 
5
17
  ### callbacks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb-dynamic-api",
3
- "version": "4.11.0",
3
+ "version": "4.13.0",
4
4
  "description": "Auto generated CRUD API for MongoDB using NestJS",
5
5
  "readmeFilename": "README.md",
6
6
  "main": "index.js",
@@ -4,13 +4,11 @@ import { AbilityPredicate, PredicateBehavior } from './dynamic-api-ability.inter
4
4
  import { BroadcastConfig } from './dynamic-api-broadcast-config.interface';
5
5
  import { CascadeConfig } from './dynamic-api-cascade-config.interface';
6
6
  import { DTOsBundle } from './dynamic-api-route-dtos-bundle.type';
7
- import { RouteType } from './dynamic-api-route-type.type';
8
- import { AnyBeforeDeleteCallback, AnyBeforeSaveCallback } from './dynamic-api-service-before-save-callback.interface';
7
+ import { BeforeDeleteCallback, BeforeDeleteManyCallback, BeforeSaveCallback, BeforeSaveCreateContext, BeforeSaveCreateManyContext, BeforeSaveDeleteCallback, BeforeSaveDeleteContext, BeforeSaveDeleteManyCallback, BeforeSaveDeleteManyContext, BeforeSaveDuplicateContext, BeforeSaveDuplicateManyContext, BeforeSaveListCallback, BeforeSaveReplaceContext, BeforeSaveUpdateContext, BeforeSaveUpdateManyContext } from './dynamic-api-service-before-save-callback.interface';
9
8
  import { AfterSaveCallback } from './dynamic-api-service-callback.interface';
10
9
  import { DynamicApiWebSocketOptions } from './dynamic-api-web-socket.interface';
11
10
  type FromUserMap<Entity> = Partial<Record<keyof Entity, string | ((user: unknown) => unknown)>>;
12
- interface DynamicApiRouteConfig<Entity extends BaseEntity> {
13
- type: RouteType;
11
+ interface BaseRouteConfig<Entity extends BaseEntity> {
14
12
  isPublic?: boolean;
15
13
  disableCache?: boolean;
16
14
  description?: string;
@@ -20,9 +18,6 @@ interface DynamicApiRouteConfig<Entity extends BaseEntity> {
20
18
  validationPipeOptions?: ValidationPipeOptions;
21
19
  abilityPredicate?: AbilityPredicate<Entity>;
22
20
  predicateBehavior?: PredicateBehavior;
23
- beforeSaveCallback?: AnyBeforeSaveCallback<Entity>;
24
- beforeDeleteCallback?: AnyBeforeDeleteCallback<Entity>;
25
- cascade?: CascadeConfig[];
26
21
  callback?: AfterSaveCallback<Entity>;
27
22
  webSocket?: DynamicApiWebSocketOptions;
28
23
  eventName?: string;
@@ -31,5 +26,58 @@ interface DynamicApiRouteConfig<Entity extends BaseEntity> {
31
26
  useInterceptors?: Type<NestInterceptor>[];
32
27
  fromUser?: FromUserMap<Entity>;
33
28
  }
29
+ interface CreateOneRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
30
+ type: 'CreateOne';
31
+ beforeSaveCallback?: BeforeSaveCallback<Entity, BeforeSaveCreateContext<Entity>>;
32
+ }
33
+ interface CreateManyRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
34
+ type: 'CreateMany';
35
+ beforeSaveCallback?: BeforeSaveListCallback<Entity, BeforeSaveCreateManyContext<Entity>>;
36
+ }
37
+ interface UpdateOneRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
38
+ type: 'UpdateOne';
39
+ beforeSaveCallback?: BeforeSaveCallback<Entity, BeforeSaveUpdateContext<Entity>>;
40
+ }
41
+ interface UpdateManyRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
42
+ type: 'UpdateMany';
43
+ beforeSaveCallback?: BeforeSaveListCallback<Entity, BeforeSaveUpdateManyContext<Entity>>;
44
+ }
45
+ interface ReplaceOneRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
46
+ type: 'ReplaceOne';
47
+ beforeSaveCallback?: BeforeSaveCallback<Entity, BeforeSaveReplaceContext<Entity>>;
48
+ }
49
+ interface DuplicateOneRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
50
+ type: 'DuplicateOne';
51
+ beforeSaveCallback?: BeforeSaveCallback<Entity, BeforeSaveDuplicateContext<Entity>>;
52
+ }
53
+ interface DuplicateManyRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
54
+ type: 'DuplicateMany';
55
+ beforeSaveCallback?: BeforeSaveListCallback<Entity, BeforeSaveDuplicateManyContext<Entity>>;
56
+ }
57
+ interface DeleteOneRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
58
+ type: 'DeleteOne';
59
+ beforeSaveCallback?: BeforeSaveDeleteCallback<Entity, BeforeSaveDeleteContext>;
60
+ beforeDeleteCallback?: BeforeDeleteCallback<Entity, BeforeSaveDeleteContext>;
61
+ cascade?: CascadeConfig[];
62
+ }
63
+ interface DeleteManyRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
64
+ type: 'DeleteMany';
65
+ beforeSaveCallback?: BeforeSaveDeleteManyCallback<Entity, BeforeSaveDeleteManyContext>;
66
+ beforeDeleteCallback?: BeforeDeleteManyCallback<Entity, BeforeSaveDeleteManyContext>;
67
+ cascade?: CascadeConfig[];
68
+ }
69
+ interface GetOneRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
70
+ type: 'GetOne';
71
+ }
72
+ interface GetManyRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
73
+ type: 'GetMany';
74
+ }
75
+ interface AggregateRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
76
+ type: 'Aggregate';
77
+ }
78
+ interface CustomOperationRouteConfig<Entity extends BaseEntity> extends BaseRouteConfig<Entity> {
79
+ type: 'Custom';
80
+ }
81
+ type DynamicApiRouteConfig<Entity extends BaseEntity> = CreateOneRouteConfig<Entity> | CreateManyRouteConfig<Entity> | UpdateOneRouteConfig<Entity> | UpdateManyRouteConfig<Entity> | ReplaceOneRouteConfig<Entity> | DuplicateOneRouteConfig<Entity> | DuplicateManyRouteConfig<Entity> | DeleteOneRouteConfig<Entity> | DeleteManyRouteConfig<Entity> | GetOneRouteConfig<Entity> | GetManyRouteConfig<Entity> | AggregateRouteConfig<Entity> | CustomOperationRouteConfig<Entity>;
34
82
  type DynamicAPIRouteConfig<Entity extends BaseEntity> = DynamicApiRouteConfig<Entity>;
35
- export { DynamicApiRouteConfig, DynamicAPIRouteConfig, FromUserMap };
83
+ export { BaseRouteConfig, CreateOneRouteConfig, CreateManyRouteConfig, UpdateOneRouteConfig, UpdateManyRouteConfig, ReplaceOneRouteConfig, DuplicateOneRouteConfig, DuplicateManyRouteConfig, DeleteOneRouteConfig, DeleteManyRouteConfig, GetOneRouteConfig, GetManyRouteConfig, AggregateRouteConfig, CustomOperationRouteConfig, DynamicApiRouteConfig, DynamicAPIRouteConfig, FromUserMap, };
@@ -1,12 +1,21 @@
1
1
  import { Type, ValidationPipeOptions } from '@nestjs/common';
2
2
  import { AuthAbilityPredicate, AfterSaveCallback, DynamicAPIServiceProvider, GatewayOptions } from '../../interfaces';
3
3
  import { BaseEntity } from '../../models';
4
- import { AuthControllerConstructor, AuthGatewayConstructor, DynamicApiGetAccountOptions, DynamicApiLoginOptions, DynamicApiRefreshTokenOptions, DynamicApiRegisterOptions, DynamicApiResetPasswordOptions, DynamicApiUpdateAccountOptions } from './interfaces';
4
+ import { AuthControllerConstructor, AuthGatewayConstructor, DynamicApiGetAccountOptions, DynamicApiLoginOptions, DynamicApiRefreshTokenOptions, DynamicApiRegisterOptions, DynamicApiResetPasswordOptions, DynamicApiUpdateAccountOptions, PasswordlessOptions } from './interfaces';
5
5
  declare const authServiceProviderName = "DynamicApiAuthService";
6
6
  declare const authGatewayProviderName = "DynamicApiAuthGateway";
7
7
  declare const localStrategyProviderName = "DynamicApiLocalStrategy";
8
8
  declare function createLocalStrategyProvider<Entity extends BaseEntity>(loginField: keyof Entity, passwordField: keyof Entity, abilityPredicate: AuthAbilityPredicate | undefined, customValidate?: (req: any) => Promise<Entity | null>, useStrategy?: Type<any>): DynamicAPIServiceProvider;
9
- declare function createAuthServiceProvider<Entity extends BaseEntity>(userEntity: Type<Entity>, { loginField, passwordField, additionalFields, callback: loginCallback }: DynamicApiLoginOptions<Entity>, getAccountCallback: AfterSaveCallback<Entity> | undefined, register: DynamicApiRegisterOptions<Entity> | undefined, resetPasswordOptions: DynamicApiResetPasswordOptions<Entity> | undefined, updateAccount: DynamicApiUpdateAccountOptions<Entity> | undefined, refreshToken?: DynamicApiRefreshTokenOptions<Entity>): DynamicAPIServiceProvider;
9
+ type AuthServiceProviderOptions<Entity extends BaseEntity> = {
10
+ loginOptions: DynamicApiLoginOptions<Entity>;
11
+ getAccountCallback?: AfterSaveCallback<Entity>;
12
+ register?: DynamicApiRegisterOptions<Entity>;
13
+ resetPasswordOptions?: DynamicApiResetPasswordOptions<Entity>;
14
+ updateAccount?: DynamicApiUpdateAccountOptions<Entity>;
15
+ refreshToken?: DynamicApiRefreshTokenOptions<Entity>;
16
+ passwordlessOptions?: PasswordlessOptions<Entity>;
17
+ };
18
+ declare function createAuthServiceProvider<Entity extends BaseEntity>(userEntity: Type<Entity>, { loginOptions: { loginField, passwordField, additionalFields, callback: loginCallback }, getAccountCallback, register, resetPasswordOptions, updateAccount, refreshToken, passwordlessOptions, }: AuthServiceProviderOptions<Entity>): DynamicAPIServiceProvider;
10
19
  type CreateAuthControllerOptions<Entity extends BaseEntity> = {
11
20
  getAccountOptions?: DynamicApiGetAccountOptions<Entity>;
12
21
  registerOptions?: DynamicApiRegisterOptions<Entity>;
@@ -14,6 +23,7 @@ type CreateAuthControllerOptions<Entity extends BaseEntity> = {
14
23
  resetPasswordOptions?: DynamicApiResetPasswordOptions<Entity>;
15
24
  updateAccountOptions?: DynamicApiUpdateAccountOptions<Entity>;
16
25
  refreshTokenOptions?: DynamicApiRefreshTokenOptions<Entity>;
26
+ passwordlessOptions?: PasswordlessOptions<Entity>;
17
27
  };
18
28
  type CreateAuthGatewayOptions<Entity extends BaseEntity> = GatewayOptions & {
19
29
  validationPipeOptions?: ValidationPipeOptions;
@@ -23,6 +33,6 @@ type CreateAuthGatewayOptions<Entity extends BaseEntity> = GatewayOptions & {
23
33
  updateAccountOptions?: DynamicApiUpdateAccountOptions<Entity>;
24
34
  refreshTokenOptions?: DynamicApiRefreshTokenOptions<Entity>;
25
35
  };
26
- declare function createAuthController<Entity extends BaseEntity>(userEntity: Type<Entity>, loginOptions: DynamicApiLoginOptions<Entity>, { getAccountOptions, registerOptions, validationPipeOptions, resetPasswordOptions, updateAccountOptions, refreshTokenOptions, }?: CreateAuthControllerOptions<Entity>): AuthControllerConstructor<Entity>;
36
+ declare function createAuthController<Entity extends BaseEntity>(userEntity: Type<Entity>, loginOptions: DynamicApiLoginOptions<Entity>, { getAccountOptions, registerOptions, validationPipeOptions, resetPasswordOptions, updateAccountOptions, refreshTokenOptions, passwordlessOptions, }?: CreateAuthControllerOptions<Entity>): AuthControllerConstructor<Entity>;
27
37
  declare function createAuthGateway<Entity extends BaseEntity>(userEntity: Type<Entity>, loginOptions: DynamicApiLoginOptions<Entity>, { getAccountOptions, registerOptions, resetPasswordOptions, updateAccountOptions, refreshTokenOptions, validationPipeOptions, ...gatewayOptions }: CreateAuthGatewayOptions<Entity>): AuthGatewayConstructor<Entity>;
28
38
  export { authServiceProviderName, authGatewayProviderName, createAuthController, createAuthServiceProvider, createAuthGateway, createLocalStrategyProvider, localStrategyProviderName, };
@@ -29,6 +29,7 @@ const decorators_1 = require("../../decorators");
29
29
  const dynamic_api_module_1 = require("../../dynamic-api.module");
30
30
  const filters_1 = require("../../filters");
31
31
  const services_1 = require("../../services");
32
+ const otp_code_model_1 = require("./models/otp-code.model");
32
33
  const mixins_1 = require("./mixins");
33
34
  const services_2 = require("./services");
34
35
  const authServiceProviderName = 'DynamicApiAuthService';
@@ -92,13 +93,14 @@ function createLocalStrategyProvider(loginField, passwordField, abilityPredicate
92
93
  useClass: LocalStrategy,
93
94
  };
94
95
  }
95
- function createAuthServiceProvider(userEntity, { loginField, passwordField, additionalFields = [], callback: loginCallback }, getAccountCallback, register, resetPasswordOptions, updateAccount, refreshToken) {
96
+ function createAuthServiceProvider(userEntity, { loginOptions: { loginField, passwordField, additionalFields = [], callback: loginCallback }, getAccountCallback, register, resetPasswordOptions, updateAccount, refreshToken, passwordlessOptions, }) {
96
97
  let AuthService = class AuthService extends services_2.BaseAuthService {
97
- constructor(model, jwtService, bcryptService) {
98
- super(model, jwtService, bcryptService);
98
+ constructor(model, jwtService, bcryptService, otpModel) {
99
+ super(model, jwtService, bcryptService, otpModel);
99
100
  this.model = model;
100
101
  this.jwtService = jwtService;
101
102
  this.bcryptService = bcryptService;
103
+ this.otpModel = otpModel;
102
104
  this.entity = userEntity;
103
105
  this.additionalRequestFields = additionalFields;
104
106
  this.loginField = loginField;
@@ -112,21 +114,33 @@ function createAuthServiceProvider(userEntity, { loginField, passwordField, addi
112
114
  this.loginCallback = loginCallback;
113
115
  this.getAccountCallback = getAccountCallback;
114
116
  this.resetPasswordOptions = resetPasswordOptions;
117
+ this.passwordlessOptions = passwordlessOptions;
115
118
  }
116
119
  };
117
120
  AuthService = __decorate([
118
121
  __param(0, (0, mongoose_1.InjectModel)(userEntity.name, dynamic_api_module_1.DynamicApiModule.state.get('connectionName'))),
122
+ __param(3, (0, common_1.Optional)()),
123
+ __param(3, (0, mongoose_1.InjectModel)(otp_code_model_1.OtpCode.name, dynamic_api_module_1.DynamicApiModule.state.get('connectionName'))),
119
124
  __metadata("design:paramtypes", [mongoose_2.Model,
120
125
  jwt_1.JwtService,
121
- services_1.BcryptService])
126
+ services_1.BcryptService,
127
+ mongoose_2.Model])
122
128
  ], AuthService);
123
129
  return {
124
130
  provide: authServiceProviderName,
125
131
  useClass: AuthService,
126
132
  };
127
133
  }
128
- function createAuthController(userEntity, loginOptions, { getAccountOptions, registerOptions, validationPipeOptions, resetPasswordOptions, updateAccountOptions, refreshTokenOptions, } = {}) {
129
- let AuthController = class AuthController extends (0, mixins_1.AuthControllerMixin)(userEntity, loginOptions, registerOptions, resetPasswordOptions, updateAccountOptions, getAccountOptions, refreshTokenOptions) {
134
+ function createAuthController(userEntity, loginOptions, { getAccountOptions, registerOptions, validationPipeOptions, resetPasswordOptions, updateAccountOptions, refreshTokenOptions, passwordlessOptions, } = {}) {
135
+ let AuthController = class AuthController extends (0, mixins_1.AuthControllerMixin)(userEntity, {
136
+ loginOptions,
137
+ registerOptions,
138
+ resetPasswordOptions,
139
+ updateAccountOptions,
140
+ getAccountOptions,
141
+ refreshTokenOptions,
142
+ passwordlessOptions,
143
+ }) {
130
144
  constructor(service, broadcastService, jwtService) {
131
145
  super(service, broadcastService, jwtService);
132
146
  this.service = service;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.helper.js","sourceRoot":"","sources":["../../../../libs/dynamic-api/src/modules/auth/auth.helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmPE,oDAAoB;AACpB,8DAAyB;AACzB,8CAAiB;AACjB,kEAA2B;AAtP7B,2CAA8J;AAC9J,qCAAyC;AACzC,+CAA+C;AAC/C,+CAAoD;AACpD,6CAA0C;AAC1C,mDAAsD;AACtD,uCAAiC;AACjC,mDAA0C;AAC1C,iDAAiD;AACjD,iEAA4D;AAC5D,2CAA4D;AAG5D,6CAA2E;AAE3E,qCAAiE;AACjE,yCAA6C;AAE7C,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AA+NtD,0DAAuB;AA9NzB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AC5B,UAAsB;YAEzC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YAHR,YAAO,GAAP,OAAO,CAAqB;YAC5B,eAAU,GAAV,UAAU,CAAY;QAG3C,CAAC;KACF,CAAA;IAhBK,WAAW;QAHhB,IAAA,6BAAgB,EAAC,cAAc,CAAC;QAChC,IAAA,mBAAU,EAAC,IAAI,qCAA2B,EAAE,CAAC;QAC7C,IAAA,0BAAa,EAAC,qBAAqB,CAAC;QAWhC,WAAA,IAAA,eAAM,EAAC,uBAAuB,CAAC,CAAA;iDAED,gBAAU;OAZvC,WAAW,CAgBhB;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
1
+ {"version":3,"file":"auth.helper.js","sourceRoot":"","sources":["../../../../libs/dynamic-api/src/modules/auth/auth.helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA4QE,oDAAoB;AACpB,8DAAyB;AACzB,8CAAiB;AACjB,kEAA2B;AA/Q7B,2CAA8J;AAC9J,qCAAyC;AACzC,+CAA+C;AAC/C,+CAAoD;AACpD,6CAA0C;AAC1C,mDAAsD;AACtD,uCAAiC;AACjC,mDAA0C;AAC1C,iDAAiD;AACjD,iEAA4D;AAC5D,2CAA4D;AAG5D,6CAA2E;AAC3E,4DAAkD;AAElD,qCAAiE;AACjE,yCAA6C;AAE7C,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AAuPtD,0DAAuB;AAtPzB,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AAuPtD,0DAAuB;AAtPzB,MAAM,yBAAyB,GAAG,yBAAyB,CAAC;AA2P1D,8DAAyB;AAzP3B,SAAS,2BAA2B,CAClC,UAAwB,EACxB,aAA2B,EAC3B,gBAAkD,EAClD,cAAqD,EACrD,WAAuB;IAEvB,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO;YACL,OAAO,EAAE,yBAAyB;YAClC,QAAQ,EAAE,WAAW;SACtB,CAAC;IACJ,CAAC;IAED,IACM,aAAa,GADnB,MACM,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,UAAsB;YAEzC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YAHR,YAAO,GAAP,OAAO,CAAqB;YAC5B,eAAU,GAAV,UAAU,CAAY;QAG3C,CAAC;KACF,CAAA;IAhBK,WAAW;QAHhB,IAAA,6BAAgB,EAAC,cAAc,CAAC;QAChC,IAAA,mBAAU,EAAC,IAAI,qCAA2B,EAAE,CAAC;QAC7C,IAAA,0BAAa,EAAC,qBAAqB,CAAC;QAWhC,WAAA,IAAA,eAAM,EAAC,uBAAuB,CAAC,CAAA;iDAED,gBAAU;OAZvC,WAAW,CAgBhB;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -18,6 +18,7 @@ const gateways_1 = require("../../gateways");
18
18
  const helpers_1 = require("../../helpers");
19
19
  const services_1 = require("../../services");
20
20
  const auth_helper_1 = require("./auth.helper");
21
+ const otp_code_model_1 = require("./models/otp-code.model");
21
22
  const strategies_1 = require("./strategies");
22
23
  let AuthModule = AuthModule_1 = class AuthModule {
23
24
  configure(consumer) {
@@ -26,12 +27,13 @@ let AuthModule = AuthModule_1 = class AuthModule {
26
27
  }
27
28
  }
28
29
  static forRoot(options) {
29
- const { userEntity, login: { loginField, passwordField, ...login }, getAccount, register, updateAccount, resetPassword, refreshToken, jwt: { secret, expiresIn }, validationPipeOptions, webSocket, extraImports, extraProviders, extraControllers, } = this.initializeAuthOptions(options);
30
+ const { userEntity, login: { loginField, passwordField, ...login }, getAccount, register, updateAccount, resetPassword, refreshToken, passwordless, jwt: { secret, expiresIn }, validationPipeOptions, webSocket, extraImports, extraProviders, extraControllers, } = this.initializeAuthOptions(options);
30
31
  AuthModule_1.useCookie = refreshToken?.useCookie ?? false;
31
32
  const { resetPasswordCallback, ...resetPasswordOptionsRest } = resetPassword;
32
33
  const resetPasswordOptions = resetPasswordCallback
33
34
  ? { resetPasswordCallback, ...resetPasswordOptionsRest }
34
35
  : undefined;
36
+ const connectionName = dynamic_api_module_1.DynamicApiModule.state.get('connectionName');
35
37
  const AuthController = (0, auth_helper_1.createAuthController)(userEntity, { loginField, passwordField, ...login }, {
36
38
  getAccountOptions: getAccount,
37
39
  registerOptions: register,
@@ -39,8 +41,17 @@ let AuthModule = AuthModule_1 = class AuthModule {
39
41
  resetPasswordOptions,
40
42
  updateAccountOptions: updateAccount,
41
43
  refreshTokenOptions: refreshToken,
44
+ passwordlessOptions: passwordless,
45
+ });
46
+ const AuthServiceProvider = (0, auth_helper_1.createAuthServiceProvider)(userEntity, {
47
+ loginOptions: { loginField, passwordField, ...login },
48
+ getAccountCallback: getAccount?.callback,
49
+ register,
50
+ resetPasswordOptions,
51
+ updateAccount,
52
+ refreshToken,
53
+ passwordlessOptions: passwordless,
42
54
  });
43
- const AuthServiceProvider = (0, auth_helper_1.createAuthServiceProvider)(userEntity, { loginField, passwordField, ...login }, getAccount?.callback, register, resetPasswordOptions, updateAccount, refreshToken);
44
55
  const LocalStrategyProvider = (0, auth_helper_1.createLocalStrategyProvider)(loginField, passwordField, login.abilityPredicate, login.customValidate, login.useStrategy);
45
56
  const schema = (0, helpers_1.buildSchemaFromEntity)(userEntity);
46
57
  services_1.DynamicApiGlobalStateService.addEntitySchema(userEntity, schema);
@@ -68,6 +79,9 @@ let AuthModule = AuthModule_1 = class AuthModule {
68
79
  }),
69
80
  },
70
81
  ];
82
+ const otpFeatureModule = passwordless
83
+ ? mongoose_1.MongooseModule.forFeature([{ name: otp_code_model_1.OtpCode.name, schema: otp_code_model_1.OtpCodeSchema }], connectionName)
84
+ : undefined;
71
85
  return {
72
86
  module: AuthModule_1,
73
87
  imports: [
@@ -78,6 +92,7 @@ let AuthModule = AuthModule_1 = class AuthModule {
78
92
  schema,
79
93
  },
80
94
  ], dynamic_api_module_1.DynamicApiModule.state.get('connectionName')),
95
+ ...(otpFeatureModule ? [otpFeatureModule] : []),
81
96
  passport_1.PassportModule,
82
97
  jwt_1.JwtModule.register({
83
98
  global: true,
@@ -98,7 +113,7 @@ let AuthModule = AuthModule_1 = class AuthModule {
98
113
  controllers: [AuthController, ...extraControllers],
99
114
  };
100
115
  }
101
- static initializeAuthOptions({ userEntity, jwt, login, register, updateAccount, getAccount, resetPassword, refreshToken, validationPipeOptions, webSocket, extraImports = [], extraProviders = [], extraControllers = [], }) {
116
+ static initializeAuthOptions({ userEntity, jwt, login, register, updateAccount, getAccount, resetPassword, refreshToken, passwordless, validationPipeOptions, webSocket, extraImports = [], extraProviders = [], extraControllers = [], }) {
102
117
  return {
103
118
  userEntity: userEntity,
104
119
  jwt: {
@@ -137,6 +152,12 @@ let AuthModule = AuthModule_1 = class AuthModule {
137
152
  refreshTokenField: refreshToken?.refreshTokenField,
138
153
  useCookie: refreshToken?.useCookie ?? false,
139
154
  },
155
+ passwordless: passwordless
156
+ ? {
157
+ ...passwordless,
158
+ otpExpirationMinutes: passwordless.otpExpirationMinutes ?? 10,
159
+ }
160
+ : undefined,
140
161
  validationPipeOptions: validationPipeOptions,
141
162
  webSocket,
142
163
  extraImports,
@@ -1 +1 @@
1
- {"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../../../libs/dynamic-api/src/modules/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,8CAA8C;AAC9C,2CAAwE;AACxE,qCAAwC;AAExC,+CAAkD;AAClD,+CAAkD;AAClD,iEAA4D;AAC5D,6CAAkE;AAClE,2CAAmF;AAGnF,6CAAyG;AACzG,+CAAyJ;AAEzJ,6CAA+D;AAGxD,IAAM,UAAU,kBAAhB,MAAM,UAAU;IAGrB,SAAS,CAAC,QAA4B;QACpC,IAAI,YAAU,CAAC,SAAS,EAAE,CAAC;YACzB,QAAQ,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,MAAM,CAAC,OAAO,CACZ,OAAsC;QAEtC,MAAM,EACJ,UAAU,EACV,KAAK,EAAE,EACL,UAAU,EACV,aAAa,EACb,GAAG,KAAK,EACT,EACD,UA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ACb,GAAG,aAAa;gBAChB,yBAAyB,EAAE,aAAa,EAAE,yBAAyB,IAAI,EAAE;aAC1E;YACD,aAAa,EAAE;gBACb,GAAG,aAAa;gBAChB,UAAU,EAAE,CAAC,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC,OAAuB,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;gBACrG,mBAAmB,EAAE,aAAa,EAAE,mBAAmB,IAAI,EAAE;aAC9D;YACD,YAAY,EAAE;gBACZ,GAAG,YAAY;gBACf,eAAe,EAAE,YAAY,EAAE,eAAe,IAAI,EAAE;gBACpD,iBAAiB,EAAE,YAAY,EAAE,iBAAiB;gBAClD,SAAS,EAAE,YAAY,EAAE,SAAS,IAAI,KAAK;aAC5C;YACD,qBAAqB,EAAE,qBAAqB;YAC5C,SAAS;YACT,YAAY;YACZ,cAAc;YACd,gBAAgB;SACjB,CAAC;IACJ,CAAC;;AApMU,gCAAU;AACN,oBAAS,GAAG,KAAK,AAAR,CAAS;qBADtB,UAAU;IADtB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,UAAU,CAqMtB"}
1
+ {"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../../../libs/dynamic-api/src/modules/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,8CAA8C;AAC9C,2CAAwE;AACxE,qCAAwC;AAExC,+CAAkD;AAClD,+CAAkD;AAClD,iEAA4D;AAC5D,6CAAkE;AAClE,2CAAmF;AAGnF,6CAAyG;AACzG,+CAAyJ;AACzJ,4DAAiE;AAEjE,6CAA+D;AAGxD,IAAM,UAAU,kBAAhB,MAAM,UAAU;IAGrB,SAAS,CAAC,QAA4B;QACpC,IAAI,YAAU,CAAC,SAAS,EAAE,CAAC;YACzB,QAAQ,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,MAAM,CAAC,OA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C,CAAC,SAAS;YACb,qBAAqB,EAAE,qBAAqB;YAC5C,SAAS;YACT,YAAY;YACZ,cAAc;YACd,gBAAgB;SACjB,CAAC;IACJ,CAAC;;AA3NU,gCAAU;AACN,oBAAS,GAAG,KAAK,AAAR,CAAS;qBADtB,UAAU;IADtB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,UAAU,CA4NtB"}
@@ -0,0 +1,3 @@
1
+ export declare class SendOtpCodeDto {
2
+ identifier: string;
3
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SendOtpCodeDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ class SendOtpCodeDto {
16
+ }
17
+ exports.SendOtpCodeDto = SendOtpCodeDto;
18
+ __decorate([
19
+ (0, class_validator_1.IsString)(),
20
+ (0, class_validator_1.IsNotEmpty)(),
21
+ (0, swagger_1.ApiProperty)({ description: 'User identifier (e.g. email address).' }),
22
+ __metadata("design:type", String)
23
+ ], SendOtpCodeDto.prototype, "identifier", void 0);
24
+ //# sourceMappingURL=send-otp-code.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-otp-code.dto.js","sourceRoot":"","sources":["../../../../../libs/dynamic-api/src/modules/auth/dtos/send-otp-code.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAAuD;AAEvD,MAAa,cAAc;CAK1B;AALD,wCAKC;AADC;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;;kDACnD"}
@@ -0,0 +1,4 @@
1
+ export declare class VerifyOtpCodeDto {
2
+ identifier: string;
3
+ code: string;
4
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.VerifyOtpCodeDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ class VerifyOtpCodeDto {
16
+ }
17
+ exports.VerifyOtpCodeDto = VerifyOtpCodeDto;
18
+ __decorate([
19
+ (0, class_validator_1.IsString)(),
20
+ (0, class_validator_1.IsNotEmpty)(),
21
+ (0, swagger_1.ApiProperty)({ description: 'User identifier (e.g. email address).' }),
22
+ __metadata("design:type", String)
23
+ ], VerifyOtpCodeDto.prototype, "identifier", void 0);
24
+ __decorate([
25
+ (0, class_validator_1.IsString)(),
26
+ (0, class_validator_1.IsNotEmpty)(),
27
+ (0, class_validator_1.Length)(6, 6),
28
+ (0, swagger_1.ApiProperty)({ description: '6-digit one-time code sent to the user.' }),
29
+ __metadata("design:type", String)
30
+ ], VerifyOtpCodeDto.prototype, "code", void 0);
31
+ //# sourceMappingURL=verify-otp-code.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-otp-code.dto.js","sourceRoot":"","sources":["../../../../../libs/dynamic-api/src/modules/auth/dtos/verify-otp-code.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAA+D;AAE/D,MAAa,gBAAgB;CAW5B;AAXD,4CAWC;AAPC;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;;oDACnD;AAMnB;IAJC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,CAAC,EAAE,CAAC,CAAC;IACZ,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;;8CAC3D"}
@@ -3,4 +3,5 @@ export * from './jwt-refresh/jwt-refresh.guard';
3
3
  export * from './jwt-socket-auth/jwt-socket-auth.guard';
4
4
  export * from './jwt-socket-refresh/jwt-socket-refresh.guard';
5
5
  export * from './local-auth/local-auth.guard';
6
+ export * from './passwordless/passwordless.guard';
6
7
  export * from './reset-password/reset-password.guard';
@@ -19,5 +19,6 @@ __exportStar(require("./jwt-refresh/jwt-refresh.guard"), exports);
19
19
  __exportStar(require("./jwt-socket-auth/jwt-socket-auth.guard"), exports);
20
20
  __exportStar(require("./jwt-socket-refresh/jwt-socket-refresh.guard"), exports);
21
21
  __exportStar(require("./local-auth/local-auth.guard"), exports);
22
+ __exportStar(require("./passwordless/passwordless.guard"), exports);
22
23
  __exportStar(require("./reset-password/reset-password.guard"), exports);
23
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/dynamic-api/src/modules/auth/guards/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,kEAAgD;AAChD,0EAAwD;AACxD,gFAA8D;AAC9D,gEAA8C;AAC9C,wEAAsD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/dynamic-api/src/modules/auth/guards/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,kEAAgD;AAChD,0EAAwD;AACxD,gFAA8D;AAC9D,gEAA8C;AAC9C,oEAAkD;AAClD,wEAAsD"}
@@ -0,0 +1,6 @@
1
+ import { CanActivate, ExecutionContext } from '@nestjs/common';
2
+ export declare class PasswordlessGuard implements CanActivate {
3
+ private readonly configured;
4
+ constructor(configured: boolean);
5
+ canActivate(_context: ExecutionContext): boolean;
6
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PasswordlessGuard = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ let PasswordlessGuard = class PasswordlessGuard {
15
+ constructor(configured) {
16
+ this.configured = configured;
17
+ }
18
+ canActivate(_context) {
19
+ if (!this.configured) {
20
+ throw new common_1.ServiceUnavailableException('This feature is not available');
21
+ }
22
+ return true;
23
+ }
24
+ };
25
+ exports.PasswordlessGuard = PasswordlessGuard;
26
+ exports.PasswordlessGuard = PasswordlessGuard = __decorate([
27
+ (0, common_1.Injectable)(),
28
+ __metadata("design:paramtypes", [Boolean])
29
+ ], PasswordlessGuard);
30
+ //# sourceMappingURL=passwordless.guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passwordless.guard.js","sourceRoot":"","sources":["../../../../../../libs/dynamic-api/src/modules/auth/guards/passwordless/passwordless.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAwG;AAGjG,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,YAA6B,UAAmB;QAAnB,eAAU,GAAV,UAAU,CAAS;IAAG,CAAC;IAEpD,WAAW,CAAC,QAA0B;QACpC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,oCAA2B,CAAC,+BAA+B,CAAC,CAAC;QACzE,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAVY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;;GACA,iBAAiB,CAU7B"}
@@ -28,6 +28,13 @@ interface AuthController<Entity extends BaseEntity> {
28
28
  logout(req: {
29
29
  user: Entity;
30
30
  }, res: Response): Promise<void>;
31
+ sendOtpCode(body: {
32
+ identifier: string;
33
+ }): Promise<void>;
34
+ verifyOtpCode(body: {
35
+ identifier: string;
36
+ code: string;
37
+ }, res: Response): Promise<LoginResponse>;
31
38
  }
32
39
  type AuthControllerConstructor<Entity extends BaseEntity> = new (service: AuthService<Entity>, broadcastService?: DynamicApiBroadcastService, jwtService?: JwtService) => AuthController<Entity>;
33
40
  export type { AuthController, AuthControllerConstructor };
@@ -66,6 +66,12 @@ type DynamicApiRefreshTokenOptions<Entity extends BaseEntity = any> = {
66
66
  refreshTokenField?: keyof Entity;
67
67
  useCookie?: boolean;
68
68
  };
69
+ type PasswordlessOptions<Entity extends BaseEntity = any> = {
70
+ otpExpirationMinutes?: number;
71
+ generateCode?: () => string;
72
+ sendCodeCallback: (identifier: string, code: string) => Promise<void>;
73
+ callback?: AfterSaveCallback<Entity>;
74
+ };
69
75
  type DynamicApiAuthOptions<Entity extends BaseEntity = any> = {
70
76
  userEntity: Type<Entity>;
71
77
  jwt?: DynamicApiJWTOptions;
@@ -75,10 +81,11 @@ type DynamicApiAuthOptions<Entity extends BaseEntity = any> = {
75
81
  updateAccount?: DynamicApiUpdateAccountOptions<Entity>;
76
82
  resetPassword?: Partial<DynamicApiResetPasswordOptions<Entity>>;
77
83
  refreshToken?: DynamicApiRefreshTokenOptions<Entity>;
84
+ passwordless?: PasswordlessOptions<Entity>;
78
85
  validationPipeOptions?: ValidationPipeOptions;
79
86
  webSocket?: DynamicApiWebSocketOptions;
80
87
  extraImports?: ModuleMetadata['imports'];
81
88
  extraProviders?: ModuleMetadata['providers'];
82
89
  extraControllers?: ModuleMetadata['controllers'];
83
90
  };
84
- export type { DynamicApiAuthBroadcastConfig, DynamicApiAuthOptions, DynamicApiRegisterOptions, DynamicApiUpdateAccountOptions, DynamicApiGetAccountOptions, DynamicApiJWTOptions, DynamicApiLoginOptions, DynamicApiRefreshTokenOptions, DynamicApiResetPasswordOptions, };
91
+ export type { DynamicApiAuthBroadcastConfig, DynamicApiAuthOptions, DynamicApiRegisterOptions, DynamicApiUpdateAccountOptions, DynamicApiGetAccountOptions, DynamicApiJWTOptions, DynamicApiLoginOptions, DynamicApiRefreshTokenOptions, DynamicApiResetPasswordOptions, PasswordlessOptions, };
@@ -13,5 +13,7 @@ interface AuthService<Entity extends BaseEntity> {
13
13
  changePassword(resetPasswordToken: string, newPassword: string): Promise<void>;
14
14
  refreshToken(user: Entity, rawToken?: string): Promise<LoginResponse>;
15
15
  logout(user: Entity): Promise<void>;
16
+ sendOtpCode(identifier: string): Promise<void>;
17
+ verifyOtpCode(identifier: string, code: string): Promise<LoginResponse>;
16
18
  }
17
19
  export type { AuthService, LoginResponse };
@@ -1,5 +1,14 @@
1
1
  import { Type } from '@nestjs/common';
2
2
  import { BaseEntity } from '../../../models';
3
- import { AuthControllerConstructor, DynamicApiGetAccountOptions, DynamicApiLoginOptions, DynamicApiRefreshTokenOptions, DynamicApiRegisterOptions, DynamicApiResetPasswordOptions, DynamicApiUpdateAccountOptions } from '../interfaces';
4
- declare function AuthControllerMixin<Entity extends BaseEntity>(userEntity: Type<Entity>, { loginField, passwordField, additionalFields: additionalRequestFields, useInterceptors: loginUseInterceptors, broadcast: loginBroadcastConfig, }: DynamicApiLoginOptions<Entity>, { additionalFields: additionalRegisterFields, protected: registerProtected, abilityPredicate: registerAbilityPredicate, useInterceptors: registerUseInterceptors, broadcast: registerBroadcastConfig, }?: DynamicApiRegisterOptions<Entity>, { resetPasswordUseInterceptors, changePasswordUseInterceptors, ...resetPasswordOptions }?: DynamicApiResetPasswordOptions<Entity>, { useInterceptors: updateAccountUseInterceptors, broadcast: updateAccountBroadcastConfig, refreshTokenOnUpdate, ...updateAccountOptions }?: DynamicApiUpdateAccountOptions<Entity>, { useInterceptors: getAccountUseInterceptors, broadcast: getAccountBroadcastConfig, }?: DynamicApiGetAccountOptions<Entity>, { useInterceptors: refreshTokenUseInterceptors, useCookie, }?: DynamicApiRefreshTokenOptions<Entity>): AuthControllerConstructor<Entity>;
3
+ import { AuthControllerConstructor, DynamicApiGetAccountOptions, DynamicApiLoginOptions, DynamicApiRefreshTokenOptions, DynamicApiRegisterOptions, DynamicApiResetPasswordOptions, DynamicApiUpdateAccountOptions, PasswordlessOptions } from '../interfaces';
4
+ type AuthControllerMixinOptions<Entity extends BaseEntity> = {
5
+ loginOptions: DynamicApiLoginOptions<Entity>;
6
+ registerOptions?: DynamicApiRegisterOptions<Entity>;
7
+ resetPasswordOptions?: DynamicApiResetPasswordOptions<Entity>;
8
+ updateAccountOptions?: DynamicApiUpdateAccountOptions<Entity>;
9
+ getAccountOptions?: DynamicApiGetAccountOptions<Entity>;
10
+ refreshTokenOptions?: DynamicApiRefreshTokenOptions<Entity>;
11
+ passwordlessOptions?: PasswordlessOptions<Entity>;
12
+ };
13
+ declare function AuthControllerMixin<Entity extends BaseEntity>(userEntity: Type<Entity>, { loginOptions: { loginField, passwordField, additionalFields: additionalRequestFields, useInterceptors: loginUseInterceptors, broadcast: loginBroadcastConfig, }, registerOptions: { additionalFields: additionalRegisterFields, protected: registerProtected, abilityPredicate: registerAbilityPredicate, useInterceptors: registerUseInterceptors, broadcast: registerBroadcastConfig, }, resetPasswordOptions: { resetPasswordUseInterceptors, changePasswordUseInterceptors, ...resetPasswordOptions }, updateAccountOptions: { useInterceptors: updateAccountUseInterceptors, broadcast: updateAccountBroadcastConfig, refreshTokenOnUpdate, ...updateAccountOptions }, getAccountOptions: { useInterceptors: getAccountUseInterceptors, broadcast: getAccountBroadcastConfig, }, refreshTokenOptions: { useInterceptors: refreshTokenUseInterceptors, useCookie, }, passwordlessOptions, }: AuthControllerMixinOptions<Entity>): AuthControllerConstructor<Entity>;
5
14
  export { AuthControllerMixin };