@authup/server-core 1.0.0-beta.61 → 1.0.0-beta.63

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 (216) hide show
  1. package/dist/adapters/database/domains/client-scope/entity.d.ts.map +1 -1
  2. package/dist/adapters/database/domains/client-scope/entity.mjs +16 -8
  3. package/dist/adapters/database/domains/client-scope/entity.mjs.map +1 -1
  4. package/dist/adapters/database/domains/identity-provider-account/entity.d.ts.map +1 -1
  5. package/dist/adapters/database/domains/identity-provider-account/entity.mjs +1 -1
  6. package/dist/adapters/database/domains/identity-provider-account/entity.mjs.map +1 -1
  7. package/dist/adapters/database/domains/identity-provider-attribute/subscriber.d.ts +8 -1
  8. package/dist/adapters/database/domains/identity-provider-attribute/subscriber.d.ts.map +1 -1
  9. package/dist/adapters/database/domains/identity-provider-attribute/subscriber.mjs +14 -0
  10. package/dist/adapters/database/domains/identity-provider-attribute/subscriber.mjs.map +1 -1
  11. package/dist/adapters/database/migrations/mysql/1786631686318-SortIndexesAndAccountUniqueness.d.ts +50 -0
  12. package/dist/adapters/database/migrations/mysql/1786631686318-SortIndexesAndAccountUniqueness.d.ts.map +1 -0
  13. package/dist/adapters/database/migrations/mysql/1786631686318-SortIndexesAndAccountUniqueness.mjs +86 -0
  14. package/dist/adapters/database/migrations/mysql/1786631686318-SortIndexesAndAccountUniqueness.mjs.map +1 -0
  15. package/dist/adapters/database/migrations/postgres/1786631686318-SortIndexesAndAccountUniqueness.d.ts +42 -0
  16. package/dist/adapters/database/migrations/postgres/1786631686318-SortIndexesAndAccountUniqueness.d.ts.map +1 -0
  17. package/dist/adapters/database/migrations/postgres/1786631686318-SortIndexesAndAccountUniqueness.mjs +80 -0
  18. package/dist/adapters/database/migrations/postgres/1786631686318-SortIndexesAndAccountUniqueness.mjs.map +1 -0
  19. package/dist/adapters/http/adapters/oauth2/grant-types/refresh_token.d.ts.map +1 -1
  20. package/dist/adapters/http/adapters/oauth2/grant-types/refresh_token.mjs +8 -2
  21. package/dist/adapters/http/adapters/oauth2/grant-types/refresh_token.mjs.map +1 -1
  22. package/dist/adapters/http/adapters/oauth2/grant-types/utils/credentials.mjs +1 -1
  23. package/dist/adapters/http/adapters/oauth2/grant-types/utils/guess.mjs +1 -1
  24. package/dist/adapters/http/controllers/entities/client/module.mjs +2 -2
  25. package/dist/adapters/http/controllers/entities/identity-provider/module.d.ts +24 -4
  26. package/dist/adapters/http/controllers/entities/identity-provider/module.d.ts.map +1 -1
  27. package/dist/adapters/http/controllers/entities/identity-provider/module.mjs +117 -106
  28. package/dist/adapters/http/controllers/entities/identity-provider/module.mjs.map +1 -1
  29. package/dist/adapters/http/controllers/entities/identity-provider/types.d.ts +6 -4
  30. package/dist/adapters/http/controllers/entities/identity-provider/types.d.ts.map +1 -1
  31. package/dist/adapters/http/controllers/entities/realm/module.mjs +2 -2
  32. package/dist/adapters/http/controllers/entities/session/module.mjs +2 -2
  33. package/dist/adapters/http/controllers/entities/user/module.mjs +2 -2
  34. package/dist/adapters/http/controllers/entities/user-authenticator/module.mjs +2 -2
  35. package/dist/adapters/http/controllers/workflows/authenticator-challenge/module.d.ts +2 -0
  36. package/dist/adapters/http/controllers/workflows/authenticator-challenge/module.d.ts.map +1 -1
  37. package/dist/adapters/http/controllers/workflows/authenticator-challenge/module.mjs +21 -3
  38. package/dist/adapters/http/controllers/workflows/authenticator-challenge/module.mjs.map +1 -1
  39. package/dist/adapters/http/controllers/workflows/authorize/module.d.ts.map +1 -1
  40. package/dist/adapters/http/controllers/workflows/authorize/module.mjs +14 -5
  41. package/dist/adapters/http/controllers/workflows/authorize/module.mjs.map +1 -1
  42. package/dist/adapters/http/controllers/workflows/token/module.d.ts.map +1 -1
  43. package/dist/adapters/http/controllers/workflows/token/module.mjs +22 -9
  44. package/dist/adapters/http/controllers/workflows/token/module.mjs.map +1 -1
  45. package/dist/adapters/http/controllers/workflows/token/utils/extract.mjs +2 -1
  46. package/dist/adapters/http/controllers/workflows/token/utils/extract.mjs.map +1 -1
  47. package/dist/adapters/http/middleware/built-in/assets.mjs +1 -1
  48. package/dist/adapters/http/middleware/built-in/cors.d.ts.map +1 -1
  49. package/dist/adapters/http/middleware/built-in/cors.mjs.map +1 -1
  50. package/dist/adapters/http/middleware/built-in/error.d.ts.map +1 -1
  51. package/dist/adapters/http/middleware/built-in/error.mjs +10 -1
  52. package/dist/adapters/http/middleware/built-in/error.mjs.map +1 -1
  53. package/dist/adapters/http/request/helpers/param-id.d.ts.map +1 -1
  54. package/dist/adapters/http/request/helpers/param-id.mjs +2 -1
  55. package/dist/adapters/http/request/helpers/param-id.mjs.map +1 -1
  56. package/dist/adapters/http/ui/account-console/module.mjs +1 -1
  57. package/dist/adapters/http/ui/auth-console/http-client.mjs +1 -1
  58. package/dist/adapters/http/ui/auth-console/module.mjs +1 -1
  59. package/dist/adapters/http/ui/console-packages/module.d.ts +1 -1
  60. package/dist/adapters/http/ui/console-packages/module.mjs +2 -2
  61. package/dist/adapters/http/ui/console-packages/module.mjs.map +1 -1
  62. package/dist/adapters/http/ui/shared/html.d.ts.map +1 -1
  63. package/dist/adapters/http/ui/shared/html.mjs +1 -0
  64. package/dist/adapters/http/ui/shared/html.mjs.map +1 -1
  65. package/dist/app/modules/config/normalize.d.ts.map +1 -1
  66. package/dist/app/modules/config/normalize.mjs +2 -2
  67. package/dist/app/modules/config/normalize.mjs.map +1 -1
  68. package/dist/app/modules/config/read/env.mjs +1 -1
  69. package/dist/app/modules/config/types.d.ts +8 -0
  70. package/dist/app/modules/config/types.d.ts.map +1 -1
  71. package/dist/app/modules/database/repositories/event/repository.d.ts +2 -2
  72. package/dist/app/modules/database/repositories/event/repository.d.ts.map +1 -1
  73. package/dist/app/modules/database/repositories/event/repository.mjs +23 -6
  74. package/dist/app/modules/database/repositories/event/repository.mjs.map +1 -1
  75. package/dist/app/modules/database/repositories/identity-provider/repository.d.ts +3 -1
  76. package/dist/app/modules/database/repositories/identity-provider/repository.d.ts.map +1 -1
  77. package/dist/app/modules/database/repositories/identity-provider/repository.mjs +2 -2
  78. package/dist/app/modules/database/repositories/identity-provider/repository.mjs.map +1 -1
  79. package/dist/app/modules/database/repositories/identity-provider-account/repository.d.ts.map +1 -1
  80. package/dist/app/modules/database/repositories/identity-provider-account/repository.mjs +9 -1
  81. package/dist/app/modules/database/repositories/identity-provider-account/repository.mjs.map +1 -1
  82. package/dist/app/modules/http/modules/controller.d.ts.map +1 -1
  83. package/dist/app/modules/http/modules/controller.mjs +20 -6
  84. package/dist/app/modules/http/modules/controller.mjs.map +1 -1
  85. package/dist/app/modules/identity/module.d.ts.map +1 -1
  86. package/dist/app/modules/identity/module.mjs +6 -3
  87. package/dist/app/modules/identity/module.mjs.map +1 -1
  88. package/dist/app/modules/identity/repositories/user.d.ts +1 -0
  89. package/dist/app/modules/identity/repositories/user.d.ts.map +1 -1
  90. package/dist/app/modules/identity/repositories/user.mjs +3 -0
  91. package/dist/app/modules/identity/repositories/user.mjs.map +1 -1
  92. package/dist/app/modules/oauth2/constants.d.ts +2 -1
  93. package/dist/app/modules/oauth2/constants.d.ts.map +1 -1
  94. package/dist/app/modules/oauth2/constants.mjs +1 -0
  95. package/dist/app/modules/oauth2/constants.mjs.map +1 -1
  96. package/dist/app/modules/oauth2/module.d.ts.map +1 -1
  97. package/dist/app/modules/oauth2/module.mjs +5 -0
  98. package/dist/app/modules/oauth2/module.mjs.map +1 -1
  99. package/dist/app/modules/oauth2/repositories/authorize/state/repository.d.ts +1 -2
  100. package/dist/app/modules/oauth2/repositories/authorize/state/repository.d.ts.map +1 -1
  101. package/dist/app/modules/oauth2/repositories/authorize/state/repository.mjs +7 -16
  102. package/dist/app/modules/oauth2/repositories/authorize/state/repository.mjs.map +1 -1
  103. package/dist/app/modules/oauth2/repositories/constants.d.ts +1 -0
  104. package/dist/app/modules/oauth2/repositories/constants.d.ts.map +1 -1
  105. package/dist/app/modules/oauth2/repositories/constants.mjs +1 -0
  106. package/dist/app/modules/oauth2/repositories/constants.mjs.map +1 -1
  107. package/dist/app/modules/oauth2/repositories/federated-login/index.d.ts +2 -0
  108. package/dist/app/modules/oauth2/repositories/federated-login/index.d.ts.map +1 -0
  109. package/dist/app/modules/oauth2/repositories/federated-login/index.mjs +5 -0
  110. package/dist/app/modules/oauth2/repositories/federated-login/store.d.ts +9 -0
  111. package/dist/app/modules/oauth2/repositories/federated-login/store.d.ts.map +1 -0
  112. package/dist/app/modules/oauth2/repositories/federated-login/store.mjs +33 -0
  113. package/dist/app/modules/oauth2/repositories/federated-login/store.mjs.map +1 -0
  114. package/dist/app/modules/oauth2/repositories/index.d.ts +1 -0
  115. package/dist/app/modules/oauth2/repositories/index.d.ts.map +1 -1
  116. package/dist/app/modules/oauth2/repositories/index.mjs +3 -1
  117. package/dist/app/modules/runtime/module.mjs +2 -2
  118. package/dist/cli/commands/migration.mjs +1 -1
  119. package/dist/core/entities/client-scope/schema.d.ts.map +1 -1
  120. package/dist/core/entities/client-scope/schema.mjs +16 -1
  121. package/dist/core/entities/client-scope/schema.mjs.map +1 -1
  122. package/dist/core/entities/event/constants.d.ts +9 -0
  123. package/dist/core/entities/event/constants.d.ts.map +1 -1
  124. package/dist/core/entities/event/constants.mjs +9 -1
  125. package/dist/core/entities/event/constants.mjs.map +1 -1
  126. package/dist/core/entities/event/entity-event-handler.d.ts.map +1 -1
  127. package/dist/core/entities/event/entity-event-handler.mjs +14 -1
  128. package/dist/core/entities/event/entity-event-handler.mjs.map +1 -1
  129. package/dist/core/entities/event/index.mjs +2 -2
  130. package/dist/core/entities/event/types.d.ts +11 -2
  131. package/dist/core/entities/event/types.d.ts.map +1 -1
  132. package/dist/core/entities/identity-provider/types.d.ts +9 -1
  133. package/dist/core/entities/identity-provider/types.d.ts.map +1 -1
  134. package/dist/core/entities/identity-provider-account/types.d.ts +6 -0
  135. package/dist/core/entities/identity-provider-account/types.d.ts.map +1 -1
  136. package/dist/core/entities/identity-provider-account/types.mjs.map +1 -1
  137. package/dist/core/entities/index.mjs +2 -2
  138. package/dist/core/identity/entities/user/types.d.ts +1 -0
  139. package/dist/core/identity/entities/user/types.d.ts.map +1 -1
  140. package/dist/core/identity/index.mjs +12 -11
  141. package/dist/core/identity/provider/account/module.d.ts +3 -0
  142. package/dist/core/identity/provider/account/module.d.ts.map +1 -1
  143. package/dist/core/identity/provider/account/module.mjs +54 -27
  144. package/dist/core/identity/provider/account/module.mjs.map +1 -1
  145. package/dist/core/identity/provider/account/types.d.ts +7 -0
  146. package/dist/core/identity/provider/account/types.d.ts.map +1 -1
  147. package/dist/core/identity/provider/authentication/index.mjs +3 -2
  148. package/dist/core/identity/provider/authentication/protocols/index.mjs +2 -1
  149. package/dist/core/identity/provider/authentication/protocols/oauth2/assurance.d.ts +46 -0
  150. package/dist/core/identity/provider/authentication/protocols/oauth2/assurance.d.ts.map +1 -0
  151. package/dist/core/identity/provider/authentication/protocols/oauth2/assurance.mjs +89 -0
  152. package/dist/core/identity/provider/authentication/protocols/oauth2/assurance.mjs.map +1 -0
  153. package/dist/core/identity/provider/authentication/protocols/oauth2/index.d.ts +1 -0
  154. package/dist/core/identity/provider/authentication/protocols/oauth2/index.d.ts.map +1 -1
  155. package/dist/core/identity/provider/authentication/protocols/oauth2/index.mjs +2 -1
  156. package/dist/core/identity/provider/authentication/protocols/oauth2/module.d.ts.map +1 -1
  157. package/dist/core/identity/provider/authentication/protocols/oauth2/module.mjs +9 -2
  158. package/dist/core/identity/provider/authentication/protocols/oauth2/module.mjs.map +1 -1
  159. package/dist/core/identity/provider/index.mjs +12 -11
  160. package/dist/core/index.mjs +16 -12
  161. package/dist/core/oauth2/authorization/code-request/verifier/module.d.ts.map +1 -1
  162. package/dist/core/oauth2/authorization/code-request/verifier/module.mjs +7 -1
  163. package/dist/core/oauth2/authorization/code-request/verifier/module.mjs.map +1 -1
  164. package/dist/core/oauth2/authorization/helpers.d.ts.map +1 -1
  165. package/dist/core/oauth2/authorization/helpers.mjs +6 -1
  166. package/dist/core/oauth2/authorization/helpers.mjs.map +1 -1
  167. package/dist/core/oauth2/authorization/module.d.ts.map +1 -1
  168. package/dist/core/oauth2/authorization/module.mjs +5 -3
  169. package/dist/core/oauth2/authorization/module.mjs.map +1 -1
  170. package/dist/core/oauth2/authorization/state/module.mjs +1 -2
  171. package/dist/core/oauth2/authorization/state/module.mjs.map +1 -1
  172. package/dist/core/oauth2/authorization/state/types.d.ts +13 -2
  173. package/dist/core/oauth2/authorization/state/types.d.ts.map +1 -1
  174. package/dist/core/oauth2/end-session/service.d.ts.map +1 -1
  175. package/dist/core/oauth2/end-session/service.mjs +1 -0
  176. package/dist/core/oauth2/end-session/service.mjs.map +1 -1
  177. package/dist/core/oauth2/federated-login/constants.d.ts +22 -0
  178. package/dist/core/oauth2/federated-login/constants.d.ts.map +1 -0
  179. package/dist/core/oauth2/federated-login/constants.mjs +27 -0
  180. package/dist/core/oauth2/federated-login/constants.mjs.map +1 -0
  181. package/dist/core/oauth2/federated-login/index.d.ts +4 -0
  182. package/dist/core/oauth2/federated-login/index.d.ts.map +1 -0
  183. package/dist/core/oauth2/federated-login/index.mjs +7 -0
  184. package/dist/core/oauth2/federated-login/module.d.ts +29 -0
  185. package/dist/core/oauth2/federated-login/module.d.ts.map +1 -0
  186. package/dist/core/oauth2/federated-login/module.mjs +193 -0
  187. package/dist/core/oauth2/federated-login/module.mjs.map +1 -0
  188. package/dist/core/oauth2/federated-login/types.d.ts +196 -0
  189. package/dist/core/oauth2/federated-login/types.d.ts.map +1 -0
  190. package/dist/core/oauth2/federated-login/types.mjs +36 -0
  191. package/dist/core/oauth2/federated-login/types.mjs.map +1 -0
  192. package/dist/core/oauth2/grant-types/authorize.mjs +1 -1
  193. package/dist/core/oauth2/grant-types/client-credentials.mjs +1 -1
  194. package/dist/core/oauth2/grant-types/identity.mjs +1 -1
  195. package/dist/core/oauth2/grant-types/password.mjs +1 -1
  196. package/dist/core/oauth2/grant-types/refresh-token.mjs +1 -1
  197. package/dist/core/oauth2/index.d.ts +1 -0
  198. package/dist/core/oauth2/index.d.ts.map +1 -1
  199. package/dist/core/oauth2/index.mjs +5 -1
  200. package/dist/core/oauth2/token/verifier/module.d.ts.map +1 -1
  201. package/dist/core/oauth2/token/verifier/module.mjs +3 -3
  202. package/dist/core/oauth2/token/verifier/module.mjs.map +1 -1
  203. package/dist/core/provisioning/entities/policy/validator.d.ts.map +1 -1
  204. package/dist/core/provisioning/entities/policy/validator.mjs +2 -1
  205. package/dist/core/provisioning/entities/policy/validator.mjs.map +1 -1
  206. package/dist/core/provisioning/entities/realm/wildcard-validator.d.ts.map +1 -1
  207. package/dist/core/provisioning/entities/realm/wildcard-validator.mjs +2 -1
  208. package/dist/core/provisioning/entities/realm/wildcard-validator.mjs.map +1 -1
  209. package/dist/core/security/policy/evaluator.mjs.map +1 -1
  210. package/dist/node_modules/@ebec/core/dist/index.mjs +130 -0
  211. package/dist/node_modules/@ebec/core/dist/index.mjs.map +1 -0
  212. package/dist/swagger.json +119 -43
  213. package/dist/utils/error.d.ts.map +1 -1
  214. package/dist/utils/error.mjs +5 -6
  215. package/dist/utils/error.mjs.map +1 -1
  216. package/package.json +29 -29
@@ -42,10 +42,19 @@ export interface IEventRepository {
42
42
  /**
43
43
  * Retention sweep: drop every expiring row whose expiresAt lies before
44
44
  * the given instant (non-expiring rows are kept forever). Returns the
45
- * number of removed rows.
45
+ * number of removed rows. Removal is batched (see
46
+ * EVENT_RETENTION_SWEEP_BATCH_SIZE).
46
47
  */
47
- deleteExpired(now: string): Promise<number>;
48
+ deleteExpired(now: string, options?: EventDeleteExpiredOptions): Promise<number>;
48
49
  }
50
+ export type EventDeleteExpiredOptions = {
51
+ /**
52
+ * Rows removed per statement. Defaults to
53
+ * EVENT_RETENTION_SWEEP_BATCH_SIZE, which anything that is not a positive
54
+ * safe integer also falls back to.
55
+ */
56
+ batchSize?: number;
57
+ };
49
58
  export type EventRecordInput = {
50
59
  scope: `${EventScope}`;
51
60
  name: `${EventName}`;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","source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;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAC9B,SAAS,EAAE,GAAG,YAAY,EAAE,GAAG,IAAI,CAAC;IACpC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACpC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,WAAW,aAAa;IAC1B;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;;;OAIG;IACH,OAAO,CACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,KAAK,EAAE,YAAY,EACnB,OAAO,CAAC,EAAE,uBAAuB,GAClC,OAAO,CAAC,8BAA8B,CAAC,KAAK,CAAC,CAAC,CAAC;IAElD;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CAC9F"}
@@ -2,7 +2,15 @@ import type { IdentityProvider, IdentityProviderProtocol } from '@authup/core-ki
2
2
  import type { IEntityRepository } from '@authup/server-kit';
3
3
  export interface IIdentityProviderRepository extends IEntityRepository<IdentityProvider> {
4
4
  checkUniqueness(data: Partial<IdentityProvider>, existing?: IdentityProvider): Promise<void>;
5
- saveWithEA(entity: IdentityProvider, attributes?: Record<string, any>): Promise<IdentityProvider>;
5
+ /**
6
+ * `keepAll` leaves attributes the caller never mentioned in place, which is
7
+ * what a partial update needs: the default replaces the whole set, so an
8
+ * omitted key is deleted. The option is the persistence layer's own, named
9
+ * here structurally so core stays free of the adapter's types.
10
+ */
11
+ saveWithEA(entity: IdentityProvider, attributes?: Record<string, any>, options?: {
12
+ keepAll?: boolean;
13
+ }): Promise<IdentityProvider>;
6
14
  findByProtocol(protocol: IdentityProviderProtocol, realmKey?: string): Promise<IdentityProvider[]>;
7
15
  }
8
16
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/entities/identity-provider/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB,CAAC,gBAAgB,CAAC;IACpF,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAAE,QAAQ,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7F,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAElG,cAAc,CAAC,QAAQ,EAAE,wBAAwB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;CACtG"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/entities/identity-provider/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB,CAAC,gBAAgB,CAAC;IACpF,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAAE,QAAQ,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7F;;;;;OAKG;IACH,UAAU,CACN,MAAM,EAAE,gBAAgB,EACxB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAChC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAE7B,cAAc,CAAC,QAAQ,EAAE,wBAAwB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;CACtG"}
@@ -44,6 +44,12 @@ export interface IIdentityProviderAccountRepository {
44
44
  * Find identity account with user relation (federated login + link flow).
45
45
  */
46
46
  findOneByProviderIdentity(identity: IdentityProviderIdentity): Promise<IdentityProviderAccount | null>;
47
+ /**
48
+ * Throws `EntityConflictError` (`@authup/errors`) when the row violates
49
+ * EITHER unique index, (providerUserId, providerId) or (providerId,
50
+ * userId): the driver does not tell them apart, so the caller
51
+ * classifies by re-reading the identity.
52
+ */
47
53
  save(entity: DeepPartial<IdentityProviderAccount>): Promise<IdentityProviderAccount>;
48
54
  }
49
55
  export type IdentityProviderAccountServiceReadOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/entities/identity-provider-account/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,MA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AAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;IAEjE,MAAM,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvD;;;;;;;;;OASG;IACH,aAAa,CAAC,MAAM,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE7F;;OAEG;IACH,yBAAyB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;IAEvG;;;;;OAKG;IACH,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,uBAAuB,CAAC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACxF;AAED,MAAM,MAAM,yCAAyC,GAAG;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC5C;;;OAGG;IACH,OAAO,CACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,KAAK,EAAE,YAAY,EACnB,OAAO,CAAC,EAAE,yCAAyC,GACpD,OAAO,CAAC,8BAA8B,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAEpE;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,yCAAyC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAE/H;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,yCAAyC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;CAClI"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","names":["IDENTITY_PROVIDER_ACCOUNT_FILTER_KEYS"],"sources":["../../../../src/core/entities/identity-provider-account/types.ts"],"sourcesContent":["/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IdentityProviderAccount } from '@authup/core-kit';\nimport type { IQuery } from '@rapiq/core';\nimport type { ActorContext, EntityRepositoryFindManyResult } from '@authup/server-kit';\nimport type { DeepPartial } from 'typeorm';\nimport type { IdentityProviderIdentity } from '../../identity/provider/types.ts';\n\n/**\n * Filter keys an identity-provider-account list query may target.\n */\nexport const IDENTITY_PROVIDER_ACCOUNT_FILTER_KEYS = [\n 'id',\n 'userId',\n 'providerId',\n 'userRealmId',\n 'providerUserId',\n] as const;\n\nexport type IdentityProviderAccountFindManyOptions = {\n /**\n * Force the result to a single user (self-service). Applied as a\n * mandatory WHERE that a rapiq query filter cannot override.\n */\n userId?: string,\n /**\n * Restrict the result to a single owner realm (the nested\n * `/realms/:realmId/identity-provider-accounts` mount). The owner\n * realm of a row is `userRealmId`.\n */\n realmId?: string,\n};\n\n/**\n * Unified port: the entity CRUD surface (management API) plus the\n * account-manager methods the federated login and link flows consume.\n * One adapter implements both concerns over the same table.\n */\nexport interface IIdentityProviderAccountRepository {\n findMany(query: IQuery, options?: IdentityProviderAccountFindManyOptions): Promise<EntityRepositoryFindManyResult<IdentityProviderAccount>>;\n\n findOneById(id: string): Promise<IdentityProviderAccount | null>;\n\n remove(entity: IdentityProviderAccount): Promise<void>;\n\n /**\n * Atomically remove the account, refusing (returning `false`) when it\n * is the user's LAST linked account and `userHasOtherLogin` is false —\n * the unlink lockout guard. The count and the delete run in one\n * transaction with the user's account rows locked (on drivers that\n * support row locks), so two concurrent unlinks for the same user\n * cannot both pass the guard and strand a password-less user with no\n * login. Fires the entity subscriber like `remove`. Returns `true`\n * when the row was removed.\n */\n removeGuarded(entity: IdentityProviderAccount, userHasOtherLogin: boolean): Promise<boolean>;\n\n /**\n * Find identity account with user relation (federated login + link flow).\n */\n findOneByProviderIdentity(identity: IdentityProviderIdentity): Promise<IdentityProviderAccount | null>;\n\n save(entity: DeepPartial<IdentityProviderAccount>): Promise<IdentityProviderAccount>;\n}\n\nexport type IdentityProviderAccountServiceReadOptions = {\n realmId?: string,\n};\n\nexport interface IIdentityProviderAccountService {\n /**\n * List linked accounts. An actor without\n * `IDENTITY_PROVIDER_ACCOUNT_READ` is scoped to its own rows.\n */\n getMany(\n query: Record<string, any>,\n actor: ActorContext,\n options?: IdentityProviderAccountServiceReadOptions\n ): Promise<EntityRepositoryFindManyResult<IdentityProviderAccount>>;\n\n /**\n * Read a single linked account. Own rows need no permission.\n */\n getOne(id: string, actor: ActorContext, options?: IdentityProviderAccountServiceReadOptions): Promise<IdentityProviderAccount>;\n\n /**\n * Unlink. Own rows need no permission. Refuses for EVERY caller when\n * the row is the user's last linked account and the user has no\n * password (lockout guard).\n */\n delete(id: string, actor: ActorContext, options?: IdentityProviderAccountServiceReadOptions): Promise<IdentityProviderAccount>;\n}\n"],"mappings":";;;;;;GAgBA,MAAaA,wCAAwC;CACjD;CACA;CACA;CACA;CACA;AACH"}
1
+ {"version":3,"file":"types.mjs","names":["IDENTITY_PROVIDER_ACCOUNT_FILTER_KEYS"],"sources":["../../../../src/core/entities/identity-provider-account/types.ts"],"sourcesContent":["/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IdentityProviderAccount } from '@authup/core-kit';\nimport type { IQuery } from '@rapiq/core';\nimport type { ActorContext, EntityRepositoryFindManyResult } from '@authup/server-kit';\nimport type { DeepPartial } from 'typeorm';\nimport type { IdentityProviderIdentity } from '../../identity/provider/types.ts';\n\n/**\n * Filter keys an identity-provider-account list query may target.\n */\nexport const IDENTITY_PROVIDER_ACCOUNT_FILTER_KEYS = [\n 'id',\n 'userId',\n 'providerId',\n 'userRealmId',\n 'providerUserId',\n] as const;\n\nexport type IdentityProviderAccountFindManyOptions = {\n /**\n * Force the result to a single user (self-service). Applied as a\n * mandatory WHERE that a rapiq query filter cannot override.\n */\n userId?: string,\n /**\n * Restrict the result to a single owner realm (the nested\n * `/realms/:realmId/identity-provider-accounts` mount). The owner\n * realm of a row is `userRealmId`.\n */\n realmId?: string,\n};\n\n/**\n * Unified port: the entity CRUD surface (management API) plus the\n * account-manager methods the federated login and link flows consume.\n * One adapter implements both concerns over the same table.\n */\nexport interface IIdentityProviderAccountRepository {\n findMany(query: IQuery, options?: IdentityProviderAccountFindManyOptions): Promise<EntityRepositoryFindManyResult<IdentityProviderAccount>>;\n\n findOneById(id: string): Promise<IdentityProviderAccount | null>;\n\n remove(entity: IdentityProviderAccount): Promise<void>;\n\n /**\n * Atomically remove the account, refusing (returning `false`) when it\n * is the user's LAST linked account and `userHasOtherLogin` is false —\n * the unlink lockout guard. The count and the delete run in one\n * transaction with the user's account rows locked (on drivers that\n * support row locks), so two concurrent unlinks for the same user\n * cannot both pass the guard and strand a password-less user with no\n * login. Fires the entity subscriber like `remove`. Returns `true`\n * when the row was removed.\n */\n removeGuarded(entity: IdentityProviderAccount, userHasOtherLogin: boolean): Promise<boolean>;\n\n /**\n * Find identity account with user relation (federated login + link flow).\n */\n findOneByProviderIdentity(identity: IdentityProviderIdentity): Promise<IdentityProviderAccount | null>;\n\n /**\n * Throws `EntityConflictError` (`@authup/errors`) when the row violates\n * EITHER unique index, (providerUserId, providerId) or (providerId,\n * userId): the driver does not tell them apart, so the caller\n * classifies by re-reading the identity.\n */\n save(entity: DeepPartial<IdentityProviderAccount>): Promise<IdentityProviderAccount>;\n}\n\nexport type IdentityProviderAccountServiceReadOptions = {\n realmId?: string,\n};\n\nexport interface IIdentityProviderAccountService {\n /**\n * List linked accounts. An actor without\n * `IDENTITY_PROVIDER_ACCOUNT_READ` is scoped to its own rows.\n */\n getMany(\n query: Record<string, any>,\n actor: ActorContext,\n options?: IdentityProviderAccountServiceReadOptions\n ): Promise<EntityRepositoryFindManyResult<IdentityProviderAccount>>;\n\n /**\n * Read a single linked account. Own rows need no permission.\n */\n getOne(id: string, actor: ActorContext, options?: IdentityProviderAccountServiceReadOptions): Promise<IdentityProviderAccount>;\n\n /**\n * Unlink. Own rows need no permission. Refuses for EVERY caller when\n * the row is the user's last linked account and the user has no\n * password (lockout guard).\n */\n delete(id: string, actor: ActorContext, options?: IdentityProviderAccountServiceReadOptions): Promise<IdentityProviderAccount>;\n}\n"],"mappings":";;;;;;GAgBA,MAAaA,wCAAwC;CACjD;CACA;CACA;CACA;CACA;AACH"}
@@ -2,7 +2,7 @@ import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
4
  import { CONSENT_FILTER_KEYS, CONSENT_SCOPE_MAX_LENGTH } from "./consent/types.mjs";
5
- import { EVENT_ACTOR_NAME_MAX_LENGTH, EVENT_LOG_RETENTION_DAYS_DEFAULT } from "./event/constants.mjs";
5
+ import { EVENT_ACTOR_NAME_MAX_LENGTH, EVENT_LOG_RETENTION_DAYS_DEFAULT, EVENT_RETENTION_SWEEP_BATCH_SIZE } from "./event/constants.mjs";
6
6
  import { CLIENT_READ_PERMISSIONS } from "./client/constants.mjs";
7
7
  import { clientSchema } from "./client/schema.mjs";
8
8
  import { clientPermissionSchema } from "./client-permission/schema.mjs";
@@ -91,4 +91,4 @@ import { UserRoleService } from "./user-role/service.mjs";
91
91
  import "./user-role/index.mjs";
92
92
  import { IdentityProviderRoleMappingService } from "./identity-provider-role-mapping/service.mjs";
93
93
  import "./identity-provider-role-mapping/index.mjs";
94
- export { CLIENT_READ_PERMISSIONS, CONSENT_FILTER_KEYS, CONSENT_SCOPE_MAX_LENGTH, ClientPermissionService, ClientRoleService, ClientScopeService, ClientService, ConsentService, EVENT_ACTOR_NAME_MAX_LENGTH, EVENT_DIFF_SECRET_KEY_REGEX, EVENT_DIFF_VALUE_MAX_LENGTH, EVENT_LOG_RETENTION_DAYS_DEFAULT, EntityEventHandler, EventService, IDENTITY_PROVIDER_ACCOUNT_FILTER_KEYS, IDENTITY_PROVIDER_ACCOUNT_UNLINK_BLOCKED_ERROR_INSTANCE, IdentityProviderAccountService, IdentityProviderAccountUnlinkBlockedError, IdentityProviderRoleMappingService, KeyService, PermissionPolicyService, PermissionService, PolicyService, RealmService, RoleAttributeService, RolePermissionService, RoleService, SESSION_TOKEN_FILTER_KEYS, SYSTEM_CLIENT_DEFINITIONS, SYSTEM_CLIENT_SCOPE_NAMES, ScopeService, SessionService, SessionTokenService, SystemClientProvisioner, TrustAnchorService, USER_AUTHENTICATOR_ATTEMPT_CACHE_PREFIX, USER_AUTHENTICATOR_ATTEMPT_LOCK_FACTOR, USER_AUTHENTICATOR_ATTEMPT_LOCK_MAX, USER_AUTHENTICATOR_ATTEMPT_WINDOW, USER_AUTHENTICATOR_EMAIL_CODE_CACHE_PREFIX, USER_AUTHENTICATOR_EMAIL_CODE_EXPIRES_IN_MINUTES, USER_AUTHENTICATOR_EMAIL_CODE_LENGTH, USER_AUTHENTICATOR_EMAIL_SEND_CACHE_PREFIX, USER_AUTHENTICATOR_EMAIL_SEND_COOLDOWN, USER_AUTHENTICATOR_FILTER_KEYS, USER_AUTHENTICATOR_RECOVERY_CODE_COUNT, USER_AUTHENTICATOR_THROTTLE_CACHE_PREFIX, USER_AUTHENTICATOR_TOTP_ALGORITHM, USER_AUTHENTICATOR_TOTP_DIGITS, USER_AUTHENTICATOR_TOTP_PERIOD, USER_AUTHENTICATOR_VERIFY_LOCK_CACHE_PREFIX, USER_AUTHENTICATOR_VERIFY_LOCK_RENEW_INTERVAL, USER_AUTHENTICATOR_VERIFY_LOCK_TTL, USER_AUTHENTICATOR_WEBAUTHN_AUTH_CACHE_PREFIX, USER_AUTHENTICATOR_WEBAUTHN_CHALLENGE_WINDOW, USER_AUTHENTICATOR_WEBAUTHN_REG_CACHE_PREFIX, UserAttributeService, UserAuthenticatorService, UserPermissionService, UserRoleService, UserService, buildEntityDiff, buildSystemClientAttributes, buildWebauthnAuthenticationOptions, buildWebauthnRegistrationOptions, clientPermissionSchema, clientRoleSchema, clientSchema, clientScopeSchema, consentSchema, eventSchema, generateNumericCode, generateRecoveryCode, guessUserAuthenticatorKindByResponse, identityProviderAccountSchema, identityProviderRoleMappingSchema, identityProviderSchema, isIdentityProviderAccountUnlinkBlockedError, keySchema, permissionPolicySchema, permissionSchema, policySchema, realmSchema, roleAttributeSchema, rolePermissionSchema, roleSchema, sanitizeEventData, scopeSchema, sessionSchema, sessionTokenSchema, trustAnchorSchema, userAttributeSchema, userAuthenticatorSchema, userPermissionSchema, userRoleSchema, userSchema, verifyWebauthnAuthentication, verifyWebauthnRegistration };
94
+ export { CLIENT_READ_PERMISSIONS, CONSENT_FILTER_KEYS, CONSENT_SCOPE_MAX_LENGTH, ClientPermissionService, ClientRoleService, ClientScopeService, ClientService, ConsentService, EVENT_ACTOR_NAME_MAX_LENGTH, EVENT_DIFF_SECRET_KEY_REGEX, EVENT_DIFF_VALUE_MAX_LENGTH, EVENT_LOG_RETENTION_DAYS_DEFAULT, EVENT_RETENTION_SWEEP_BATCH_SIZE, EntityEventHandler, EventService, IDENTITY_PROVIDER_ACCOUNT_FILTER_KEYS, IDENTITY_PROVIDER_ACCOUNT_UNLINK_BLOCKED_ERROR_INSTANCE, IdentityProviderAccountService, IdentityProviderAccountUnlinkBlockedError, IdentityProviderRoleMappingService, KeyService, PermissionPolicyService, PermissionService, PolicyService, RealmService, RoleAttributeService, RolePermissionService, RoleService, SESSION_TOKEN_FILTER_KEYS, SYSTEM_CLIENT_DEFINITIONS, SYSTEM_CLIENT_SCOPE_NAMES, ScopeService, SessionService, SessionTokenService, SystemClientProvisioner, TrustAnchorService, USER_AUTHENTICATOR_ATTEMPT_CACHE_PREFIX, USER_AUTHENTICATOR_ATTEMPT_LOCK_FACTOR, USER_AUTHENTICATOR_ATTEMPT_LOCK_MAX, USER_AUTHENTICATOR_ATTEMPT_WINDOW, USER_AUTHENTICATOR_EMAIL_CODE_CACHE_PREFIX, USER_AUTHENTICATOR_EMAIL_CODE_EXPIRES_IN_MINUTES, USER_AUTHENTICATOR_EMAIL_CODE_LENGTH, USER_AUTHENTICATOR_EMAIL_SEND_CACHE_PREFIX, USER_AUTHENTICATOR_EMAIL_SEND_COOLDOWN, USER_AUTHENTICATOR_FILTER_KEYS, USER_AUTHENTICATOR_RECOVERY_CODE_COUNT, USER_AUTHENTICATOR_THROTTLE_CACHE_PREFIX, USER_AUTHENTICATOR_TOTP_ALGORITHM, USER_AUTHENTICATOR_TOTP_DIGITS, USER_AUTHENTICATOR_TOTP_PERIOD, USER_AUTHENTICATOR_VERIFY_LOCK_CACHE_PREFIX, USER_AUTHENTICATOR_VERIFY_LOCK_RENEW_INTERVAL, USER_AUTHENTICATOR_VERIFY_LOCK_TTL, USER_AUTHENTICATOR_WEBAUTHN_AUTH_CACHE_PREFIX, USER_AUTHENTICATOR_WEBAUTHN_CHALLENGE_WINDOW, USER_AUTHENTICATOR_WEBAUTHN_REG_CACHE_PREFIX, UserAttributeService, UserAuthenticatorService, UserPermissionService, UserRoleService, UserService, buildEntityDiff, buildSystemClientAttributes, buildWebauthnAuthenticationOptions, buildWebauthnRegistrationOptions, clientPermissionSchema, clientRoleSchema, clientSchema, clientScopeSchema, consentSchema, eventSchema, generateNumericCode, generateRecoveryCode, guessUserAuthenticatorKindByResponse, identityProviderAccountSchema, identityProviderRoleMappingSchema, identityProviderSchema, isIdentityProviderAccountUnlinkBlockedError, keySchema, permissionPolicySchema, permissionSchema, policySchema, realmSchema, roleAttributeSchema, rolePermissionSchema, roleSchema, sanitizeEventData, scopeSchema, sessionSchema, sessionTokenSchema, trustAnchorSchema, userAttributeSchema, userAuthenticatorSchema, userPermissionSchema, userRoleSchema, userSchema, verifyWebauthnAuthentication, verifyWebauthnRegistration };
@@ -8,5 +8,6 @@ export interface IUserIdentityRepository {
8
8
  savePermissions(user: User, items: IdentityProviderMapperElement[]): Promise<void>;
9
9
  saveRoles(user: User, items: IdentityProviderMapperElement[]): Promise<void>;
10
10
  saveOneWithEA(user: Partial<User>, extraAttributes: Record<string, any>): Promise<User>;
11
+ remove(user: User): Promise<void>;
11
12
  }
12
13
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/core/identity/entities/user/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAE7E,MAAM,WAAW,uBAAuB;IACpC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAClE,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAC1E,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAE5D,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,6BAA6B,EAAE,GAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACpF,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,6BAA6B,EAAE,GAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5F"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/core/identity/entities/user/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAE7E,MAAM,WAAW,uBAAuB;IACpC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAClE,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAC1E,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAE5D,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,6BAA6B,EAAE,GAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACpF,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,6BAA6B,EAAE,GAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzF,MAAM,CAAC,IAAI,EAAE,IAAI,GAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC"}
@@ -3,6 +3,17 @@ import "node:url";
3
3
  import.meta.url;
4
4
  import { applyJunctionCreateGrant, buildJunctionUpdateData } from "./permission/junction-grant.mjs";
5
5
  import { toIdentityPolicyData } from "./permission/identity-policy-data.mjs";
6
+ import { IdentityProviderLdapAuthenticator } from "./provider/authentication/protocols/ldap/module.mjs";
7
+ import { IdentityProviderLdapCollectionAuthenticator } from "./provider/authentication/protocols/ldap/collection.mjs";
8
+ import { IDENTITY_PROVIDER_ASSURANCE_ERROR_INSTANCE, IdentityProviderAssuranceError, assertIdentityProviderAssurance, buildIdentityProviderAcrValues, isIdentityProviderAssuranceError } from "./provider/authentication/protocols/oauth2/assurance.mjs";
9
+ import { IdentityProviderOAuth2Authenticator } from "./provider/authentication/protocols/oauth2/module.mjs";
10
+ import { IdentityProviderOpenIDAuthenticator } from "./provider/authentication/protocols/open-id/module.mjs";
11
+ import { IdentityProviderFacebookAuthenticator } from "./provider/authentication/presets/facebook.mjs";
12
+ import { IdentityProviderGithubAuthenticator } from "./provider/authentication/presets/github.mjs";
13
+ import { IdentityProviderGoogleAuthenticator } from "./provider/authentication/presets/google.mjs";
14
+ import { IdentityProviderInstagramAuthenticator } from "./provider/authentication/presets/instagram.mjs";
15
+ import { IdentityProviderPaypalAuthenticator } from "./provider/authentication/presets/paypal.mjs";
16
+ import { createIdentityProviderOAuth2Authenticator } from "./provider/authentication/factory.mjs";
6
17
  import { PASSWORD_RESET_EXPIRES_IN_MINUTES } from "./password-recovery/constants.mjs";
7
18
  import { PasswordRecoveryService } from "./password-recovery/service.mjs";
8
19
  import "./password-recovery/index.mjs";
@@ -19,21 +30,11 @@ import { IdentityProviderAttributeMapper } from "./provider/mapper/attributes/mo
19
30
  import { IdentityProviderRoleMapper } from "./provider/mapper/role/module.mjs";
20
31
  import { IdentityProviderPermissionMapper } from "./provider/mapper/permission/module.mjs";
21
32
  import { IdentityProviderAccountManager } from "./provider/account/module.mjs";
22
- import { IdentityProviderLdapAuthenticator } from "./provider/authentication/protocols/ldap/module.mjs";
23
- import { IdentityProviderLdapCollectionAuthenticator } from "./provider/authentication/protocols/ldap/collection.mjs";
24
- import { IdentityProviderOAuth2Authenticator } from "./provider/authentication/protocols/oauth2/module.mjs";
25
- import { IdentityProviderOpenIDAuthenticator } from "./provider/authentication/protocols/open-id/module.mjs";
26
- import { IdentityProviderFacebookAuthenticator } from "./provider/authentication/presets/facebook.mjs";
27
- import { IdentityProviderGithubAuthenticator } from "./provider/authentication/presets/github.mjs";
28
- import { IdentityProviderGoogleAuthenticator } from "./provider/authentication/presets/google.mjs";
29
- import { IdentityProviderInstagramAuthenticator } from "./provider/authentication/presets/instagram.mjs";
30
- import { IdentityProviderPaypalAuthenticator } from "./provider/authentication/presets/paypal.mjs";
31
33
  import { IDENTITY_PROVIDER_LDAP_COLLECTION_AUTHENTICATOR_TOKEN } from "./provider/authentication/constants.mjs";
32
- import { createIdentityProviderOAuth2Authenticator } from "./provider/authentication/factory.mjs";
33
34
  import "./provider/index.mjs";
34
35
  import { RegistrationService } from "./registration/service.mjs";
35
36
  import "./registration/index.mjs";
36
37
  import { IdentityResolver } from "./resolver/module.mjs";
37
38
  import "./resolver/index.mjs";
38
39
  import { IdentityRoleProvider } from "./role/module.mjs";
39
- export { IDENTITY_PROVIDER_ACCOUNT_ALREADY_LINKED_ERROR_INSTANCE, IDENTITY_PROVIDER_ACCOUNT_LINK_TTL, IDENTITY_PROVIDER_LDAP_COLLECTION_AUTHENTICATOR_TOKEN, IdentityPermissionProvider, IdentityProviderAccountAlreadyLinkedError, IdentityProviderAccountBaseMapper, IdentityProviderAccountManager, IdentityProviderAttributeMapper, IdentityProviderFacebookAuthenticator, IdentityProviderGithubAuthenticator, IdentityProviderGoogleAuthenticator, IdentityProviderInstagramAuthenticator, IdentityProviderLdapAuthenticator, IdentityProviderLdapCollectionAuthenticator, IdentityProviderMapperOperation, IdentityProviderOAuth2Authenticator, IdentityProviderOpenIDAuthenticator, IdentityProviderPaypalAuthenticator, IdentityProviderPermissionMapper, IdentityProviderRoleMapper, IdentityResolver, IdentityRoleProvider, PASSWORD_RESET_EXPIRES_IN_MINUTES, PasswordRecoveryService, PermissionCheckerService, PolicyCheckerService, RegistrationService, applyJunctionCreateGrant, buildJunctionUpdateData, createIdentityProviderOAuth2Authenticator, isIdentityProviderAccountAlreadyLinkedError, toIdentityPolicyData };
40
+ export { IDENTITY_PROVIDER_ACCOUNT_ALREADY_LINKED_ERROR_INSTANCE, IDENTITY_PROVIDER_ACCOUNT_LINK_TTL, IDENTITY_PROVIDER_ASSURANCE_ERROR_INSTANCE, IDENTITY_PROVIDER_LDAP_COLLECTION_AUTHENTICATOR_TOKEN, IdentityPermissionProvider, IdentityProviderAccountAlreadyLinkedError, IdentityProviderAccountBaseMapper, IdentityProviderAccountManager, IdentityProviderAssuranceError, IdentityProviderAttributeMapper, IdentityProviderFacebookAuthenticator, IdentityProviderGithubAuthenticator, IdentityProviderGoogleAuthenticator, IdentityProviderInstagramAuthenticator, IdentityProviderLdapAuthenticator, IdentityProviderLdapCollectionAuthenticator, IdentityProviderMapperOperation, IdentityProviderOAuth2Authenticator, IdentityProviderOpenIDAuthenticator, IdentityProviderPaypalAuthenticator, IdentityProviderPermissionMapper, IdentityProviderRoleMapper, IdentityResolver, IdentityRoleProvider, PASSWORD_RESET_EXPIRES_IN_MINUTES, PasswordRecoveryService, PermissionCheckerService, PolicyCheckerService, RegistrationService, applyJunctionCreateGrant, assertIdentityProviderAssurance, buildIdentityProviderAcrValues, buildJunctionUpdateData, createIdentityProviderOAuth2Authenticator, isIdentityProviderAccountAlreadyLinkedError, isIdentityProviderAssuranceError, toIdentityPolicyData };
@@ -1,5 +1,6 @@
1
1
  import type { IdentityProviderAccount, User } from '@authup/core-kit';
2
2
  import { UserValidator } from '@authup/core-kit';
3
+ import type { Logger } from '@authup/server-kit';
3
4
  import type { IUserIdentityRepository } from '../../entities/index.ts';
4
5
  import type { IIdentityProviderMapper } from '../mapper/index.ts';
5
6
  import type { IdentityProviderIdentity } from '../types.ts';
@@ -11,8 +12,10 @@ export declare class IdentityProviderAccountManager implements IIdentityProvider
11
12
  protected repository: IIdentityProviderAccountRepository;
12
13
  protected userRepository: IUserIdentityRepository;
13
14
  protected userValidator: UserValidator;
15
+ protected logger?: Logger;
14
16
  constructor(ctx: IdentityProviderAccountManagerContext);
15
17
  save(identity: IdentityProviderIdentity): Promise<IdentityProviderAccount>;
18
+ protected update(identity: IdentityProviderIdentity, account: IdentityProviderAccount): Promise<IdentityProviderAccount>;
16
19
  link(identity: IdentityProviderIdentity, userId: string): Promise<IdentityProviderAccount>;
17
20
  protected pickCandidate(identity: IdentityProviderIdentity, key: keyof User, maxLength: number): string | null;
18
21
  saveUser(identity: IdentityProviderIdentity, user?: User): Promise<User>;
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../src/core/identity/provider/account/module.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACH,aAAa,EAGhB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,KAAK,EAAE,+BAA+B,EAAE,kCAAkC,EAAE,qCAAqC,EAAE,MAAM,YAAY,CAAC;AAE7I,qBAAa,8BAA+B,YAAW,+BAA+B;IAClF,SAAS,CAAC,gBAAgB,EAAG,uBAAuB,CAAC;IAErD,SAAS,CAAC,gBAAgB,EAAG,uBAAuB,CAAC;IAErD,SAAS,CAAC,UAAU,EAAG,uBAAuB,CAAC;IAE/C,SAAS,CAAC,UAAU,EAAG,kCAAkC,CAAC;IAE1D,SAAS,CAAC,cAAc,EAAE,uBAAuB,CAAC;IAElD,SAAS,CAAC,aAAa,EAAG,aAAa,CAAC;gBAE5B,GAAG,EAAE,qCAAqC;IAUhD,IAAI,CAAC,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAmC1E,IAAI,CAAC,QAAQ,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAuChG,SAAS,CAAC,aAAa,CACnB,QAAQ,EAAE,wBAAwB,EAClC,GAAG,EAAE,MAAM,IAAI,EACf,SAAS,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IAElD,SAAS,CAAC,aAAa,EAAG,aAAa,CAAC;IAExC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEd,GAAG,EAAE,qCAAqC;IAWhD,IAAI,CAAC,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;cAsDhE,MAAM,CAClB,QAAQ,EAAE,wBAAwB,EAClC,OAAO,EAAE,uBAAuB,GACjC,OAAO,CAAC,uBAAuB,CAAC;IAa7B,IAAI,CAAC,QAAQ,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IA6DhG,SAAS,CAAC,aAAa,CACnB,QAAQ,EAAE,wBAAwB,EAClC,GAAG,EAAE,MAAM,IAAI,EACf,SAAS,EAAE,MAAM,GAClB,MAAM,GAAG,IAAI;IAWV,QAAQ,CACV,QAAQ,EAAE,wBAAwB,EAClC,IAAI,CAAC,EAAE,IAAI,GACZ,OAAO,CAAC,IAAI,CAAC;IA0FV,kBAAkB,CACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,QAAQ,EAAE,wBAAwB,EAClC,QAAQ,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IA+ElB,eAAe,CACjB,QAAQ,EAAE,wBAAwB,EAClC,IAAI,EAAE,IAAI;IAOR,SAAS,CACX,QAAQ,EAAE,wBAAwB,EAClC,IAAI,EAAE,IAAI;CAMjB"}
@@ -1,13 +1,15 @@
1
1
  import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
+ import { describeError } from "../../../../utils/error.mjs";
5
+ import "../../../../utils/index.mjs";
4
6
  import { IdentityProviderAccountAlreadyLinkedError } from "./error.mjs";
5
7
  import { IdentityProviderIdentityOperation } from "../constants.mjs";
6
8
  import { IdentityProviderMapperOperation } from "../mapper/constants.mjs";
7
9
  import "../mapper/index.mjs";
8
10
  import { ValidatorGroup, createNanoID, extendObject } from "@authup/kit";
9
11
  import { UserValidator, buildUserFakeEmail, isUserFakeEmail } from "@authup/core-kit";
10
- import { ValidationError } from "@authup/errors";
12
+ import { ValidationError, isEntityConflictError } from "@authup/errors";
11
13
  import { isValidupError, stringifyPath } from "validup";
12
14
  //#region src/core/identity/provider/account/module.ts
13
15
  var IdentityProviderAccountManager = class {
@@ -17,35 +19,50 @@ var IdentityProviderAccountManager = class {
17
19
  repository;
18
20
  userRepository;
19
21
  userValidator;
22
+ logger;
20
23
  constructor(ctx) {
21
24
  this.attributesMapper = ctx.attributeMapper;
22
25
  this.permissionMapper = ctx.permissionMapper;
23
26
  this.roleMapper = ctx.roleMapper;
24
27
  this.repository = ctx.repository;
25
28
  this.userRepository = ctx.userRepository;
29
+ this.logger = ctx.logger;
26
30
  this.userValidator = new UserValidator();
27
31
  }
28
32
  async save(identity) {
29
33
  let account = await this.repository.findOneByProviderIdentity(identity);
30
- if (account) {
31
- identity.operation = IdentityProviderIdentityOperation.UPDATE;
32
- account.user = await this.saveUser(identity, account.user);
33
- await this.repository.save(account);
34
- await this.saveRoles(identity, account.user);
35
- await this.savePermissions(identity, account.user);
36
- return account;
37
- }
34
+ if (account) return this.update(identity, account);
38
35
  identity.operation = IdentityProviderIdentityOperation.CREATE;
39
36
  const user = await this.saveUser(identity);
40
- account = await this.repository.save({
41
- providerId: identity.provider.id,
42
- providerUserId: identity.id,
43
- providerUserName: user.name,
44
- providerRealmId: identity.provider.realmId,
45
- user,
46
- userId: user.id,
47
- userRealmId: user.realmId
48
- });
37
+ try {
38
+ account = await this.repository.save({
39
+ providerId: identity.provider.id,
40
+ providerUserId: identity.id,
41
+ providerUserName: user.name,
42
+ providerRealmId: identity.provider.realmId,
43
+ user,
44
+ userId: user.id,
45
+ userRealmId: user.realmId
46
+ });
47
+ } catch (e) {
48
+ if (!isEntityConflictError(e)) throw e;
49
+ const raced = await this.repository.findOneByProviderIdentity(identity);
50
+ if (!raced) throw e;
51
+ try {
52
+ await this.userRepository.remove(user);
53
+ } catch (removeError) {
54
+ this.logger?.warn(describeError(removeError, `The user provisioned for the external identity "${identity.id}" could not be removed after losing a concurrent first login.`));
55
+ }
56
+ return this.update(identity, raced);
57
+ }
58
+ await this.saveRoles(identity, account.user);
59
+ await this.savePermissions(identity, account.user);
60
+ return account;
61
+ }
62
+ async update(identity, account) {
63
+ identity.operation = IdentityProviderIdentityOperation.UPDATE;
64
+ account.user = await this.saveUser(identity, account.user);
65
+ await this.repository.save(account);
49
66
  await this.saveRoles(identity, account.user);
50
67
  await this.savePermissions(identity, account.user);
51
68
  return account;
@@ -63,15 +80,25 @@ var IdentityProviderAccountManager = class {
63
80
  existing.providerUserEmail = providerUserEmail ?? existing.providerUserEmail;
64
81
  return this.repository.save(existing);
65
82
  }
66
- return this.repository.save({
67
- providerId: identity.provider.id,
68
- providerUserId: identity.id,
69
- providerUserName,
70
- providerUserEmail: providerUserEmail ?? void 0,
71
- providerRealmId: identity.provider.realmId,
72
- userId,
73
- userRealmId: user.realmId ?? null
74
- });
83
+ try {
84
+ return await this.repository.save({
85
+ providerId: identity.provider.id,
86
+ providerUserId: identity.id,
87
+ providerUserName,
88
+ providerUserEmail: providerUserEmail ?? void 0,
89
+ providerRealmId: identity.provider.realmId,
90
+ userId,
91
+ userRealmId: user.realmId ?? null
92
+ });
93
+ } catch (e) {
94
+ if (!isEntityConflictError(e)) throw e;
95
+ const raced = await this.repository.findOneByProviderIdentity(identity);
96
+ if (raced) {
97
+ if (raced.userId === userId) return raced;
98
+ throw new IdentityProviderAccountAlreadyLinkedError();
99
+ }
100
+ throw new ValidationError("The user is already linked to this identity provider through another account.");
101
+ }
75
102
  }
76
103
  pickCandidate(identity, key, maxLength) {
77
104
  const candidates = identity.attributeCandidates?.[key] || [];
@@ -1 +1 @@
1
- {"version":3,"file":"module.mjs","names":["UserValidator","buildUserFakeEmail","isUserFakeEmail","ValidatorGroup","createNanoID","extendObject","ValidationError","isValidupError","stringifyPath","IdentityProviderIdentityOperation","IdentityProviderMapperOperation","IdentityProviderAccountAlreadyLinkedError","IdentityProviderAccountManager","attributesMapper","permissionMapper","roleMapper","repository","userRepository","userValidator","ctx","attributeMapper","save","identity","account","findOneByProviderIdentity","operation","UPDATE","user","saveUser","saveRoles","savePermissions","CREATE","providerId","provider","id","providerUserId","providerUserName","name","providerRealmId","realmId","userId","userRealmId","link","findOneById","pickCandidate","slice","providerUserEmail","existing","undefined","key","maxLength","candidates","attributeCandidates","candidate","length","attributes","execute","entity","attribute","value","active","nameLocked","clientId","attributesSelf","validateAttributes","Error","attributesSelfKeys","Object","keys","attributesExtra","entityKeys","entityKey","index","indexOf","output","trim","toLowerCase","attempts","Math","max","saveOneWithEA","names","shift","run","group","email","e","retry","i","issues","child","pathNormalized","path","Array","isArray","first","rest","push","entities"],"sources":["../../../../../src/core/identity/provider/account/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IdentityProviderAccount, User } from '@authup/core-kit';\nimport {\n UserValidator,\n buildUserFakeEmail,\n isUserFakeEmail,\n} from '@authup/core-kit';\nimport { ValidatorGroup, createNanoID, extendObject } from '@authup/kit';\nimport { ValidationError } from '@authup/errors';\nimport { isValidupError, stringifyPath } from 'validup';\nimport type { IUserIdentityRepository } from '../../entities/index.ts';\nimport { IdentityProviderIdentityOperation } from '../constants.ts';\nimport type { IIdentityProviderMapper } from '../mapper/index.ts';\nimport { IdentityProviderMapperOperation } from '../mapper/index.ts';\nimport type { IdentityProviderIdentity } from '../types.ts';\nimport { IdentityProviderAccountAlreadyLinkedError } from './error.ts';\nimport type { IIdentityProviderAccountManager, IIdentityProviderAccountRepository, IdentityProviderAccountManagerContext } from './types.ts';\n\nexport class IdentityProviderAccountManager implements IIdentityProviderAccountManager {\n protected attributesMapper : IIdentityProviderMapper;\n\n protected permissionMapper : IIdentityProviderMapper;\n\n protected roleMapper : IIdentityProviderMapper;\n\n protected repository : IIdentityProviderAccountRepository;\n\n protected userRepository: IUserIdentityRepository;\n\n protected userValidator : UserValidator;\n\n constructor(ctx: IdentityProviderAccountManagerContext) {\n this.attributesMapper = ctx.attributeMapper;\n this.permissionMapper = ctx.permissionMapper;\n this.roleMapper = ctx.roleMapper;\n this.repository = ctx.repository;\n this.userRepository = ctx.userRepository;\n\n this.userValidator = new UserValidator();\n }\n\n async save(identity: IdentityProviderIdentity): Promise<IdentityProviderAccount> {\n let account = await this.repository.findOneByProviderIdentity(identity);\n if (account) {\n identity.operation = IdentityProviderIdentityOperation.UPDATE;\n\n account.user = await this.saveUser(identity, account.user);\n\n await this.repository.save(account);\n\n await this.saveRoles(identity, account.user);\n await this.savePermissions(identity, account.user);\n\n return account;\n }\n\n identity.operation = IdentityProviderIdentityOperation.CREATE;\n\n const user = await this.saveUser(identity);\n\n account = await this.repository.save({\n providerId: identity.provider.id,\n providerUserId: identity.id,\n providerUserName: user.name, // todo: parse identity.name\n providerRealmId: identity.provider.realmId,\n user,\n userId: user.id,\n userRealmId: user.realmId,\n });\n\n await this.saveRoles(identity, account.user);\n await this.savePermissions(identity, account.user);\n\n return account;\n }\n\n async link(identity: IdentityProviderIdentity, userId: string): Promise<IdentityProviderAccount> {\n const user = await this.userRepository.findOneById(userId);\n if (!user) {\n throw new ValidationError('The linking user does not exist.');\n }\n\n if (\n identity.provider.realmId &&\n user.realmId !== identity.provider.realmId\n ) {\n throw new ValidationError('The provider and user realm do not match.');\n }\n\n const providerUserName = this.pickCandidate(identity, 'name', 256) ?? identity.id.slice(0, 256);\n const providerUserEmail = this.pickCandidate(identity, 'email', 512);\n\n const existing = await this.repository.findOneByProviderIdentity(identity);\n if (existing) {\n if (existing.userId !== userId) {\n throw new IdentityProviderAccountAlreadyLinkedError();\n }\n\n existing.providerUserName = providerUserName ?? existing.providerUserName;\n existing.providerUserEmail = providerUserEmail ?? existing.providerUserEmail;\n\n return this.repository.save(existing);\n }\n\n return this.repository.save({\n providerId: identity.provider.id,\n providerUserId: identity.id,\n providerUserName,\n providerUserEmail: providerUserEmail ?? undefined,\n providerRealmId: identity.provider.realmId,\n userId,\n userRealmId: user.realmId ?? null,\n });\n }\n\n protected pickCandidate(\n identity: IdentityProviderIdentity,\n key: keyof User,\n maxLength: number,\n ): string | null {\n const candidates = identity.attributeCandidates?.[key] || [];\n for (const candidate of candidates) {\n if (typeof candidate === 'string' && candidate.length > 0) {\n return candidate.slice(0, maxLength);\n }\n }\n\n return null;\n }\n\n async saveUser(\n identity: IdentityProviderIdentity,\n user?: User,\n ): Promise<User> {\n const attributes = await this.attributesMapper.execute(\n identity,\n );\n\n const entity : Record<string, any> = {};\n for (const attribute of attributes) {\n if (\n attribute.key &&\n attribute.operation === IdentityProviderMapperOperation.CREATE\n ) {\n // attribute value might be object, array, ...\n entity[attribute.key] = attribute.value;\n }\n }\n\n if (!user) {\n entity.realmId = identity.provider.realmId;\n entity.active = true;\n entity.nameLocked = true;\n entity.clientId = identity.clientId || null;\n }\n\n const attributesSelf = await this.validateAttributes(entity, identity, 10);\n if (!attributesSelf) {\n // todo: better error name\n throw new Error('Identity provider attributes could not be validated.');\n }\n const attributesSelfKeys = Object.keys(attributesSelf);\n\n const attributesExtra : Record<string, any> = {};\n\n const entityKeys = Object.keys(entity);\n for (const entityKey of entityKeys) {\n const index = attributesSelfKeys.indexOf(entityKey);\n if (index !== -1) {\n continue;\n }\n\n attributesExtra[entityKey] = entity[entityKey];\n }\n\n let output : User;\n if (user) {\n output = extendObject(user, attributesSelf);\n } else {\n output = attributesSelf;\n }\n\n if (typeof output.name === 'string') {\n output.name = output.name.trim().toLowerCase();\n }\n\n let attempts = Math.max((identity.attributeCandidates?.name?.length || 0) + 1, 10);\n while (attempts > 0) {\n try {\n // todo: we also need to remove existing ones via idp login flow ( but not other attributes!)\n return await this.userRepository.saveOneWithEA(output, attributesExtra);\n } catch {\n const names = identity.attributeCandidates?.name || [];\n if (names.length > 0) {\n while (names.length > 0) {\n output.name = `${names.shift()}`.trim().toLowerCase();\n\n try {\n await this.userValidator.run(output, {\n group: identity.operation === IdentityProviderIdentityOperation.CREATE ?\n ValidatorGroup.CREATE :\n ValidatorGroup.UPDATE,\n });\n break;\n } catch {\n // todo: do nothing.\n }\n }\n } else {\n output.name = createNanoID('0123456789abcdefghijklmnopqrstuvwxyz-_', 10);\n }\n\n if (isUserFakeEmail(output.email)) {\n output.email = buildUserFakeEmail(output.name);\n }\n\n attempts -= 1;\n }\n }\n\n throw new Error('The user account could not be created due a conflict error.');\n }\n\n async validateAttributes(\n entity: Record<string, any>,\n identity: IdentityProviderIdentity,\n attempts: number,\n ) : Promise<User | null> {\n attempts--;\n if (attempts <= 0) {\n return null;\n }\n\n try {\n return await this.userValidator.run(entity, {\n group: identity.operation === IdentityProviderIdentityOperation.CREATE ?\n ValidatorGroup.CREATE :\n ValidatorGroup.UPDATE,\n });\n } catch (e: any) {\n if (!isValidupError(e)) {\n return null;\n }\n\n let retry = false;\n for (let i = 0; i < e.issues.length; i++) {\n const child = e.issues[i];\n\n const pathNormalized = stringifyPath(child.path);\n\n if (\n Array.isArray(entity[pathNormalized]) &&\n entity[pathNormalized].length > 0\n ) {\n const [first, ...rest] = entity[pathNormalized];\n entity[pathNormalized] = first;\n\n if (rest.length > 0) {\n if (!identity.attributeCandidates) {\n identity.attributeCandidates = {};\n }\n\n if (!identity.attributeCandidates[pathNormalized]) {\n identity.attributeCandidates[pathNormalized] = [];\n }\n\n identity.attributeCandidates[pathNormalized]!.push(...rest);\n }\n\n retry = true;\n break;\n }\n\n if (\n identity.attributeCandidates &&\n identity.attributeCandidates[pathNormalized] &&\n identity.attributeCandidates[pathNormalized]!.length > 0\n ) {\n entity[pathNormalized] = identity.attributeCandidates[pathNormalized]!.shift();\n retry = true;\n break;\n }\n\n if (\n entity.name &&\n pathNormalized === 'email'\n ) {\n entity[pathNormalized] = buildUserFakeEmail(entity.name);\n retry = true;\n break;\n }\n\n if (entity[pathNormalized]) {\n entity[pathNormalized] = null;\n break;\n }\n }\n\n if (retry) {\n return this.validateAttributes(entity, identity, attempts);\n }\n\n return null;\n }\n }\n\n async savePermissions(\n identity: IdentityProviderIdentity,\n user: User,\n ) {\n const entities = await this.permissionMapper.execute(identity);\n\n await this.userRepository.savePermissions(user, entities);\n }\n\n async saveRoles(\n identity: IdentityProviderIdentity,\n user: User,\n ) {\n const entities = await this.roleMapper.execute(identity);\n\n await this.userRepository.saveRoles(user, entities);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAwBA,IAAaY,iCAAb,MAAaA;CACCC;CAEAC;CAEAC;CAEAC;CAEAC;CAEAC;CAEV,YAAYC,KAA4C;EACpD,KAAKN,mBAAmBM,IAAIC;EAC5B,KAAKN,mBAAmBK,IAAIL;EAC5B,KAAKC,aAAaI,IAAIJ;EACtB,KAAKC,aAAaG,IAAIH;EACtB,KAAKC,iBAAiBE,IAAIF;EAE1B,KAAKC,gBAAgB,IAAIlB,cAAAA;CAC7B;CAEA,MAAMqB,KAAKC,UAAsE;EAC7E,IAAIC,UAAU,MAAM,KAAKP,WAAWQ,0BAA0BF,QAAAA;EAC9D,IAAIC,SAAS;GACTD,SAASG,YAAYhB,kCAAkCiB;GAEvDH,QAAQI,OAAO,MAAM,KAAKC,SAASN,UAAUC,QAAQI,IAAI;GAEzD,MAAM,KAAKX,WAAWK,KAAKE,OAAAA;GAE3B,MAAM,KAAKM,UAAUP,UAAUC,QAAQI,IAAI;GAC3C,MAAM,KAAKG,gBAAgBR,UAAUC,QAAQI,IAAI;GAEjD,OAAOJ;EACX;EAEAD,SAASG,YAAYhB,kCAAkCsB;EAEvD,MAAMJ,OAAO,MAAM,KAAKC,SAASN,QAAAA;EAEjCC,UAAU,MAAM,KAAKP,WAAWK,KAAK;GACjCW,YAAYV,SAASW,SAASC;GAC9BC,gBAAgBb,SAASY;GACzBE,kBAAkBT,KAAKU;GACvBC,iBAAiBhB,SAASW,SAASM;GACnCZ;GACAa,QAAQb,KAAKO;GACbO,aAAad,KAAKY;EACtB,CAAA;E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BuC,eAAe,CAAEM,KAAI,GAAID,IAAAA;KAC1D;KAEAT,QAAQ;KACR;IACJ;IAEA,IACIjE,SAAS8B,uBACT9B,SAAS8B,oBAAoBuC,mBAC7BrE,SAAS8B,oBAAoBuC,eAAe,CAAErC,SAAS,GACzD;KACEG,OAAOkC,kBAAkBrE,SAAS8B,oBAAoBuC,eAAe,CAAET,MAAK;KAC5EK,QAAQ;KACR;IACJ;IAEA,IACI9B,OAAOpB,QACPsD,mBAAmB,SACrB;KACElC,OAAOkC,kBAAkB1F,mBAAmBwD,OAAOpB,IAAI;KACvDkD,QAAQ;KACR;IACJ;IAEA,IAAI9B,OAAOkC,iBAAiB;KACxBlC,OAAOkC,kBAAkB;KACzB;IACJ;GACJ;GAEA,IAAIJ,OACA,OAAO,KAAKvB,mBAAmBP,QAAQnC,UAAUuD,QAAAA;GAGrD,OAAO;EACX;CACJ;CAEA,MAAM/C,gBACFR,UACAK,MACF;EACE,MAAMuE,WAAW,MAAM,KAAKpF,iBAAiB0C,QAAQlC,QAAAA;EAErD,MAAM,KAAKL,eAAea,gBAAgBH,MAAMuE,QAAAA;CACpD;CAEA,MAAMrE,UACFP,UACAK,MACF;EACE,MAAMuE,WAAW,MAAM,KAAKnF,WAAWyC,QAAQlC,QAAAA;EAE/C,MAAM,KAAKL,eAAeY,UAAUF,MAAMuE,QAAAA;CAC9C;AACJ"}
1
+ {"version":3,"file":"module.mjs","names":["UserValidator","buildUserFakeEmail","isUserFakeEmail","ValidatorGroup","createNanoID","extendObject","ValidationError","isEntityConflictError","isValidupError","stringifyPath","describeError","IdentityProviderIdentityOperation","IdentityProviderMapperOperation","IdentityProviderAccountAlreadyLinkedError","IdentityProviderAccountManager","attributesMapper","permissionMapper","roleMapper","repository","userRepository","userValidator","logger","ctx","attributeMapper","save","identity","account","findOneByProviderIdentity","update","operation","CREATE","user","saveUser","providerId","provider","id","providerUserId","providerUserName","name","providerRealmId","realmId","userId","userRealmId","e","raced","remove","removeError","warn","saveRoles","savePermissions","UPDATE","link","findOneById","pickCandidate","slice","providerUserEmail","existing","undefined","key","maxLength","candidates","attributeCandidates","candidate","length","attributes","execute","entity","attribute","value","active","nameLocked","clientId","attributesSelf","validateAttributes","Error","attributesSelfKeys","Object","keys","attributesExtra","entityKeys","entityKey","index","indexOf","output","trim","toLowerCase","attempts","Math","max","saveOneWithEA","names","shift","run","group","email","retry","i","issues","child","pathNormalized","path","Array","isArray","first","rest","push","entities"],"sources":["../../../../../src/core/identity/provider/account/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IdentityProviderAccount, User } from '@authup/core-kit';\nimport {\n UserValidator,\n buildUserFakeEmail,\n isUserFakeEmail,\n} from '@authup/core-kit';\nimport { ValidatorGroup, createNanoID, extendObject } from '@authup/kit';\nimport { ValidationError, isEntityConflictError } from '@authup/errors';\nimport { isValidupError, stringifyPath } from 'validup';\nimport type { Logger } from '@authup/server-kit';\nimport { describeError } from '../../../../utils/index.ts';\nimport type { IUserIdentityRepository } from '../../entities/index.ts';\nimport { IdentityProviderIdentityOperation } from '../constants.ts';\nimport type { IIdentityProviderMapper } from '../mapper/index.ts';\nimport { IdentityProviderMapperOperation } from '../mapper/index.ts';\nimport type { IdentityProviderIdentity } from '../types.ts';\nimport { IdentityProviderAccountAlreadyLinkedError } from './error.ts';\nimport type { IIdentityProviderAccountManager, IIdentityProviderAccountRepository, IdentityProviderAccountManagerContext } from './types.ts';\n\nexport class IdentityProviderAccountManager implements IIdentityProviderAccountManager {\n protected attributesMapper : IIdentityProviderMapper;\n\n protected permissionMapper : IIdentityProviderMapper;\n\n protected roleMapper : IIdentityProviderMapper;\n\n protected repository : IIdentityProviderAccountRepository;\n\n protected userRepository: IUserIdentityRepository;\n\n protected userValidator : UserValidator;\n\n protected logger?: Logger;\n\n constructor(ctx: IdentityProviderAccountManagerContext) {\n this.attributesMapper = ctx.attributeMapper;\n this.permissionMapper = ctx.permissionMapper;\n this.roleMapper = ctx.roleMapper;\n this.repository = ctx.repository;\n this.userRepository = ctx.userRepository;\n this.logger = ctx.logger;\n\n this.userValidator = new UserValidator();\n }\n\n async save(identity: IdentityProviderIdentity): Promise<IdentityProviderAccount> {\n let account = await this.repository.findOneByProviderIdentity(identity);\n if (account) {\n return this.update(identity, account);\n }\n\n identity.operation = IdentityProviderIdentityOperation.CREATE;\n\n const user = await this.saveUser(identity);\n\n try {\n account = await this.repository.save({\n providerId: identity.provider.id,\n providerUserId: identity.id,\n providerUserName: user.name, // todo: parse identity.name\n providerRealmId: identity.provider.realmId,\n user,\n userId: user.id,\n userRealmId: user.realmId,\n });\n } catch (e) {\n if (!isEntityConflictError(e)) {\n throw e;\n }\n\n // the loser of two concurrent first logins: the identity is linked\n // now, so continue with the winner's account and drop the user\n // this request provisioned moments ago (unreferenced; best effort,\n // a leftover row must not fail the login).\n const raced = await this.repository.findOneByProviderIdentity(identity);\n if (!raced) {\n throw e;\n }\n\n try {\n await this.userRepository.remove(user);\n } catch (removeError) {\n // The row is unreferenced, so it costs nothing but a squatted\n // user name. Left unreported it would be invisible forever.\n this.logger?.warn(describeError(\n removeError,\n `The user provisioned for the external identity \"${identity.id}\" could not be removed after losing a concurrent first login.`,\n ));\n }\n\n return this.update(identity, raced);\n }\n\n await this.saveRoles(identity, account.user);\n await this.savePermissions(identity, account.user);\n\n return account;\n }\n\n protected async update(\n identity: IdentityProviderIdentity,\n account: IdentityProviderAccount,\n ): Promise<IdentityProviderAccount> {\n identity.operation = IdentityProviderIdentityOperation.UPDATE;\n\n account.user = await this.saveUser(identity, account.user);\n\n await this.repository.save(account);\n\n await this.saveRoles(identity, account.user);\n await this.savePermissions(identity, account.user);\n\n return account;\n }\n\n async link(identity: IdentityProviderIdentity, userId: string): Promise<IdentityProviderAccount> {\n const user = await this.userRepository.findOneById(userId);\n if (!user) {\n throw new ValidationError('The linking user does not exist.');\n }\n\n if (\n identity.provider.realmId &&\n user.realmId !== identity.provider.realmId\n ) {\n throw new ValidationError('The provider and user realm do not match.');\n }\n\n const providerUserName = this.pickCandidate(identity, 'name', 256) ?? identity.id.slice(0, 256);\n const providerUserEmail = this.pickCandidate(identity, 'email', 512);\n\n const existing = await this.repository.findOneByProviderIdentity(identity);\n if (existing) {\n if (existing.userId !== userId) {\n throw new IdentityProviderAccountAlreadyLinkedError();\n }\n\n existing.providerUserName = providerUserName ?? existing.providerUserName;\n existing.providerUserEmail = providerUserEmail ?? existing.providerUserEmail;\n\n return this.repository.save(existing);\n }\n\n try {\n return await this.repository.save({\n providerId: identity.provider.id,\n providerUserId: identity.id,\n providerUserName,\n providerUserEmail: providerUserEmail ?? undefined,\n providerRealmId: identity.provider.realmId,\n userId,\n userRealmId: user.realmId ?? null,\n });\n } catch (e) {\n if (!isEntityConflictError(e)) {\n throw e;\n }\n\n // one of the two unique indexes fired; the re-read tells which:\n // a row for the identity means (providerUserId, providerId), a\n // race with the SAME user (two Connect tabs) being a no-op; no\n // row means (providerId, userId), the user already holds a link\n // at this provider through another external account.\n const raced = await this.repository.findOneByProviderIdentity(identity);\n if (raced) {\n if (raced.userId === userId) {\n return raced;\n }\n\n throw new IdentityProviderAccountAlreadyLinkedError();\n }\n\n throw new ValidationError('The user is already linked to this identity provider through another account.');\n }\n }\n\n protected pickCandidate(\n identity: IdentityProviderIdentity,\n key: keyof User,\n maxLength: number,\n ): string | null {\n const candidates = identity.attributeCandidates?.[key] || [];\n for (const candidate of candidates) {\n if (typeof candidate === 'string' && candidate.length > 0) {\n return candidate.slice(0, maxLength);\n }\n }\n\n return null;\n }\n\n async saveUser(\n identity: IdentityProviderIdentity,\n user?: User,\n ): Promise<User> {\n const attributes = await this.attributesMapper.execute(\n identity,\n );\n\n const entity : Record<string, any> = {};\n for (const attribute of attributes) {\n if (\n attribute.key &&\n attribute.operation === IdentityProviderMapperOperation.CREATE\n ) {\n // attribute value might be object, array, ...\n entity[attribute.key] = attribute.value;\n }\n }\n\n if (!user) {\n entity.realmId = identity.provider.realmId;\n entity.active = true;\n entity.nameLocked = true;\n entity.clientId = identity.clientId || null;\n }\n\n const attributesSelf = await this.validateAttributes(entity, identity, 10);\n if (!attributesSelf) {\n // todo: better error name\n throw new Error('Identity provider attributes could not be validated.');\n }\n const attributesSelfKeys = Object.keys(attributesSelf);\n\n const attributesExtra : Record<string, any> = {};\n\n const entityKeys = Object.keys(entity);\n for (const entityKey of entityKeys) {\n const index = attributesSelfKeys.indexOf(entityKey);\n if (index !== -1) {\n continue;\n }\n\n attributesExtra[entityKey] = entity[entityKey];\n }\n\n let output : User;\n if (user) {\n output = extendObject(user, attributesSelf);\n } else {\n output = attributesSelf;\n }\n\n if (typeof output.name === 'string') {\n output.name = output.name.trim().toLowerCase();\n }\n\n let attempts = Math.max((identity.attributeCandidates?.name?.length || 0) + 1, 10);\n while (attempts > 0) {\n try {\n // todo: we also need to remove existing ones via idp login flow ( but not other attributes!)\n return await this.userRepository.saveOneWithEA(output, attributesExtra);\n } catch {\n const names = identity.attributeCandidates?.name || [];\n if (names.length > 0) {\n while (names.length > 0) {\n output.name = `${names.shift()}`.trim().toLowerCase();\n\n try {\n await this.userValidator.run(output, {\n group: identity.operation === IdentityProviderIdentityOperation.CREATE ?\n ValidatorGroup.CREATE :\n ValidatorGroup.UPDATE,\n });\n break;\n } catch {\n // todo: do nothing.\n }\n }\n } else {\n output.name = createNanoID('0123456789abcdefghijklmnopqrstuvwxyz-_', 10);\n }\n\n if (isUserFakeEmail(output.email)) {\n output.email = buildUserFakeEmail(output.name);\n }\n\n attempts -= 1;\n }\n }\n\n throw new Error('The user account could not be created due a conflict error.');\n }\n\n async validateAttributes(\n entity: Record<string, any>,\n identity: IdentityProviderIdentity,\n attempts: number,\n ) : Promise<User | null> {\n attempts--;\n if (attempts <= 0) {\n return null;\n }\n\n try {\n return await this.userValidator.run(entity, {\n group: identity.operation === IdentityProviderIdentityOperation.CREATE ?\n ValidatorGroup.CREATE :\n ValidatorGroup.UPDATE,\n });\n } catch (e: any) {\n if (!isValidupError(e)) {\n return null;\n }\n\n let retry = false;\n for (let i = 0; i < e.issues.length; i++) {\n const child = e.issues[i];\n\n const pathNormalized = stringifyPath(child.path);\n\n if (\n Array.isArray(entity[pathNormalized]) &&\n entity[pathNormalized].length > 0\n ) {\n const [first, ...rest] = entity[pathNormalized];\n entity[pathNormalized] = first;\n\n if (rest.length > 0) {\n if (!identity.attributeCandidates) {\n identity.attributeCandidates = {};\n }\n\n if (!identity.attributeCandidates[pathNormalized]) {\n identity.attributeCandidates[pathNormalized] = [];\n }\n\n identity.attributeCandidates[pathNormalized]!.push(...rest);\n }\n\n retry = true;\n break;\n }\n\n if (\n identity.attributeCandidates &&\n identity.attributeCandidates[pathNormalized] &&\n identity.attributeCandidates[pathNormalized]!.length > 0\n ) {\n entity[pathNormalized] = identity.attributeCandidates[pathNormalized]!.shift();\n retry = true;\n break;\n }\n\n if (\n entity.name &&\n pathNormalized === 'email'\n ) {\n entity[pathNormalized] = buildUserFakeEmail(entity.name);\n retry = true;\n break;\n }\n\n if (entity[pathNormalized]) {\n entity[pathNormalized] = null;\n break;\n }\n }\n\n if (retry) {\n return this.validateAttributes(entity, identity, attempts);\n }\n\n return null;\n }\n }\n\n async savePermissions(\n identity: IdentityProviderIdentity,\n user: User,\n ) {\n const entities = await this.permissionMapper.execute(identity);\n\n await this.userRepository.savePermissions(user, entities);\n }\n\n async saveRoles(\n identity: IdentityProviderIdentity,\n user: User,\n ) {\n const entities = await this.roleMapper.execute(identity);\n\n await this.userRepository.saveRoles(user, entities);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA0BA,IAAac,iCAAb,MAAaA;CACCC;CAEAC;CAEAC;CAEAC;CAEAC;CAEAC;CAEAC;CAEV,YAAYC,KAA4C;EACpD,KAAKP,mBAAmBO,IAAIC;EAC5B,KAAKP,mBAAmBM,IAAIN;EAC5B,KAAKC,aAAaK,IAAIL;EACtB,KAAKC,aAAaI,IAAIJ;EACtB,KAAK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AO,GAAGC,QAAQtC,OAAOiC;KAChCjC,OAAOiC,kBAAkBI;KAEzB,IAAIC,KAAKzC,SAAS,GAAG;MACjB,IAAI,CAACtC,SAASoC,qBACVpC,SAASoC,sBAAsB,CAAC;MAGpC,IAAI,CAACpC,SAASoC,oBAAoBsC,iBAC9B1E,SAASoC,oBAAoBsC,kBAAkB,CAAA;MAGnD1E,SAASoC,oBAAoBsC,eAAe,CAAEM,KAAI,GAAID,IAAAA;KAC1D;KAEAT,QAAQ;KACR;IACJ;IAEA,IACItE,SAASoC,uBACTpC,SAASoC,oBAAoBsC,mBAC7B1E,SAASoC,oBAAoBsC,eAAe,CAAEpC,SAAS,GACzD;KACEG,OAAOiC,kBAAkB1E,SAASoC,oBAAoBsC,eAAe,CAAER,MAAK;KAC5EI,QAAQ;KACR;IACJ;IAEA,IACI7B,OAAO5B,QACP6D,mBAAmB,SACrB;KACEjC,OAAOiC,kBAAkBlG,mBAAmBiE,OAAO5B,IAAI;KACvDyD,QAAQ;KACR;IACJ;IAEA,IAAI7B,OAAOiC,iBAAiB;KACxBjC,OAAOiC,kBAAkB;KACzB;IACJ;GACJ;GAEA,IAAIJ,OACA,OAAO,KAAKtB,mBAAmBP,QAAQzC,UAAU6D,QAAAA;GAGrD,OAAO;EACX;CACJ;CAEA,MAAMrC,gBACFxB,UACAM,MACF;EACE,MAAM2E,WAAW,MAAM,KAAK1F,iBAAiBiD,QAAQxC,QAAAA;EAErD,MAAM,KAAKN,eAAe8B,gBAAgBlB,MAAM2E,QAAAA;CACpD;CAEA,MAAM1D,UACFvB,UACAM,MACF;EACE,MAAM2E,WAAW,MAAM,KAAKzF,WAAWgD,QAAQxC,QAAAA;EAE/C,MAAM,KAAKN,eAAe6B,UAAUjB,MAAM2E,QAAAA;CAC9C;AACJ"}
@@ -1,4 +1,5 @@
1
1
  import type { IdentityProviderAccount } from '@authup/core-kit';
2
+ import type { Logger } from '@authup/server-kit';
2
3
  import type { IUserIdentityRepository } from '../../entities/index.ts';
3
4
  import type { IIdentityProviderMapper } from '../mapper/index.ts';
4
5
  import type { IdentityProviderIdentity } from '../types.ts';
@@ -43,6 +44,12 @@ export type IdentityProviderAccountManagerContext = {
43
44
  attributeMapper: IIdentityProviderMapper;
44
45
  permissionMapper: IIdentityProviderMapper;
45
46
  roleMapper: IIdentityProviderMapper;
47
+ /**
48
+ * Reports the compensating actions `save()` takes when it loses a
49
+ * concurrent first login. They must not fail the login, so they are
50
+ * swallowed. Without a logger they are also invisible.
51
+ */
52
+ logger?: Logger;
46
53
  repository: IIdentityProviderAccountRepository;
47
54
  userRepository: IUserIdentityRepository;
48
55
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/core/identity/provider/account/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,sDAAsD,CAAC;AAE/G,YAAY,EAAE,kCAAkC,EAAE,MAAM,sDAAsD,CAAC;AAE/G;;;;;;;;;;GAUG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC,CAAC;AAEF,MAAM,WAAW,iCAAiC;IAC9C;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,2BAA2B,GAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1D;;;OA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,MAAM,GAAG,IAAI,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC,CAAC;AAEF,MAAM,WAAW,iCAAiC;IAC9C;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,2BAA2B,GAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1D;;;OAGG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAI,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC,CAAC;CACzE;AAED,MAAM,MAAM,qCAAqC,GAAG;IAChD,eAAe,EAAE,uBAAuB,CAAC;IACzC,gBAAgB,EAAE,uBAAuB,CAAC;IAC1C,UAAU,EAAE,uBAAuB,CAAC;IACpC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,UAAU,EAAE,kCAAkC,CAAC;IAC/C,cAAc,EAAE,uBAAuB,CAAA;CAC1C,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC5C;;;;OAIG;IACH,IAAI,CAAC,QAAQ,EAAE,wBAAwB,GAAI,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAE5E;;;;;;;;OAQG;IACH,IAAI,CAAC,QAAQ,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,GAAI,OAAO,CAAC,uBAAuB,CAAC,CAAC;CAC/F"}
@@ -3,6 +3,7 @@ import "node:url";
3
3
  import.meta.url;
4
4
  import { IdentityProviderLdapAuthenticator } from "./protocols/ldap/module.mjs";
5
5
  import { IdentityProviderLdapCollectionAuthenticator } from "./protocols/ldap/collection.mjs";
6
+ import { IDENTITY_PROVIDER_ASSURANCE_ERROR_INSTANCE, IdentityProviderAssuranceError, assertIdentityProviderAssurance, buildIdentityProviderAcrValues, isIdentityProviderAssuranceError } from "./protocols/oauth2/assurance.mjs";
6
7
  import { IdentityProviderOAuth2Authenticator } from "./protocols/oauth2/module.mjs";
7
8
  import { IdentityProviderOpenIDAuthenticator } from "./protocols/open-id/module.mjs";
8
9
  import "./protocols/index.mjs";
@@ -12,6 +13,6 @@ import { IdentityProviderGoogleAuthenticator } from "./presets/google.mjs";
12
13
  import { IdentityProviderInstagramAuthenticator } from "./presets/instagram.mjs";
13
14
  import { IdentityProviderPaypalAuthenticator } from "./presets/paypal.mjs";
14
15
  import "./presets/index.mjs";
15
- import { IDENTITY_PROVIDER_LDAP_COLLECTION_AUTHENTICATOR_TOKEN } from "./constants.mjs";
16
16
  import { createIdentityProviderOAuth2Authenticator } from "./factory.mjs";
17
- export { IDENTITY_PROVIDER_LDAP_COLLECTION_AUTHENTICATOR_TOKEN, IdentityProviderFacebookAuthenticator, IdentityProviderGithubAuthenticator, IdentityProviderGoogleAuthenticator, IdentityProviderInstagramAuthenticator, IdentityProviderLdapAuthenticator, IdentityProviderLdapCollectionAuthenticator, IdentityProviderOAuth2Authenticator, IdentityProviderOpenIDAuthenticator, IdentityProviderPaypalAuthenticator, createIdentityProviderOAuth2Authenticator };
17
+ import { IDENTITY_PROVIDER_LDAP_COLLECTION_AUTHENTICATOR_TOKEN } from "./constants.mjs";
18
+ export { IDENTITY_PROVIDER_ASSURANCE_ERROR_INSTANCE, IDENTITY_PROVIDER_LDAP_COLLECTION_AUTHENTICATOR_TOKEN, IdentityProviderAssuranceError, IdentityProviderFacebookAuthenticator, IdentityProviderGithubAuthenticator, IdentityProviderGoogleAuthenticator, IdentityProviderInstagramAuthenticator, IdentityProviderLdapAuthenticator, IdentityProviderLdapCollectionAuthenticator, IdentityProviderOAuth2Authenticator, IdentityProviderOpenIDAuthenticator, IdentityProviderPaypalAuthenticator, assertIdentityProviderAssurance, buildIdentityProviderAcrValues, createIdentityProviderOAuth2Authenticator, isIdentityProviderAssuranceError };
@@ -4,8 +4,9 @@ import.meta.url;
4
4
  import { IdentityProviderLdapAuthenticator } from "./ldap/module.mjs";
5
5
  import { IdentityProviderLdapCollectionAuthenticator } from "./ldap/collection.mjs";
6
6
  import "./ldap/index.mjs";
7
+ import { IDENTITY_PROVIDER_ASSURANCE_ERROR_INSTANCE, IdentityProviderAssuranceError, assertIdentityProviderAssurance, buildIdentityProviderAcrValues, isIdentityProviderAssuranceError } from "./oauth2/assurance.mjs";
7
8
  import { IdentityProviderOAuth2Authenticator } from "./oauth2/module.mjs";
8
9
  import "./oauth2/index.mjs";
9
10
  import { IdentityProviderOpenIDAuthenticator } from "./open-id/module.mjs";
10
11
  import "./open-id/index.mjs";
11
- export { IdentityProviderLdapAuthenticator, IdentityProviderLdapCollectionAuthenticator, IdentityProviderOAuth2Authenticator, IdentityProviderOpenIDAuthenticator };
12
+ export { IDENTITY_PROVIDER_ASSURANCE_ERROR_INSTANCE, IdentityProviderAssuranceError, IdentityProviderLdapAuthenticator, IdentityProviderLdapCollectionAuthenticator, IdentityProviderOAuth2Authenticator, IdentityProviderOpenIDAuthenticator, assertIdentityProviderAssurance, buildIdentityProviderAcrValues, isIdentityProviderAssuranceError };
@@ -0,0 +1,46 @@
1
+ import type { OAuth2IdentityProviderBase } from '@authup/core-kit';
2
+ import { ValidationError } from '@authup/errors';
3
+ export declare const IDENTITY_PROVIDER_ASSURANCE_ERROR_INSTANCE: unique symbol;
4
+ /**
5
+ * The upstream did not meet the provider's `requiredAmr` / `requiredAcr`.
6
+ *
7
+ * It adds no dedicated `ErrorCode` and keeps `ValidationError`'s shared
8
+ * `BAD_REQUEST`, so the marker is the ONLY thing the guard may read - a
9
+ * code fallback would match every other `ValidationError` in the process.
10
+ * That is sound here because both callers swallow it into a redirect (the
11
+ * login bounces to the hosted page with `access_denied`, the link callback
12
+ * with `linkError`), so it never crosses a wire boundary. The reason lands
13
+ * in the operator's log instead, which is where a misconfigured allow-list
14
+ * is debugged.
15
+ */
16
+ export declare class IdentityProviderAssuranceError extends ValidationError {
17
+ constructor(message: string);
18
+ }
19
+ export declare function isIdentityProviderAssuranceError(input: unknown): input is IdentityProviderAssuranceError;
20
+ /**
21
+ * The `acr_values` an outbound authorize request asks for, so the upstream is
22
+ * asked to step up rather than merely observed. Voluntary in OIDC Core
23
+ * 5.5.1.1 - a provider may ignore it and answer anyway, which is exactly what
24
+ * {@see assertIdentityProviderAssurance} is for.
25
+ */
26
+ export declare function buildIdentityProviderAcrValues(provider: Partial<OAuth2IdentityProviderBase>): string | undefined;
27
+ /**
28
+ * Verify what the upstream actually returned against the provider's
29
+ * allow-lists.
30
+ *
31
+ * Fail closed on every uncertainty: the claims are read from the `id_token`
32
+ * alone, so a provider that returns none - or one whose token carries neither
33
+ * claim, or cannot be decoded - is refused once an allow-list is set. Failing
34
+ * open there would make the feature decorative.
35
+ *
36
+ * The token is DECODED, not verified, and that is not an oversight. It is the
37
+ * return value of the server's own back-channel POST to the operator-configured
38
+ * `tokenUrl`, so OIDC Core 3.1.3.7 item 6 accepts TLS server validation in
39
+ * place of checking the signature. No browser-supplied token reaches here, and
40
+ * a provider the operator configured is the authentication authority for these
41
+ * users anyway: one that lies about `amr` could equally mint any subject. What
42
+ * item 6 does NOT waive is the audience, which is checked below because
43
+ * `clientId` is already in hand.
44
+ */
45
+ export declare function assertIdentityProviderAssurance(provider: Partial<OAuth2IdentityProviderBase>, idToken?: string): void;
46
+ //# sourceMappingURL=assurance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assurance.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/identity/provider/authentication/protocols/oauth2/assurance.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAqC,MAAM,gBAAgB,CAAC;AAGpF,eAAO,MAAM,0CAA0C,eAAmE,CAAC;AAE3H;;;;;;;;;;;GAWG;AACH,qBAAa,8BAA+B,SAAQ,eAAe;gBACnD,OAAO,EAAE,MAAM;CAI9B;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,8BAA8B,CAExG;AAiBD;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,OAAO,CAAC,0BAA0B,CAAC,GAAG,MAAM,GAAG,SAAS,CAGhH;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,+BAA+B,CAC3C,QAAQ,EAAE,OAAO,CAAC,0BAA0B,CAAC,EAC7C,OAAO,CAAC,EAAE,MAAM,GACjB,IAAI,CAgEN"}