@nest-boot/auth 7.12.1 → 8.0.0-beta.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 (177) hide show
  1. package/dist/adapters/mikro-orm-adapter.d.ts +2 -2
  2. package/dist/adapters/mikro-orm-adapter.js +4 -9
  3. package/dist/adapters/mikro-orm-adapter.js.map +1 -1
  4. package/dist/auth-module-options.interface.d.ts +3 -2
  5. package/dist/auth-module-options.interface.js +1 -2
  6. package/dist/auth.constants.js +2 -5
  7. package/dist/auth.constants.js.map +1 -1
  8. package/dist/auth.guard.js +12 -14
  9. package/dist/auth.guard.js.map +1 -1
  10. package/dist/auth.middleware.d.ts +4 -4
  11. package/dist/auth.middleware.js +19 -19
  12. package/dist/auth.middleware.js.map +1 -1
  13. package/dist/auth.module-definition.d.ts +1 -1
  14. package/dist/auth.module-definition.js +3 -7
  15. package/dist/auth.module-definition.js.map +1 -1
  16. package/dist/auth.module.d.ts +3 -3
  17. package/dist/auth.module.js +48 -47
  18. package/dist/auth.module.js.map +1 -1
  19. package/dist/auth.service.d.ts +200 -200
  20. package/dist/auth.service.js +6 -8
  21. package/dist/auth.service.js.map +1 -1
  22. package/dist/auth.transaction-context.js +3 -9
  23. package/dist/auth.transaction-context.js.map +1 -1
  24. package/dist/decorators/current-session.decorator.js +4 -7
  25. package/dist/decorators/current-session.decorator.js.map +1 -1
  26. package/dist/decorators/current-user.decorator.js +4 -7
  27. package/dist/decorators/current-user.decorator.js.map +1 -1
  28. package/dist/decorators/index.d.ts +3 -3
  29. package/dist/decorators/index.js +3 -19
  30. package/dist/decorators/index.js.map +1 -1
  31. package/dist/decorators/public.decorator.d.ts +1 -1
  32. package/dist/decorators/public.decorator.js +3 -7
  33. package/dist/decorators/public.decorator.js.map +1 -1
  34. package/dist/entities/account.entity.d.ts +1 -1
  35. package/dist/entities/account.entity.js +49 -33
  36. package/dist/entities/account.entity.js.map +1 -1
  37. package/dist/entities/index.d.ts +4 -4
  38. package/dist/entities/index.js +4 -20
  39. package/dist/entities/index.js.map +1 -1
  40. package/dist/entities/session.entity.d.ts +1 -1
  41. package/dist/entities/session.entity.js +35 -29
  42. package/dist/entities/session.entity.js.map +1 -1
  43. package/dist/entities/user.entity.d.ts +1 -1
  44. package/dist/entities/user.entity.js +30 -27
  45. package/dist/entities/user.entity.js.map +1 -1
  46. package/dist/entities/verification.entity.d.ts +1 -1
  47. package/dist/entities/verification.entity.js +26 -25
  48. package/dist/entities/verification.entity.js.map +1 -1
  49. package/dist/index.d.ts +9 -9
  50. package/dist/index.js +9 -25
  51. package/dist/index.js.map +1 -1
  52. package/dist/utils/assert-no-duplicate-generic-oauth-plugin.js +1 -4
  53. package/dist/utils/assert-no-duplicate-generic-oauth-plugin.js.map +1 -1
  54. package/dist/utils/create-email-and-password-config.d.ts +1 -1
  55. package/dist/utils/create-email-and-password-config.js +3 -6
  56. package/dist/utils/create-email-and-password-config.js.map +1 -1
  57. package/dist/utils/create-oidc-config.d.ts +1 -1
  58. package/dist/utils/create-oidc-config.js +12 -15
  59. package/dist/utils/create-oidc-config.js.map +1 -1
  60. package/dist/utils/create-social-provider-config.d.ts +2 -2
  61. package/dist/utils/create-social-provider-config.js +13 -16
  62. package/dist/utils/create-social-provider-config.js.map +1 -1
  63. package/dist/utils/create-social-providers-config.d.ts +1 -1
  64. package/dist/utils/create-social-providers-config.js +4 -7
  65. package/dist/utils/create-social-providers-config.js.map +1 -1
  66. package/dist/utils/estimate-entropy.js +1 -4
  67. package/dist/utils/estimate-entropy.js.map +1 -1
  68. package/dist/utils/generic-oauth-provider-config.type.js +1 -2
  69. package/dist/utils/has-oidc-env-config.js +3 -6
  70. package/dist/utils/has-oidc-env-config.js.map +1 -1
  71. package/dist/utils/has-social-provider-credential-env-config.d.ts +1 -1
  72. package/dist/utils/has-social-provider-credential-env-config.js +3 -6
  73. package/dist/utils/has-social-provider-credential-env-config.js.map +1 -1
  74. package/dist/utils/has-social-provider-env-config.d.ts +1 -1
  75. package/dist/utils/has-social-provider-env-config.js +3 -6
  76. package/dist/utils/has-social-provider-env-config.js.map +1 -1
  77. package/dist/utils/is-env-true.js +1 -4
  78. package/dist/utils/is-env-true.js.map +1 -1
  79. package/dist/utils/oidc.constants.d.ts +1 -1
  80. package/dist/utils/oidc.constants.js +3 -6
  81. package/dist/utils/oidc.constants.js.map +1 -1
  82. package/dist/utils/resolve-oidc-prompt.d.ts +1 -1
  83. package/dist/utils/resolve-oidc-prompt.js +4 -7
  84. package/dist/utils/resolve-oidc-prompt.js.map +1 -1
  85. package/dist/utils/resolve-oidc-scopes.js +1 -4
  86. package/dist/utils/resolve-oidc-scopes.js.map +1 -1
  87. package/dist/utils/resolve-required-oidc-env.d.ts +1 -1
  88. package/dist/utils/resolve-required-oidc-env.js +1 -4
  89. package/dist/utils/resolve-required-oidc-env.js.map +1 -1
  90. package/dist/utils/resolve-required-social-provider-env.d.ts +1 -1
  91. package/dist/utils/resolve-required-social-provider-env.js +3 -6
  92. package/dist/utils/resolve-required-social-provider-env.js.map +1 -1
  93. package/dist/utils/resolve-secret.d.ts +1 -1
  94. package/dist/utils/resolve-secret.js +3 -6
  95. package/dist/utils/resolve-secret.js.map +1 -1
  96. package/dist/utils/resolve-social-provider-enabled.d.ts +1 -1
  97. package/dist/utils/resolve-social-provider-enabled.js +3 -6
  98. package/dist/utils/resolve-social-provider-enabled.js.map +1 -1
  99. package/dist/utils/social-provider.constants.js +1 -4
  100. package/dist/utils/social-provider.constants.js.map +1 -1
  101. package/package.json +24 -26
  102. package/dist/adapters/mikro-orm-adapter.spec.d.ts +0 -8
  103. package/dist/adapters/mikro-orm-adapter.spec.js +0 -417
  104. package/dist/adapters/mikro-orm-adapter.spec.js.map +0 -1
  105. package/dist/auth.guard.spec.d.ts +0 -1
  106. package/dist/auth.guard.spec.js +0 -87
  107. package/dist/auth.guard.spec.js.map +0 -1
  108. package/dist/auth.middleware.spec.d.ts +0 -1
  109. package/dist/auth.middleware.spec.js +0 -139
  110. package/dist/auth.middleware.spec.js.map +0 -1
  111. package/dist/auth.module.spec.d.ts +0 -1
  112. package/dist/auth.module.spec.js +0 -626
  113. package/dist/auth.module.spec.js.map +0 -1
  114. package/dist/auth.service.spec.d.ts +0 -1
  115. package/dist/auth.service.spec.js +0 -26
  116. package/dist/auth.service.spec.js.map +0 -1
  117. package/dist/auth.transaction-context.spec.d.ts +0 -1
  118. package/dist/auth.transaction-context.spec.js +0 -20
  119. package/dist/auth.transaction-context.spec.js.map +0 -1
  120. package/dist/decorators/auth.decorators.spec.d.ts +0 -1
  121. package/dist/decorators/auth.decorators.spec.js +0 -87
  122. package/dist/decorators/auth.decorators.spec.js.map +0 -1
  123. package/dist/entities/entities.spec.d.ts +0 -1
  124. package/dist/entities/entities.spec.js +0 -80
  125. package/dist/entities/entities.spec.js.map +0 -1
  126. package/dist/index.spec.d.ts +0 -1
  127. package/dist/index.spec.js +0 -73
  128. package/dist/index.spec.js.map +0 -1
  129. package/dist/tsconfig.build.tsbuildinfo +0 -1
  130. package/dist/utils/assert-no-duplicate-generic-oauth-plugin.spec.d.ts +0 -1
  131. package/dist/utils/assert-no-duplicate-generic-oauth-plugin.spec.js +0 -29
  132. package/dist/utils/assert-no-duplicate-generic-oauth-plugin.spec.js.map +0 -1
  133. package/dist/utils/create-email-and-password-config.spec.d.ts +0 -1
  134. package/dist/utils/create-email-and-password-config.spec.js +0 -81
  135. package/dist/utils/create-email-and-password-config.spec.js.map +0 -1
  136. package/dist/utils/create-oidc-config.spec.d.ts +0 -1
  137. package/dist/utils/create-oidc-config.spec.js +0 -73
  138. package/dist/utils/create-oidc-config.spec.js.map +0 -1
  139. package/dist/utils/create-social-provider-config.spec.d.ts +0 -1
  140. package/dist/utils/create-social-provider-config.spec.js +0 -139
  141. package/dist/utils/create-social-provider-config.spec.js.map +0 -1
  142. package/dist/utils/create-social-providers-config.spec.d.ts +0 -1
  143. package/dist/utils/create-social-providers-config.spec.js +0 -63
  144. package/dist/utils/create-social-providers-config.spec.js.map +0 -1
  145. package/dist/utils/estimate-entropy.spec.d.ts +0 -1
  146. package/dist/utils/estimate-entropy.spec.js +0 -13
  147. package/dist/utils/estimate-entropy.spec.js.map +0 -1
  148. package/dist/utils/has-oidc-env-config.spec.d.ts +0 -1
  149. package/dist/utils/has-oidc-env-config.spec.js +0 -23
  150. package/dist/utils/has-oidc-env-config.spec.js.map +0 -1
  151. package/dist/utils/has-social-provider-credential-env-config.spec.d.ts +0 -1
  152. package/dist/utils/has-social-provider-credential-env-config.spec.js +0 -33
  153. package/dist/utils/has-social-provider-credential-env-config.spec.js.map +0 -1
  154. package/dist/utils/has-social-provider-env-config.spec.d.ts +0 -1
  155. package/dist/utils/has-social-provider-env-config.spec.js +0 -34
  156. package/dist/utils/has-social-provider-env-config.spec.js.map +0 -1
  157. package/dist/utils/is-env-true.spec.d.ts +0 -1
  158. package/dist/utils/is-env-true.spec.js +0 -20
  159. package/dist/utils/is-env-true.spec.js.map +0 -1
  160. package/dist/utils/resolve-oidc-prompt.spec.d.ts +0 -1
  161. package/dist/utils/resolve-oidc-prompt.spec.js +0 -28
  162. package/dist/utils/resolve-oidc-prompt.spec.js.map +0 -1
  163. package/dist/utils/resolve-oidc-scopes.spec.d.ts +0 -1
  164. package/dist/utils/resolve-oidc-scopes.spec.js +0 -16
  165. package/dist/utils/resolve-oidc-scopes.spec.js.map +0 -1
  166. package/dist/utils/resolve-required-oidc-env.spec.d.ts +0 -1
  167. package/dist/utils/resolve-required-oidc-env.spec.js +0 -22
  168. package/dist/utils/resolve-required-oidc-env.spec.js.map +0 -1
  169. package/dist/utils/resolve-required-social-provider-env.spec.d.ts +0 -1
  170. package/dist/utils/resolve-required-social-provider-env.spec.js +0 -29
  171. package/dist/utils/resolve-required-social-provider-env.spec.js.map +0 -1
  172. package/dist/utils/resolve-secret.spec.d.ts +0 -1
  173. package/dist/utils/resolve-secret.spec.js +0 -34
  174. package/dist/utils/resolve-secret.spec.js.map +0 -1
  175. package/dist/utils/resolve-social-provider-enabled.spec.d.ts +0 -1
  176. package/dist/utils/resolve-social-provider-enabled.spec.js +0 -20
  177. package/dist/utils/resolve-social-provider-enabled.spec.js.map +0 -1
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -11,12 +10,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
10
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
11
  return function (target, key) { decorator(target, key, paramIndex); }
13
12
  };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.AuthService = void 0;
16
- const common_1 = require("@nestjs/common");
17
- const auth_constants_1 = require("./auth.constants");
13
+ import { Inject } from "@nestjs/common";
14
+ import { AUTH_TOKEN } from "./auth.constants.js";
18
15
  /** Service exposing the better-auth API to the application. */
19
16
  let AuthService = class AuthService {
17
+ auth;
20
18
  /**
21
19
  * Creates a new AuthService instance.
22
20
  * @param auth - The better-auth instance
@@ -29,9 +27,9 @@ let AuthService = class AuthService {
29
27
  return this.auth.api;
30
28
  }
31
29
  };
32
- exports.AuthService = AuthService;
33
- exports.AuthService = AuthService = __decorate([
34
- __param(0, (0, common_1.Inject)(auth_constants_1.AUTH_TOKEN)),
30
+ AuthService = __decorate([
31
+ __param(0, Inject(AUTH_TOKEN)),
35
32
  __metadata("design:paramtypes", [Object])
36
33
  ], AuthService);
34
+ export { AuthService };
37
35
  //# sourceMappingURL=auth.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwC;AAGxC,qDAA8C;AAE9C,+DAA+D;AAC/D,IAAa,WAAW,GAAxB,MAAa,WAAW;IACtB;;;OAGG;IACH,YAGmB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAC1B,CAAC;IAEJ,qEAAqE;IACrE,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IACvB,CAAC;CACF,CAAA;AAfY,kCAAW;sBAAX,WAAW;IAMnB,WAAA,IAAA,eAAM,EAAC,2BAAU,CAAC,CAAA;;GANV,WAAW,CAevB"}
1
+ {"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,+DAA+D;AAC/D,IAAa,WAAW,GAAxB,MAAa,WAAW;IAQH;IAPnB;;;OAGG;IACH,YAGmB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAC1B,CAAC;IAEJ,qEAAqE;IACrE,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IACvB,CAAC;CACF,CAAA;AAfY,WAAW;IAMnB,WAAA,MAAM,CAAC,UAAU,CAAC,CAAA;;GANV,WAAW,CAevB"}
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthTransactionContext = void 0;
4
1
  /**
5
2
  * Stores key-value pairs for PostgreSQL transaction-level auth context.
6
3
  *
@@ -8,11 +5,9 @@ exports.AuthTransactionContext = void 0;
8
5
  * Values set here are emitted as `set_config('auth.<key>', '<value>', true)` SQL
9
6
  * statements, enabling row-level security policies to access auth state.
10
7
  */
11
- class AuthTransactionContext {
12
- constructor() {
13
- /** Internal storage for transaction context key-value pairs. @internal */
14
- this.ctx = new Map();
15
- }
8
+ export class AuthTransactionContext {
9
+ /** Internal storage for transaction context key-value pairs. @internal */
10
+ ctx = new Map();
16
11
  /**
17
12
  * Sets a snake_case key-value pair in the transaction context.
18
13
  * @param key - Must be a valid snake_case string
@@ -40,5 +35,4 @@ class AuthTransactionContext {
40
35
  .join(",")};`;
41
36
  }
42
37
  }
43
- exports.AuthTransactionContext = AuthTransactionContext;
44
38
  //# sourceMappingURL=auth.transaction-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.transaction-context.js","sourceRoot":"","sources":["../src/auth.transaction-context.ts"],"names":[],"mappings":";;;AAmDA;;;;;;GAMG;AACH,MAAa,sBAAsB;IAAnC;QACE,0EAA0E;QACzD,QAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IAgCnD,CAAC;IA9BC;;;;;OAKG;IACH,GAAG,CAAmB,GAAiB,EAAE,KAAa;QACpD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CACb,uIAAuI,GAAG,EAAE,CAC7I,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+EAA+E;IAC/E,OAAO;QACL,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,8GAA8G;IAC9G,KAAK;QACH,OAAO,SAAS,CAAC,UAAU,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;aACtD,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACpB,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC/C,OAAO,SAAS,CAAC,oBAAoB,GAAG,OAAO,YAAY,UAAU,CAAC;QACxE,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAClB,CAAC;CACF;AAlCD,wDAkCC"}
1
+ {"version":3,"file":"auth.transaction-context.js","sourceRoot":"","sources":["../src/auth.transaction-context.ts"],"names":[],"mappings":"AAmDA;;;;;;GAMG;AACH,MAAM,OAAO,sBAAsB;IACjC,0EAA0E;IACzD,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEjD;;;;;OAKG;IACH,GAAG,CAAmB,GAAiB,EAAE,KAAa;QACpD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CACb,uIAAuI,GAAG,EAAE,CAC7I,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+EAA+E;IAC/E,OAAO;QACL,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,8GAA8G;IAC9G,KAAK;QACH,OAAO,SAAS,CAAC,UAAU,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;aACtD,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACpB,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC/C,OAAO,SAAS,CAAC,oBAAoB,GAAG,OAAO,YAAY,UAAU,CAAC;QACxE,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAClB,CAAC;CACF"}
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CurrentSession = void 0;
4
- const request_context_1 = require("@nest-boot/request-context");
5
- const common_1 = require("@nestjs/common");
6
- const session_entity_1 = require("../entities/session.entity");
1
+ import { RequestContext } from "@nest-boot/request-context";
2
+ import { createParamDecorator } from "@nestjs/common";
3
+ import { BaseSession } from "../entities/session.entity.js";
7
4
  /** Parameter decorator that injects the current {@link BaseSession} from the request context. */
8
- exports.CurrentSession = (0, common_1.createParamDecorator)(() => request_context_1.RequestContext.get(session_entity_1.BaseSession));
5
+ export const CurrentSession = createParamDecorator(() => RequestContext.get(BaseSession));
9
6
  //# sourceMappingURL=current-session.decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"current-session.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-session.decorator.ts"],"names":[],"mappings":";;;AAAA,gEAA4D;AAC5D,2CAAsD;AAEtD,+DAAyD;AAEzD,iGAAiG;AACpF,QAAA,cAAc,GAAG,IAAA,6BAAoB,EAAC,GAAG,EAAE,CACtD,gCAAc,CAAC,GAAG,CAAC,4BAAW,CAAC,CAChC,CAAC"}
1
+ {"version":3,"file":"current-session.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-session.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,iGAAiG;AACjG,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC,GAAG,EAAE,CACtD,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAChC,CAAC"}
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CurrentUser = void 0;
4
- const request_context_1 = require("@nest-boot/request-context");
5
- const common_1 = require("@nestjs/common");
6
- const user_entity_1 = require("../entities/user.entity");
1
+ import { RequestContext } from "@nest-boot/request-context";
2
+ import { createParamDecorator } from "@nestjs/common";
3
+ import { BaseUser } from "../entities/user.entity.js";
7
4
  /** Parameter decorator that injects the current {@link BaseUser} from the request context. */
8
- exports.CurrentUser = (0, common_1.createParamDecorator)(() => request_context_1.RequestContext.get(user_entity_1.BaseUser));
5
+ export const CurrentUser = createParamDecorator(() => RequestContext.get(BaseUser));
9
6
  //# sourceMappingURL=current-user.decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"current-user.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-user.decorator.ts"],"names":[],"mappings":";;;AAAA,gEAA4D;AAC5D,2CAAsD;AAEtD,yDAAmD;AAEnD,8FAA8F;AACjF,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAAC,GAAG,EAAE,CACnD,gCAAc,CAAC,GAAG,CAAC,sBAAQ,CAAC,CAC7B,CAAC"}
1
+ {"version":3,"file":"current-user.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-user.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,8FAA8F;AAC9F,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,CAAC,GAAG,EAAE,CACnD,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAC7B,CAAC"}
@@ -1,3 +1,3 @@
1
- export * from "./current-session.decorator";
2
- export * from "./current-user.decorator";
3
- export * from "./public.decorator";
1
+ export * from "./current-session.decorator.js";
2
+ export * from "./current-user.decorator.js";
3
+ export * from "./public.decorator.js";
@@ -1,20 +1,4 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./current-session.decorator"), exports);
18
- __exportStar(require("./current-user.decorator"), exports);
19
- __exportStar(require("./public.decorator"), exports);
1
+ export * from "./current-session.decorator.js";
2
+ export * from "./current-user.decorator.js";
3
+ export * from "./public.decorator.js";
20
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,2DAAyC;AACzC,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC"}
@@ -1,3 +1,3 @@
1
- import { IS_PUBLIC_KEY } from "../auth.constants";
1
+ import { IS_PUBLIC_KEY } from "../auth.constants.js";
2
2
  /** Decorator that marks a route as public, bypassing the {@link AuthGuard}. */
3
3
  export declare const Public: (value?: boolean) => import("@nestjs/common").CustomDecorator<typeof IS_PUBLIC_KEY>;
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Public = void 0;
4
- const common_1 = require("@nestjs/common");
5
- const auth_constants_1 = require("../auth.constants");
1
+ import { SetMetadata } from "@nestjs/common";
2
+ import { IS_PUBLIC_KEY } from "../auth.constants.js";
6
3
  /** Decorator that marks a route as public, bypassing the {@link AuthGuard}. */
7
- const Public = (value = true) => (0, common_1.SetMetadata)(auth_constants_1.IS_PUBLIC_KEY, value);
8
- exports.Public = Public;
4
+ export const Public = (value = true) => SetMetadata(IS_PUBLIC_KEY, value);
9
5
  //# sourceMappingURL=public.decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../src/decorators/public.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAE7C,sDAAkD;AAElD,+EAA+E;AACxE,MAAM,MAAM,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,EAAE,CAAC,IAAA,oBAAW,EAAC,8BAAa,EAAE,KAAK,CAAC,CAAC;AAA7D,QAAA,MAAM,UAAuD"}
1
+ {"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../src/decorators/public.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { BaseEntity, Opt } from "@mikro-orm/core";
1
+ import { BaseEntity, type Opt } from "@mikro-orm/core";
2
2
  /**
3
3
  * Abstract base entity for OAuth/credential account records.
4
4
  *
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -8,10 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
7
  var __metadata = (this && this.__metadata) || function (k, v) {
9
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.BaseAccount = void 0;
13
- const core_1 = require("@mikro-orm/core");
14
- const crypto_1 = require("crypto");
10
+ import { BaseEntity, Cascade, t } from "@mikro-orm/core";
11
+ import { Entity, ManyToOne, PrimaryKey, Property, } from "@mikro-orm/decorators/legacy";
12
+ import { randomUUID } from "crypto";
15
13
  /**
16
14
  * Abstract base entity for OAuth/credential account records.
17
15
  *
@@ -19,79 +17,97 @@ const crypto_1 = require("crypto");
19
17
  * Maps to the better-auth `account` model. Each account links a provider
20
18
  * (e.g. Google, GitHub, credentials) to a {@link BaseUser}.
21
19
  */
22
- let BaseAccount = class BaseAccount extends core_1.BaseEntity {
23
- constructor() {
24
- super(...arguments);
25
- /** Primary key (UUID v4, auto-generated). */
26
- this.id = (0, crypto_1.randomUUID)();
27
- /** Timestamp when the account was created. */
28
- this.createdAt = new Date();
29
- /** Timestamp of the last update. */
30
- this.updatedAt = new Date();
31
- }
20
+ let BaseAccount = class BaseAccount extends BaseEntity {
21
+ /** Primary key (UUID v4, auto-generated). */
22
+ id = randomUUID();
23
+ /** Provider-scoped account identifier. */
24
+ accountId;
25
+ /** Authentication provider identifier (e.g. `"google"`, `"credential"`). */
26
+ providerId;
27
+ /** Foreign key referencing the owning {@link BaseUser}. */
28
+ userId;
29
+ /** OAuth access token, if available. */
30
+ accessToken;
31
+ /** OAuth refresh token, if available. */
32
+ refreshToken;
33
+ /** OpenID Connect ID token, if available. */
34
+ idToken;
35
+ /** Expiration timestamp of the access token. */
36
+ accessTokenExpiresAt;
37
+ /** Expiration timestamp of the refresh token. */
38
+ refreshTokenExpiresAt;
39
+ /** OAuth scopes granted to this account. */
40
+ scope;
41
+ /** Hashed password for credential-based accounts. */
42
+ password;
43
+ /** Timestamp when the account was created. */
44
+ createdAt = new Date();
45
+ /** Timestamp of the last update. */
46
+ updatedAt = new Date();
32
47
  };
33
- exports.BaseAccount = BaseAccount;
34
48
  __decorate([
35
- (0, core_1.PrimaryKey)({ type: core_1.t.uuid }),
49
+ PrimaryKey({ type: t.uuid }),
36
50
  __metadata("design:type", Object)
37
51
  ], BaseAccount.prototype, "id", void 0);
38
52
  __decorate([
39
- (0, core_1.Property)({ type: core_1.t.text }),
53
+ Property({ type: t.text }),
40
54
  __metadata("design:type", String)
41
55
  ], BaseAccount.prototype, "accountId", void 0);
42
56
  __decorate([
43
- (0, core_1.Property)({ type: core_1.t.text }),
57
+ Property({ type: t.text }),
44
58
  __metadata("design:type", String)
45
59
  ], BaseAccount.prototype, "providerId", void 0);
46
60
  __decorate([
47
- (0, core_1.ManyToOne)(() => "User", {
61
+ ManyToOne({
62
+ entity: () => "User",
48
63
  fieldName: "user_id",
49
64
  mapToPk: true,
50
- cascade: [core_1.Cascade.REMOVE],
65
+ cascade: [Cascade.REMOVE],
51
66
  }),
52
67
  __metadata("design:type", String)
53
68
  ], BaseAccount.prototype, "userId", void 0);
54
69
  __decorate([
55
- (0, core_1.Property)({ type: core_1.t.text, nullable: true }),
70
+ Property({ type: t.text, nullable: true }),
56
71
  __metadata("design:type", Object)
57
72
  ], BaseAccount.prototype, "accessToken", void 0);
58
73
  __decorate([
59
- (0, core_1.Property)({ type: core_1.t.text, nullable: true }),
74
+ Property({ type: t.text, nullable: true }),
60
75
  __metadata("design:type", Object)
61
76
  ], BaseAccount.prototype, "refreshToken", void 0);
62
77
  __decorate([
63
- (0, core_1.Property)({ type: core_1.t.text, nullable: true }),
78
+ Property({ type: t.text, nullable: true }),
64
79
  __metadata("design:type", Object)
65
80
  ], BaseAccount.prototype, "idToken", void 0);
66
81
  __decorate([
67
- (0, core_1.Property)({ type: core_1.t.datetime, nullable: true }),
82
+ Property({ type: t.datetime, nullable: true }),
68
83
  __metadata("design:type", Object)
69
84
  ], BaseAccount.prototype, "accessTokenExpiresAt", void 0);
70
85
  __decorate([
71
- (0, core_1.Property)({ type: core_1.t.datetime, nullable: true }),
86
+ Property({ type: t.datetime, nullable: true }),
72
87
  __metadata("design:type", Object)
73
88
  ], BaseAccount.prototype, "refreshTokenExpiresAt", void 0);
74
89
  __decorate([
75
- (0, core_1.Property)({ type: core_1.t.text, nullable: true }),
90
+ Property({ type: t.text, nullable: true }),
76
91
  __metadata("design:type", Object)
77
92
  ], BaseAccount.prototype, "scope", void 0);
78
93
  __decorate([
79
- (0, core_1.Property)({ type: core_1.t.text, nullable: true }),
94
+ Property({ type: t.text, nullable: true }),
80
95
  __metadata("design:type", Object)
81
96
  ], BaseAccount.prototype, "password", void 0);
82
97
  __decorate([
83
- (0, core_1.Property)({ type: core_1.t.datetime, defaultRaw: "now()" }),
98
+ Property({ type: t.datetime, defaultRaw: "now()" }),
84
99
  __metadata("design:type", Object)
85
100
  ], BaseAccount.prototype, "createdAt", void 0);
86
101
  __decorate([
87
- (0, core_1.Property)({
88
- type: core_1.t.datetime,
102
+ Property({
103
+ type: t.datetime,
89
104
  defaultRaw: "now()",
90
105
  onUpdate: () => new Date(),
91
106
  }),
92
107
  __metadata("design:type", Object)
93
108
  ], BaseAccount.prototype, "updatedAt", void 0);
94
- exports.BaseAccount = BaseAccount = __decorate([
95
- (0, core_1.Entity)({ abstract: true })
109
+ BaseAccount = __decorate([
110
+ Entity({ abstract: true })
96
111
  ], BaseAccount);
112
+ export { BaseAccount };
97
113
  //# sourceMappingURL=account.entity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"account.entity.js","sourceRoot":"","sources":["../../src/entities/account.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CASyB;AACzB,mCAAoC;AAEpC;;;;;;GAMG;AAEI,IAAe,WAAW,GAA1B,MAAe,WAAY,SAAQ,iBAAU;IAA7C;;QACL,6CAA6C;QAE7C,OAAE,GAAgB,IAAA,mBAAU,GAAE,CAAC;QA8C/B,8CAA8C;QAE9C,cAAS,GAAc,IAAI,IAAI,EAAE,CAAC;QAElC,oCAAoC;QAMpC,cAAS,GAAc,IAAI,IAAI,EAAE,CAAC;IACpC,CAAC;CAAA,CAAA;AA5DqB,kCAAW;AAG/B;IADC,IAAA,iBAAU,EAAC,EAAE,IAAI,EAAE,QAAC,CAAC,IAAI,EAAE,CAAC;;uCACE;AAI/B;IADC,IAAA,eAAQ,EAAC,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,CAAC,CAAC,QAAQ;QAChB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;KAC3B,CAAC;;8CACgC;AA5Dd,WAAW;IADhC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;GACL,WAAW,CA6DhC"}
@@ -1,4 +1,4 @@
1
- export * from "./account.entity";
2
- export * from "./session.entity";
3
- export * from "./user.entity";
4
- export * from "./verification.entity";
1
+ export * from "./account.entity.js";
2
+ export * from "./session.entity.js";
3
+ export * from "./user.entity.js";
4
+ export * from "./verification.entity.js";
@@ -1,21 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./account.entity"), exports);
18
- __exportStar(require("./session.entity"), exports);
19
- __exportStar(require("./user.entity"), exports);
20
- __exportStar(require("./verification.entity"), exports);
1
+ export * from "./account.entity.js";
2
+ export * from "./session.entity.js";
3
+ export * from "./user.entity.js";
4
+ export * from "./verification.entity.js";
21
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,mDAAiC;AACjC,gDAA8B;AAC9B,wDAAsC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC"}
@@ -1,4 +1,4 @@
1
- import { BaseEntity, Opt } from "@mikro-orm/core";
1
+ import { BaseEntity, type Opt } from "@mikro-orm/core";
2
2
  /**
3
3
  * Abstract base entity for user session records.
4
4
  *
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -8,10 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
7
  var __metadata = (this && this.__metadata) || function (k, v) {
9
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.BaseSession = void 0;
13
- const core_1 = require("@mikro-orm/core");
14
- const crypto_1 = require("crypto");
10
+ import { BaseEntity, Cascade, t } from "@mikro-orm/core";
11
+ import { Entity, ManyToOne, PrimaryKey, Property, Unique, } from "@mikro-orm/decorators/legacy";
12
+ import { randomUUID } from "crypto";
15
13
  /**
16
14
  * Abstract base entity for user session records.
17
15
  *
@@ -19,60 +17,68 @@ const crypto_1 = require("crypto");
19
17
  * Maps to the better-auth `session` model. Each session is tied to a
20
18
  * {@link BaseUser} and identified by a unique token.
21
19
  */
22
- let BaseSession = class BaseSession extends core_1.BaseEntity {
23
- constructor() {
24
- super(...arguments);
25
- /** Primary key (UUID v4, auto-generated). */
26
- this.id = (0, crypto_1.randomUUID)();
27
- /** Timestamp when the session was created. */
28
- this.createdAt = new Date();
29
- /** Timestamp of the last update. */
30
- this.updatedAt = new Date();
31
- }
20
+ let BaseSession = class BaseSession extends BaseEntity {
21
+ /** Primary key (UUID v4, auto-generated). */
22
+ id = randomUUID();
23
+ /** Unique session token used for authentication. */
24
+ token;
25
+ /** Foreign key referencing the owning {@link BaseUser}. */
26
+ userId;
27
+ /** Timestamp when the session expires. */
28
+ expiresAt;
29
+ /** IP address of the client that created or last used this session. */
30
+ ipAddress;
31
+ /** User-Agent header from the client that created or last used this session. */
32
+ userAgent;
33
+ /** Timestamp when the session was created. */
34
+ createdAt = new Date();
35
+ /** Timestamp of the last update. */
36
+ updatedAt = new Date();
32
37
  };
33
- exports.BaseSession = BaseSession;
34
38
  __decorate([
35
- (0, core_1.PrimaryKey)({ type: core_1.t.uuid }),
39
+ PrimaryKey({ type: t.uuid }),
36
40
  __metadata("design:type", Object)
37
41
  ], BaseSession.prototype, "id", void 0);
38
42
  __decorate([
39
- (0, core_1.Property)({ type: core_1.t.text }),
40
- (0, core_1.Unique)(),
43
+ Property({ type: t.text }),
44
+ Unique(),
41
45
  __metadata("design:type", String)
42
46
  ], BaseSession.prototype, "token", void 0);
43
47
  __decorate([
44
- (0, core_1.ManyToOne)(() => "User", {
48
+ ManyToOne({
49
+ entity: () => "User",
45
50
  fieldName: "user_id",
46
51
  mapToPk: true,
47
- cascade: [core_1.Cascade.REMOVE],
52
+ cascade: [Cascade.REMOVE],
48
53
  }),
49
54
  __metadata("design:type", String)
50
55
  ], BaseSession.prototype, "userId", void 0);
51
56
  __decorate([
52
- (0, core_1.Property)({ type: core_1.t.datetime }),
57
+ Property({ type: t.datetime }),
53
58
  __metadata("design:type", Date)
54
59
  ], BaseSession.prototype, "expiresAt", void 0);
55
60
  __decorate([
56
- (0, core_1.Property)({ type: core_1.t.text, nullable: true }),
61
+ Property({ type: t.text, nullable: true }),
57
62
  __metadata("design:type", Object)
58
63
  ], BaseSession.prototype, "ipAddress", void 0);
59
64
  __decorate([
60
- (0, core_1.Property)({ type: core_1.t.text, nullable: true }),
65
+ Property({ type: t.text, nullable: true }),
61
66
  __metadata("design:type", Object)
62
67
  ], BaseSession.prototype, "userAgent", void 0);
63
68
  __decorate([
64
- (0, core_1.Property)({ type: core_1.t.datetime, defaultRaw: "now()" }),
69
+ Property({ type: t.datetime, defaultRaw: "now()" }),
65
70
  __metadata("design:type", Object)
66
71
  ], BaseSession.prototype, "createdAt", void 0);
67
72
  __decorate([
68
- (0, core_1.Property)({
69
- type: core_1.t.datetime,
73
+ Property({
74
+ type: t.datetime,
70
75
  defaultRaw: "now()",
71
76
  onUpdate: () => new Date(),
72
77
  }),
73
78
  __metadata("design:type", Object)
74
79
  ], BaseSession.prototype, "updatedAt", void 0);
75
- exports.BaseSession = BaseSession = __decorate([
76
- (0, core_1.Entity)({ abstract: true })
80
+ BaseSession = __decorate([
81
+ Entity({ abstract: true })
77
82
  ], BaseSession);
83
+ export { BaseSession };
78
84
  //# sourceMappingURL=session.entity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.entity.js","sourceRoot":"","sources":["../../src/entities/session.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAUyB;AACzB,mCAAoC;AAEpC;;;;;;GAMG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,iBAAU;IAApC;;QACL,6CAA6C;QAE7C,OAAE,GAAgB,IAAA,mBAAU,GAAE,CAAC;QA2B/B,8CAA8C;QAE9C,cAAS,GAAc,IAAI,IAAI,EAAE,CAAC;QAElC,oCAAoC;QAMpC,cAAS,GAAc,IAAI,IAAI,EAAE,CAAC;IACpC,CAAC;CAAA,CAAA;AAzCY,kCAAW;AAGtB;IADC,IAAA,iBAAU,EAAC,EAAE,IAAI,EAAE,QAAC,CAAC,IAAI,EAAE,CAAC;;uCACE;AAK/B;IAFC,IAAA,eAAQ,EAAC,EAAE,IAAI,EAAE,QAAC,CAAC,IAAI,EAAE,CAAC;IAC1B,IAAA,aAAM,GAAE;;0CACM;AAQf;IALC,IAAA,gBAAS,EAA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