@memberjunction/server 6.1.0-edge.1 → 6.1.0-edge.3

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 (261) hide show
  1. package/LICENSE +180 -4
  2. package/dist/auth/AuthProviderCatalogRouter.d.ts +31 -0
  3. package/dist/auth/AuthProviderCatalogRouter.d.ts.map +1 -0
  4. package/dist/auth/AuthProviderCatalogRouter.js +69 -0
  5. package/dist/auth/AuthProviderCatalogRouter.js.map +1 -0
  6. package/dist/auth/AuthProviderEngine.d.ts +96 -0
  7. package/dist/auth/AuthProviderEngine.d.ts.map +1 -0
  8. package/dist/auth/AuthProviderEngine.js +245 -0
  9. package/dist/auth/AuthProviderEngine.js.map +1 -0
  10. package/dist/auth/exampleNewUserSubClass.js +1 -1
  11. package/dist/auth/exampleNewUserSubClass.js.map +1 -1
  12. package/dist/auth/index.d.ts +11 -0
  13. package/dist/auth/index.d.ts.map +1 -1
  14. package/dist/auth/index.js +65 -18
  15. package/dist/auth/index.js.map +1 -1
  16. package/dist/auth/initializeProviders.d.ts +64 -1
  17. package/dist/auth/initializeProviders.d.ts.map +1 -1
  18. package/dist/auth/initializeProviders.js +117 -5
  19. package/dist/auth/initializeProviders.js.map +1 -1
  20. package/dist/auth/magicLink/MagicLinkService.js +1 -1
  21. package/dist/auth/magicLink/MagicLinkService.js.map +1 -1
  22. package/dist/auth/newUsers.js +1 -1
  23. package/dist/auth/newUsers.js.map +1 -1
  24. package/dist/config.d.ts +89 -0
  25. package/dist/config.d.ts.map +1 -1
  26. package/dist/config.js +52 -35
  27. package/dist/config.js.map +1 -1
  28. package/dist/context.js +2 -2
  29. package/dist/context.js.map +1 -1
  30. package/dist/generated/generated.d.ts +540 -1595
  31. package/dist/generated/generated.d.ts.map +1 -1
  32. package/dist/generated/generated.js +2755 -16857
  33. package/dist/generated/generated.js.map +1 -1
  34. package/dist/generic/ResolverBase.d.ts +20 -4
  35. package/dist/generic/ResolverBase.d.ts.map +1 -1
  36. package/dist/generic/ResolverBase.js +58 -21
  37. package/dist/generic/ResolverBase.js.map +1 -1
  38. package/dist/generic/RunViewResolver.d.ts +4 -0
  39. package/dist/generic/RunViewResolver.d.ts.map +1 -1
  40. package/dist/generic/RunViewResolver.js +31 -0
  41. package/dist/generic/RunViewResolver.js.map +1 -1
  42. package/dist/index.d.ts +3 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +183 -54
  45. package/dist/index.js.map +1 -1
  46. package/dist/integration/RSUProgressBridge.d.ts +83 -0
  47. package/dist/integration/RSUProgressBridge.d.ts.map +1 -0
  48. package/dist/integration/RSUProgressBridge.js +230 -0
  49. package/dist/integration/RSUProgressBridge.js.map +1 -0
  50. package/dist/integration/SchemaRefreshLaunch.d.ts +52 -0
  51. package/dist/integration/SchemaRefreshLaunch.d.ts.map +1 -0
  52. package/dist/integration/SchemaRefreshLaunch.js +50 -0
  53. package/dist/integration/SchemaRefreshLaunch.js.map +1 -0
  54. package/dist/logging/secretRedactor.d.ts +9 -0
  55. package/dist/logging/secretRedactor.d.ts.map +1 -1
  56. package/dist/logging/secretRedactor.js +39 -0
  57. package/dist/logging/secretRedactor.js.map +1 -1
  58. package/dist/middleware/BaseServerMiddleware.d.ts +5 -0
  59. package/dist/middleware/BaseServerMiddleware.d.ts.map +1 -1
  60. package/dist/middleware/BaseServerMiddleware.js +5 -0
  61. package/dist/middleware/BaseServerMiddleware.js.map +1 -1
  62. package/dist/providerConfigUnits.d.ts +20 -0
  63. package/dist/providerConfigUnits.d.ts.map +1 -0
  64. package/dist/providerConfigUnits.js +22 -0
  65. package/dist/providerConfigUnits.js.map +1 -0
  66. package/dist/realtimeWidget/WidgetSessionService.js +1 -1
  67. package/dist/realtimeWidget/WidgetSessionService.js.map +1 -1
  68. package/dist/realtimeWidget/widgetGuestElevation.js +1 -1
  69. package/dist/realtimeWidget/widgetGuestElevation.js.map +1 -1
  70. package/dist/resolvers/ActionResolver.d.ts.map +1 -1
  71. package/dist/resolvers/ActionResolver.js +12 -0
  72. package/dist/resolvers/ActionResolver.js.map +1 -1
  73. package/dist/resolvers/ComponentRegistryResolver.js +1 -1
  74. package/dist/resolvers/ComponentRegistryResolver.js.map +1 -1
  75. package/dist/resolvers/EntityPermissionResolver.js +1 -1
  76. package/dist/resolvers/EntityPermissionResolver.js.map +1 -1
  77. package/dist/resolvers/FileResolver.d.ts +34 -4
  78. package/dist/resolvers/FileResolver.d.ts.map +1 -1
  79. package/dist/resolvers/FileResolver.js +218 -28
  80. package/dist/resolvers/FileResolver.js.map +1 -1
  81. package/dist/resolvers/IntegrationDiscoveryResolver.d.ts +85 -3
  82. package/dist/resolvers/IntegrationDiscoveryResolver.d.ts.map +1 -1
  83. package/dist/resolvers/IntegrationDiscoveryResolver.js +302 -82
  84. package/dist/resolvers/IntegrationDiscoveryResolver.js.map +1 -1
  85. package/dist/resolvers/PotentialDuplicateRecordResolver.js +1 -1
  86. package/dist/resolvers/PotentialDuplicateRecordResolver.js.map +1 -1
  87. package/dist/resolvers/QueryResolver.d.ts +5 -4
  88. package/dist/resolvers/QueryResolver.d.ts.map +1 -1
  89. package/dist/resolvers/QueryResolver.js +29 -14
  90. package/dist/resolvers/QueryResolver.js.map +1 -1
  91. package/dist/resolvers/QuerySystemUserResolver.d.ts +12 -3
  92. package/dist/resolvers/QuerySystemUserResolver.d.ts.map +1 -1
  93. package/dist/resolvers/QuerySystemUserResolver.js +33 -14
  94. package/dist/resolvers/QuerySystemUserResolver.js.map +1 -1
  95. package/dist/resolvers/RealtimeClientSessionResolver.d.ts +10 -0
  96. package/dist/resolvers/RealtimeClientSessionResolver.d.ts.map +1 -1
  97. package/dist/resolvers/RealtimeClientSessionResolver.js +5 -0
  98. package/dist/resolvers/RealtimeClientSessionResolver.js.map +1 -1
  99. package/dist/resolvers/RunAIAgentResolver.d.ts +3 -1
  100. package/dist/resolvers/RunAIAgentResolver.d.ts.map +1 -1
  101. package/dist/resolvers/RunAIAgentResolver.js +20 -7
  102. package/dist/resolvers/RunAIAgentResolver.js.map +1 -1
  103. package/dist/resolvers/SearchEntitiesResolver.js +1 -1
  104. package/dist/resolvers/SearchEntitiesResolver.js.map +1 -1
  105. package/dist/resolvers/SqlLoggingConfigResolver.d.ts.map +1 -1
  106. package/dist/resolvers/SqlLoggingConfigResolver.js +1 -1
  107. package/dist/resolvers/SqlLoggingConfigResolver.js.map +1 -1
  108. package/dist/resolvers/SyncRolesUsersResolver.js +2 -2
  109. package/dist/resolvers/SyncRolesUsersResolver.js.map +1 -1
  110. package/dist/resolvers/TaskGraphFrameResolver.d.ts +18 -0
  111. package/dist/resolvers/TaskGraphFrameResolver.d.ts.map +1 -1
  112. package/dist/resolvers/TaskGraphFrameResolver.js +75 -0
  113. package/dist/resolvers/TaskGraphFrameResolver.js.map +1 -1
  114. package/dist/resolvers/UserFavoriteResolver.js +1 -1
  115. package/dist/resolvers/UserFavoriteResolver.js.map +1 -1
  116. package/dist/resolvers/UserResolver.d.ts +19 -17
  117. package/dist/resolvers/UserResolver.d.ts.map +1 -1
  118. package/dist/resolvers/UserResolver.js +66 -67
  119. package/dist/resolvers/UserResolver.js.map +1 -1
  120. package/dist/resolvers/currentUserRoles.d.ts +19 -0
  121. package/dist/resolvers/currentUserRoles.d.ts.map +1 -0
  122. package/dist/resolvers/currentUserRoles.js +36 -0
  123. package/dist/resolvers/currentUserRoles.js.map +1 -0
  124. package/dist/rest/MediaAccessKeys.d.ts +17 -0
  125. package/dist/rest/MediaAccessKeys.d.ts.map +1 -1
  126. package/dist/rest/MediaAccessKeys.js +42 -1
  127. package/dist/rest/MediaAccessKeys.js.map +1 -1
  128. package/dist/rest/MediaStreamHandler.d.ts +3 -2
  129. package/dist/rest/MediaStreamHandler.d.ts.map +1 -1
  130. package/dist/rest/MediaStreamHandler.js +83 -2
  131. package/dist/rest/MediaStreamHandler.js.map +1 -1
  132. package/dist/rest/OAuthCallbackHandler.d.ts +49 -1
  133. package/dist/rest/OAuthCallbackHandler.d.ts.map +1 -1
  134. package/dist/rest/OAuthCallbackHandler.js +130 -44
  135. package/dist/rest/OAuthCallbackHandler.js.map +1 -1
  136. package/dist/rest/SignatureWebhookHandler.js +1 -1
  137. package/dist/rest/SignatureWebhookHandler.js.map +1 -1
  138. package/dist/rest/UploadTokenManager.d.ts +90 -0
  139. package/dist/rest/UploadTokenManager.d.ts.map +1 -0
  140. package/dist/rest/UploadTokenManager.js +156 -0
  141. package/dist/rest/UploadTokenManager.js.map +1 -0
  142. package/dist/services/DurableEntityActionTaskSubmitter.d.ts +26 -0
  143. package/dist/services/DurableEntityActionTaskSubmitter.d.ts.map +1 -0
  144. package/dist/services/DurableEntityActionTaskSubmitter.js +55 -0
  145. package/dist/services/DurableEntityActionTaskSubmitter.js.map +1 -0
  146. package/dist/services/IntegrationSyncWorkerService.d.ts +48 -0
  147. package/dist/services/IntegrationSyncWorkerService.d.ts.map +1 -0
  148. package/dist/services/IntegrationSyncWorkerService.js +132 -0
  149. package/dist/services/IntegrationSyncWorkerService.js.map +1 -0
  150. package/dist/services/ScheduledJobsService.js +1 -1
  151. package/dist/services/ScheduledJobsService.js.map +1 -1
  152. package/dist/services/StartTaskGraphDispatcher.d.ts +0 -10
  153. package/dist/services/StartTaskGraphDispatcher.d.ts.map +1 -1
  154. package/dist/services/StartTaskGraphDispatcher.js +37 -2
  155. package/dist/services/StartTaskGraphDispatcher.js.map +1 -1
  156. package/dist/services/TaskGraphActionRunner.d.ts +34 -0
  157. package/dist/services/TaskGraphActionRunner.d.ts.map +1 -0
  158. package/dist/services/TaskGraphActionRunner.js +95 -0
  159. package/dist/services/TaskGraphActionRunner.js.map +1 -0
  160. package/dist/services/TaskGraphAgentRunner.d.ts +20 -0
  161. package/dist/services/TaskGraphAgentRunner.d.ts.map +1 -1
  162. package/dist/services/TaskGraphAgentRunner.js +53 -0
  163. package/dist/services/TaskGraphAgentRunner.js.map +1 -1
  164. package/dist/services/TaskGraphContinuationDeliverer.d.ts.map +1 -1
  165. package/dist/services/TaskGraphContinuationDeliverer.js +12 -1
  166. package/dist/services/TaskGraphContinuationDeliverer.js.map +1 -1
  167. package/dist/services/TaskGraphPromptRunner.d.ts +31 -0
  168. package/dist/services/TaskGraphPromptRunner.d.ts.map +1 -0
  169. package/dist/services/TaskGraphPromptRunner.js +134 -0
  170. package/dist/services/TaskGraphPromptRunner.js.map +1 -0
  171. package/dist/telephony/RingCentralTelephonyService.js +1 -1
  172. package/dist/telephony/RingCentralTelephonyService.js.map +1 -1
  173. package/dist/telephony/TwilioTelephonyRouter.js +1 -1
  174. package/dist/telephony/TwilioTelephonyRouter.js.map +1 -1
  175. package/dist/telephony/VonageTelephonyRouter.js +1 -1
  176. package/dist/telephony/VonageTelephonyRouter.js.map +1 -1
  177. package/dist/types.d.ts +6 -0
  178. package/dist/types.d.ts.map +1 -1
  179. package/dist/types.js.map +1 -1
  180. package/package.json +91 -91
  181. package/src/__tests__/APIKeyScopeAuth.test.ts +475 -0
  182. package/src/__tests__/AuthProviderEngine.test.ts +278 -0
  183. package/src/__tests__/EntityCRUDHandler.test.ts +378 -0
  184. package/src/__tests__/IntegrationSyncWorkerService.test.ts +275 -0
  185. package/src/__tests__/OAuthCallbackHandler.openRedirect.test.ts +117 -0
  186. package/src/__tests__/OAuthCallbackHandler.xss.test.ts +4 -1
  187. package/src/__tests__/RESTEndpointHandler.test.ts +672 -0
  188. package/src/__tests__/RSUProgressBridge.test.ts +250 -0
  189. package/src/__tests__/RealtimeBridgeResolver.test.ts +10 -2
  190. package/src/__tests__/RealtimeClientSessionResolver.test.ts +1 -1
  191. package/src/__tests__/ResolverBase.frozenRecordMapping.test.ts +133 -0
  192. package/src/__tests__/ResolverBase.transportMapping.test.ts +289 -0
  193. package/src/__tests__/SchemaRefreshLaunch.test.ts +114 -0
  194. package/src/__tests__/SessionManager.test.ts +1 -1
  195. package/src/__tests__/UserResolver.currentUser.test.ts +87 -0
  196. package/src/__tests__/ViewOperationsHandler.test.ts +277 -0
  197. package/src/__tests__/WidgetSessionService.test.ts +1 -1
  198. package/src/__tests__/config-units.test.ts +74 -0
  199. package/src/__tests__/databaseAbstraction.test.ts +1 -1
  200. package/src/__tests__/initializeProviders.refresh.test.ts +146 -0
  201. package/src/__tests__/magicLinkService.provisionLog.test.ts +1 -1
  202. package/src/__tests__/mjapi-bootstrap.test.ts +0 -6
  203. package/src/__tests__/newUsers.test.ts +726 -0
  204. package/src/__tests__/resolverBase.rls.test.ts +3 -0
  205. package/src/__tests__/secretRedactor.failOpen.test.ts +135 -0
  206. package/src/__tests__/uploadTokenManager.test.ts +159 -0
  207. package/src/__tests__/widgetGuestElevation.test.ts +1 -1
  208. package/src/auth/AuthProviderCatalogRouter.ts +76 -0
  209. package/src/auth/AuthProviderEngine.ts +253 -0
  210. package/src/auth/exampleNewUserSubClass.ts +1 -1
  211. package/src/auth/index.ts +69 -21
  212. package/src/auth/initializeProviders.ts +128 -7
  213. package/src/auth/magicLink/MagicLinkService.ts +1 -1
  214. package/src/auth/newUsers.ts +1 -1
  215. package/src/config.ts +55 -36
  216. package/src/context.ts +2 -2
  217. package/src/generated/generated.ts +2038 -10529
  218. package/src/generic/ResolverBase.ts +63 -21
  219. package/src/generic/RunViewResolver.ts +31 -0
  220. package/src/index.ts +199 -56
  221. package/src/integration/RSUProgressBridge.ts +248 -0
  222. package/src/integration/SchemaRefreshLaunch.ts +77 -0
  223. package/src/logging/secretRedactor.ts +43 -0
  224. package/src/middleware/BaseServerMiddleware.ts +5 -0
  225. package/src/providerConfigUnits.ts +21 -0
  226. package/src/realtimeWidget/WidgetSessionService.ts +1 -1
  227. package/src/realtimeWidget/widgetGuestElevation.ts +1 -1
  228. package/src/resolvers/ActionResolver.ts +13 -0
  229. package/src/resolvers/ComponentRegistryResolver.ts +1 -1
  230. package/src/resolvers/EntityPermissionResolver.ts +1 -1
  231. package/src/resolvers/FileResolver.ts +200 -40
  232. package/src/resolvers/IntegrationDiscoveryResolver.ts +328 -70
  233. package/src/resolvers/PotentialDuplicateRecordResolver.ts +1 -1
  234. package/src/resolvers/QueryResolver.ts +25 -11
  235. package/src/resolvers/QuerySystemUserResolver.ts +28 -13
  236. package/src/resolvers/RealtimeClientSessionResolver.ts +13 -0
  237. package/src/resolvers/RunAIAgentResolver.ts +21 -6
  238. package/src/resolvers/SearchEntitiesResolver.ts +1 -1
  239. package/src/resolvers/SqlLoggingConfigResolver.ts +1 -2
  240. package/src/resolvers/SyncRolesUsersResolver.ts +2 -2
  241. package/src/resolvers/TaskGraphFrameResolver.ts +67 -0
  242. package/src/resolvers/UserFavoriteResolver.ts +1 -1
  243. package/src/resolvers/UserResolver.ts +99 -60
  244. package/src/resolvers/currentUserRoles.ts +47 -0
  245. package/src/rest/MediaAccessKeys.ts +47 -1
  246. package/src/rest/MediaStreamHandler.ts +98 -3
  247. package/src/rest/OAuthCallbackHandler.ts +150 -42
  248. package/src/rest/SignatureWebhookHandler.ts +1 -1
  249. package/src/rest/UploadTokenManager.ts +211 -0
  250. package/src/services/DurableEntityActionTaskSubmitter.ts +78 -0
  251. package/src/services/IntegrationSyncWorkerService.ts +141 -0
  252. package/src/services/ScheduledJobsService.ts +1 -1
  253. package/src/services/StartTaskGraphDispatcher.ts +38 -1
  254. package/src/services/TaskGraphActionRunner.ts +99 -0
  255. package/src/services/TaskGraphAgentRunner.ts +58 -1
  256. package/src/services/TaskGraphContinuationDeliverer.ts +11 -1
  257. package/src/services/TaskGraphPromptRunner.ts +144 -0
  258. package/src/telephony/RingCentralTelephonyService.ts +1 -1
  259. package/src/telephony/TwilioTelephonyRouter.ts +1 -1
  260. package/src/telephony/VonageTelephonyRouter.ts +1 -1
  261. package/src/types.ts +6 -0
package/LICENSE CHANGED
@@ -1,7 +1,183 @@
1
- ISC License
1
+ Business Source License 1.1
2
2
 
3
- Copyright (c) 2023 MemberJunction
3
+ License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB plc.
4
5
 
5
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6
+ -----------------------------------------------------------------------------
6
7
 
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
8
+ Parameters
9
+
10
+ Licensor: Blue Cypress, Inc.
11
+
12
+ Licensed Work: MemberJunction.
13
+ The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
14
+
15
+ Additional Use Grant: Subject to the terms of this License, Licensor grants
16
+ you the following additional rights to make Production
17
+ Use of the Licensed Work.
18
+
19
+ 1. Internal Use
20
+
21
+ You may make production use of the Licensed Work for
22
+ your own internal business or organizational operations.
23
+
24
+ 2. Nonprofit Use
25
+
26
+ If you are a Nonprofit, you may make production use of
27
+ the Licensed Work for the operations and activities of
28
+ your Organizational Family.
29
+
30
+ 3. MemberJunction Certified Program Use
31
+
32
+ If you are authorized by Licensor under the
33
+ MemberJunction Certified Program to provide professional
34
+ services using the Licensed Work, you may make
35
+ production use of the Licensed Work in providing such
36
+ professional services to a client, provided that:
37
+
38
+ (a) the Licensed Work is deployed in, and the applicable
39
+ production use occurs within, an environment owned,
40
+ leased, licensed, subscribed to, or otherwise controlled
41
+ by that client; and
42
+
43
+ (b) the production use is for that client's own internal
44
+ business or organizational operations or is otherwise
45
+ independently permitted to that client under this
46
+ Additional Use Grant.
47
+
48
+ 4. Definitions Applicable to the Additional Use Grant
49
+
50
+ "Affiliate" means, with respect to a specified Person,
51
+ any other Person that directly or indirectly Controls,
52
+ is Controlled by, or is under common Control with such
53
+ specified Person.
54
+
55
+ "Control" (including the terms "Controls," "Controlled
56
+ by," and "under common Control with") means the direct
57
+ or indirect possession of the power to direct or cause
58
+ the direction of the management and policies of a
59
+ Person, whether through ownership of voting interests,
60
+ by contract, or otherwise.
61
+
62
+ "Organizational Family" means, with respect to a Person,
63
+ (a) such Person and its Affiliates, and (b) any
64
+ nonprofit organization, governmental entity, chapter,
65
+ division, local affiliate, regional affiliate, state
66
+ affiliate, national affiliate, or other entity that is
67
+ formally affiliated with such Person through governing
68
+ documents, a charter, bylaws, a membership agreement, or
69
+ another written organizational instrument, and is
70
+ recognized under such documents as part of the same
71
+ organizational structure.
72
+
73
+ "Nonprofit" means a Person recognized by the Internal
74
+ Revenue Service as exempt from federal income taxation
75
+ under Section 501(c)(3), 501(c)(4), 501(c)(5), or
76
+ 501(c)(6) of the Internal Revenue Code, or a foreign
77
+ organization recognized under substantially equivalent
78
+ laws.
79
+
80
+ A Person claiming eligibility as a Nonprofit shall, upon
81
+ Licensor's reasonable request, provide documentation
82
+ reasonably sufficient to demonstrate that it qualifies
83
+ as a Nonprofit. If such Person materially misrepresents,
84
+ or is unable to demonstrate, its qualification as a
85
+ Nonprofit, the rights granted to such Person under
86
+ Section 2 of this Additional Use Grant shall terminate.
87
+
88
+ "MemberJunction Certified Program" means Licensor's
89
+ then-current program for certifying and authorizing a
90
+ Person to provide professional services using the
91
+ Licensed Work.
92
+
93
+ "Person" means any individual, corporation, limited
94
+ liability company, partnership, association, nonprofit
95
+ organization, governmental entity, or other legal or
96
+ organizational entity.
97
+
98
+ Change Date: Four (4) years from the date the Licensed Work is first
99
+ made available.
100
+
101
+ Change License: MIT License.
102
+
103
+ For information about alternative licensing arrangements for the Licensed
104
+ Work, please contact Blue Cypress, Inc.
105
+
106
+ -----------------------------------------------------------------------------
107
+
108
+ Terms
109
+
110
+ The Licensor hereby grants you the right to copy, modify, create derivative
111
+ works, redistribute, and make non-production use of the Licensed Work. The
112
+ Licensor may make an Additional Use Grant, above, permitting limited
113
+ production use.
114
+
115
+ Effective on the Change Date, or the fourth anniversary of the first publicly
116
+ available distribution of a specific version of the Licensed Work under this
117
+ License, whichever comes first, the Licensor hereby grants you rights under
118
+ the terms of the Change License, and the rights granted in the paragraph
119
+ above terminate.
120
+
121
+ If your use of the Licensed Work does not comply with the requirements
122
+ currently in effect as described in this License, you must purchase a
123
+ commercial license from the Licensor, its affiliated entities, or authorized
124
+ resellers, or you must refrain from using the Licensed Work.
125
+
126
+ All copies of the original and modified Licensed Work, and derivative works
127
+ of the Licensed Work, are subject to this License. This License applies
128
+ separately for each version of the Licensed Work and the Change Date may vary
129
+ for each version of the Licensed Work released by Licensor.
130
+
131
+ You must conspicuously display this License on each original or modified copy
132
+ of the Licensed Work. If you receive the Licensed Work in original or
133
+ modified form from a third party, the terms and conditions set forth in this
134
+ License apply to your use of that work.
135
+
136
+ Any use of the Licensed Work in violation of this License will automatically
137
+ terminate your rights under this License for the current and all other
138
+ versions of the Licensed Work.
139
+
140
+ This License does not grant you any right in any trademark or logo of
141
+ Licensor or its affiliates (provided that you may use a trademark or logo of
142
+ Licensor as expressly required by this License).
143
+
144
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
145
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
146
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
147
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
148
+ TITLE.
149
+
150
+ MariaDB hereby grants you permission to use this License's text to license
151
+ your works, and to refer to it using the trademark "Business Source License",
152
+ as long as you comply with the Covenants of Licensor below.
153
+
154
+ -----------------------------------------------------------------------------
155
+
156
+ Covenants of Licensor
157
+
158
+ In consideration of the right to use this License's text and the "Business
159
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
160
+ other recipients of the licensed work to be provided by Licensor:
161
+
162
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
163
+ or a license that is compatible with GPL Version 2.0 or a later version,
164
+ where "compatible" means that software provided under the Change License
165
+ can be included in a program with software provided under GPL Version 2.0
166
+ or a later version. Licensor may specify additional Change Licenses without
167
+ limitation.
168
+
169
+ 2. To either: (a) specify an additional grant of rights to use that does not
170
+ impose any additional restriction on the right granted in this License, as
171
+ the Additional Use Grant; or (b) insert the text "None".
172
+
173
+ 3. To specify a Change Date.
174
+
175
+ 4. Not to modify this License in any other way.
176
+
177
+ -----------------------------------------------------------------------------
178
+
179
+ Notice
180
+
181
+ The Business Source License (this document, or the "License") is not an Open
182
+ Source license. However, the Licensed Work will eventually be made available
183
+ under an Open Source License, as stated in this License.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @fileoverview Unauthenticated provider-catalog endpoint.
3
+ *
4
+ * The browser must know which identity providers exist BEFORE it can authenticate, so this
5
+ * router is mounted ahead of the unified auth middleware — the same pattern the magic-link JWKS
6
+ * and widget-session routes already use.
7
+ *
8
+ * @module @memberjunction/server/auth
9
+ */
10
+ import { Router } from 'express';
11
+ /** Mount path for the public catalog router. */
12
+ export declare const AUTH_CATALOG_MOUNT_PATH = "/auth";
13
+ /**
14
+ * Builds the unauthenticated `GET /auth/providers` router.
15
+ *
16
+ * **What it exposes.** Only `Active` + `ClientVisible` rows, projected to the public allow-list
17
+ * by {@link AuthProviderEngine.GetPublicCatalog}. Secret material is structurally unable to reach
18
+ * this response: `CredentialID` and `AdditionalConfiguration` are not part of the public shape,
19
+ * and non-primitive `ClientConfiguration` values are dropped rather than serialized.
20
+ *
21
+ * **Why publishing this is safe.** Every value here was already shipped to anonymous users — a
22
+ * single-provider SPA compiled its client ID, domain and issuer straight into its JavaScript
23
+ * bundle. This endpoint moves that same data behind one source of truth; it does not widen what
24
+ * an anonymous caller can learn.
25
+ *
26
+ * **Failure is empty, not an error.** If the catalog cannot be read, the endpoint returns an empty
27
+ * list so the browser falls back to its compiled `AUTH_TYPE` and the user can still sign in.
28
+ * Returning 500 would take the login screen down for a problem the client can route around.
29
+ */
30
+ export declare function createAuthProviderCatalogRouter(): Router;
31
+ //# sourceMappingURL=AuthProviderCatalogRouter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthProviderCatalogRouter.d.ts","sourceRoot":"","sources":["../../src/auth/AuthProviderCatalogRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAA+B,MAAM,SAAS,CAAC;AAK9D,gDAAgD;AAChD,eAAO,MAAM,uBAAuB,UAAU,CAAC;AAiB/C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,CAyBxD"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @fileoverview Unauthenticated provider-catalog endpoint.
3
+ *
4
+ * The browser must know which identity providers exist BEFORE it can authenticate, so this
5
+ * router is mounted ahead of the unified auth middleware — the same pattern the magic-link JWKS
6
+ * and widget-session routes already use.
7
+ *
8
+ * @module @memberjunction/server/auth
9
+ */
10
+ import { Router } from 'express';
11
+ import { rateLimit } from 'express-rate-limit';
12
+ import { LogError } from '@memberjunction/core';
13
+ import { AuthProviderEngine } from './AuthProviderEngine.js';
14
+ /** Mount path for the public catalog router. */
15
+ export const AUTH_CATALOG_MOUNT_PATH = '/auth';
16
+ /** Requests per window per IP. Generous — a browser makes one call per page load. */
17
+ const DEFAULT_RATE_LIMIT_MAX = 60;
18
+ /** Rate-limit window. */
19
+ const DEFAULT_RATE_LIMIT_WINDOW_MS = 60_000;
20
+ /**
21
+ * How long a browser may cache the catalog.
22
+ *
23
+ * Short by design: this drives the login screen, so an admin who enables a provider expects to
24
+ * see it without telling users to hard-refresh. A minute keeps the endpoint cheap without making
25
+ * configuration changes feel stuck.
26
+ */
27
+ const CACHE_MAX_AGE_SECONDS = 60;
28
+ /**
29
+ * Builds the unauthenticated `GET /auth/providers` router.
30
+ *
31
+ * **What it exposes.** Only `Active` + `ClientVisible` rows, projected to the public allow-list
32
+ * by {@link AuthProviderEngine.GetPublicCatalog}. Secret material is structurally unable to reach
33
+ * this response: `CredentialID` and `AdditionalConfiguration` are not part of the public shape,
34
+ * and non-primitive `ClientConfiguration` values are dropped rather than serialized.
35
+ *
36
+ * **Why publishing this is safe.** Every value here was already shipped to anonymous users — a
37
+ * single-provider SPA compiled its client ID, domain and issuer straight into its JavaScript
38
+ * bundle. This endpoint moves that same data behind one source of truth; it does not widen what
39
+ * an anonymous caller can learn.
40
+ *
41
+ * **Failure is empty, not an error.** If the catalog cannot be read, the endpoint returns an empty
42
+ * list so the browser falls back to its compiled `AUTH_TYPE` and the user can still sign in.
43
+ * Returning 500 would take the login screen down for a problem the client can route around.
44
+ */
45
+ export function createAuthProviderCatalogRouter() {
46
+ const router = Router();
47
+ const limiter = rateLimit({
48
+ windowMs: DEFAULT_RATE_LIMIT_WINDOW_MS,
49
+ limit: DEFAULT_RATE_LIMIT_MAX,
50
+ standardHeaders: 'draft-7',
51
+ legacyHeaders: false,
52
+ message: { providers: [] }
53
+ });
54
+ router.get('/providers', limiter, (_req, res) => {
55
+ try {
56
+ const body = { providers: AuthProviderEngine.Instance.GetPublicCatalog() };
57
+ res.set('Cache-Control', `public, max-age=${CACHE_MAX_AGE_SECONDS}`);
58
+ res.status(200).json(body);
59
+ }
60
+ catch (error) {
61
+ const message = error instanceof Error ? error.message : String(error);
62
+ LogError(`[Auth] Failed to serve the public provider catalog: ${message}`);
63
+ const empty = { providers: [] };
64
+ res.status(200).json(empty);
65
+ }
66
+ });
67
+ return router;
68
+ }
69
+ //# sourceMappingURL=AuthProviderCatalogRouter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthProviderCatalogRouter.js","sourceRoot":"","sources":["../../src/auth/AuthProviderCatalogRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAA+B,MAAM,SAAS,CAAC;A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AAQ,CAAC,uDAAuD,OAAO,EAAE,CAAC,CAAC;YAC3E,MAAM,KAAK,GAA8B,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;YAC3D,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @fileoverview Metadata-driven authentication provider catalog.
3
+ *
4
+ * Loads `MJ: Authentication Providers` rows and registers each one with the runtime
5
+ * `AuthProviderFactory`, resolving the concrete driver through `ClassFactory` by `DriverClass`.
6
+ * This is the auth subsystem's equivalent of the File Storage `ServerDriverKey` pattern:
7
+ * adding a provider is a subclass plus a row, never an edit to core code.
8
+ *
9
+ * @module @memberjunction/server/auth
10
+ */
11
+ import { BaseEngine, UserInfo, type IMetadataProvider, type PublicAuthProviderInfo } from '@memberjunction/core';
12
+ import { MJAuthenticationProviderEntity } from '@memberjunction/core-entities';
13
+ /**
14
+ * Loads the authentication-provider catalog from metadata and registers it with the
15
+ * {@link AuthProviderFactory}.
16
+ *
17
+ * **Not `deferred`**: no authenticated request may be served before the catalog is registered,
18
+ * or tokens from a metadata-defined provider would be rejected during the startup window.
19
+ *
20
+ * **Severity is `warn`, not `fatal`**, and that is deliberate. This engine is one of two possible
21
+ * sources of providers — `initializeAuthProviders` also registers whatever `mj.config.cjs`
22
+ * declares. Making a catalog load failure fatal would turn a transient metadata problem into a
23
+ * total authentication outage for deployments that never adopted the table. The failure is
24
+ * logged loudly and the config-declared providers still stand.
25
+ */
26
+ export declare class AuthProviderEngine extends BaseEngine<AuthProviderEngine> {
27
+ private _providers;
28
+ static get Instance(): AuthProviderEngine;
29
+ /**
30
+ * Loads Active providers only. Inactive rows are excluded at the query rather than filtered
31
+ * later, so a disabled provider is never even instantiated.
32
+ */
33
+ Config(forceRefresh?: boolean, contextUser?: UserInfo, provider?: IMetadataProvider): Promise<void>;
34
+ /** Active providers from metadata, ordered for presentation. */
35
+ get Providers(): MJAuthenticationProviderEntity[];
36
+ /**
37
+ * Startup hook: load the catalog, then register every row with the factory.
38
+ */
39
+ HandleStartup(contextUser?: UserInfo, provider?: IMetadataProvider): Promise<void>;
40
+ /**
41
+ * Instantiates and registers every catalog row with the {@link AuthProviderFactory}.
42
+ *
43
+ * One bad row must not cost the deployment its other providers, so each registration is
44
+ * isolated: a failure is logged with the offending provider's name and the loop continues.
45
+ *
46
+ * @returns the number of providers successfully registered.
47
+ */
48
+ RegisterAll(contextUser?: UserInfo): Promise<number>;
49
+ /**
50
+ * Projects a catalog row onto the runtime {@link AuthProviderConfig} the driver expects.
51
+ *
52
+ * `AdditionalConfiguration` is spread FIRST so that the modelled columns win over anything a
53
+ * driver-specific blob happens to repeat — the columns are the reviewable, described surface,
54
+ * and a JSON blob must not be able to silently redefine the issuer a token is validated against.
55
+ */
56
+ private buildProviderConfig;
57
+ /**
58
+ * Splits the delimited `Scopes` column into the parsed list both projections publish.
59
+ *
60
+ * This is the single home of the delimiter convention: `buildProviderConfig` and
61
+ * `GetPublicCatalog` must agree on it, or the server would validate tokens against one scope
62
+ * set while telling the browser to request another.
63
+ */
64
+ private parseScopes;
65
+ /**
66
+ * Decrypts the row's linked credential, when it has one.
67
+ *
68
+ * Almost every provider validates tokens against a public JWKS and needs no secret at all, so
69
+ * this is the uncommon path — present for confidential-client flows, management APIs, and SCIM.
70
+ */
71
+ private resolveCredential;
72
+ /**
73
+ * Parses a JSON configuration column, treating malformed content as absent.
74
+ *
75
+ * Throwing here would take down an otherwise-valid provider over a stray character in an
76
+ * optional extras blob, so the row is registered without the extras and the problem is logged.
77
+ */
78
+ private parseJsonColumn;
79
+ /**
80
+ * Projects the catalog to the PUBLIC shape served by the unauthenticated catalog endpoint.
81
+ *
82
+ * The projection is an explicit allow-list rather than a redaction of the full row: a column
83
+ * added to this entity later is invisible to anonymous callers until someone deliberately adds
84
+ * it here. `AdditionalConfiguration` and `CredentialID` are structurally absent, never merely
85
+ * omitted at serialization time.
86
+ */
87
+ GetPublicCatalog(): PublicAuthProviderInfo[];
88
+ /**
89
+ * Flattens a parsed `ClientConfiguration` blob to the primitive key/value shape the browser
90
+ * contract declares. Nested objects and arrays are dropped with a warning rather than passed
91
+ * through, so a structured blob (the shape a credential would take) cannot ride along to an
92
+ * anonymous caller.
93
+ */
94
+ private toPublicClientConfig;
95
+ }
96
+ //# sourceMappingURL=AuthProviderEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthProviderEngine.d.ts","sourceRoot":"","sources":["../../src/auth/AuthProviderEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,UAAU,EAKV,QAAQ,EAER,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAU/E;;;;;;;;;;;;GAYG;AACH,qBAMa,kBAAmB,SAAQ,UAAU,CAAC,kBAAkB,CAAC;IACpE,OAAO,CAAC,UAAU,CAAwC;IAE1D,WAAkB,QAAQ,IAAI,kBAAkB,CAE/C;IAED;;;OAGG;IACU,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAahH,gEAAgE;IAChE,IAAW,SAAS,IAAI,8BAA8B,EAAE,CAEvD;IAED;;OAEG;IACU,aAAa,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/F;;;;;;;OAOG;IACU,WAAW,CAAC,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAqBjE;;;;;;OAMG;YACW,mBAAmB;IAqBjC;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAInB;;;;;OAKG;YACW,iBAAiB;IAa/B;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAiBvB;;;;;;;OAOG;IACI,gBAAgB,IAAI,sBAAsB,EAAE;IA6BnD;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;CAW7B"}
@@ -0,0 +1,245 @@
1
+ /**
2
+ * @fileoverview Metadata-driven authentication provider catalog.
3
+ *
4
+ * Loads `MJ: Authentication Providers` rows and registers each one with the runtime
5
+ * `AuthProviderFactory`, resolving the concrete driver through `ClassFactory` by `DriverClass`.
6
+ * This is the auth subsystem's equivalent of the File Storage `ServerDriverKey` pattern:
7
+ * adding a provider is a subclass plus a row, never an edit to core code.
8
+ *
9
+ * @module @memberjunction/server/auth
10
+ */
11
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
12
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
14
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
15
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
16
+ };
17
+ import { BaseEngine, LogError, LogStatusEx, RegisterForStartup } from '@memberjunction/core';
18
+ import { AuthProviderFactory } from '@memberjunction/auth-providers';
19
+ import { CredentialEngine } from '@memberjunction/credentials';
20
+ /**
21
+ * Subsystem label used when this engine asks CredentialEngine to decrypt secret material,
22
+ * so credential-access auditing attributes the read to authentication.
23
+ */
24
+ const CREDENTIAL_SUBSYSTEM = 'Authentication';
25
+ /**
26
+ * Loads the authentication-provider catalog from metadata and registers it with the
27
+ * {@link AuthProviderFactory}.
28
+ *
29
+ * **Not `deferred`**: no authenticated request may be served before the catalog is registered,
30
+ * or tokens from a metadata-defined provider would be rejected during the startup window.
31
+ *
32
+ * **Severity is `warn`, not `fatal`**, and that is deliberate. This engine is one of two possible
33
+ * sources of providers — `initializeAuthProviders` also registers whatever `mj.config.cjs`
34
+ * declares. Making a catalog load failure fatal would turn a transient metadata problem into a
35
+ * total authentication outage for deployments that never adopted the table. The failure is
36
+ * logged loudly and the config-declared providers still stand.
37
+ */
38
+ let AuthProviderEngine = class AuthProviderEngine extends BaseEngine {
39
+ constructor() {
40
+ super(...arguments);
41
+ this._providers = [];
42
+ }
43
+ static get Instance() {
44
+ return super.getInstance();
45
+ }
46
+ /**
47
+ * Loads Active providers only. Inactive rows are excluded at the query rather than filtered
48
+ * later, so a disabled provider is never even instantiated.
49
+ */
50
+ async Config(forceRefresh, contextUser, provider) {
51
+ const configs = [
52
+ {
53
+ PropertyName: '_providers',
54
+ EntityName: 'MJ: Authentication Providers',
55
+ Filter: `Status='Active'`,
56
+ OrderBy: 'Sequence ASC, Name ASC',
57
+ CacheLocal: true
58
+ }
59
+ ];
60
+ await this.Load(configs, provider, forceRefresh, contextUser);
61
+ }
62
+ /** Active providers from metadata, ordered for presentation. */
63
+ get Providers() {
64
+ return this.GetConfigData('_providers');
65
+ }
66
+ /**
67
+ * Startup hook: load the catalog, then register every row with the factory.
68
+ */
69
+ async HandleStartup(contextUser, provider) {
70
+ await this.Config(false, contextUser, provider);
71
+ await this.RegisterAll(contextUser);
72
+ }
73
+ /**
74
+ * Instantiates and registers every catalog row with the {@link AuthProviderFactory}.
75
+ *
76
+ * One bad row must not cost the deployment its other providers, so each registration is
77
+ * isolated: a failure is logged with the offending provider's name and the loop continues.
78
+ *
79
+ * @returns the number of providers successfully registered.
80
+ */
81
+ async RegisterAll(contextUser) {
82
+ const factory = AuthProviderFactory.Instance;
83
+ let registered = 0;
84
+ for (const row of this.Providers) {
85
+ try {
86
+ const config = await this.buildProviderConfig(row, contextUser);
87
+ factory.register(AuthProviderFactory.createProvider(config));
88
+ registered++;
89
+ }
90
+ catch (error) {
91
+ const message = error instanceof Error ? error.message : String(error);
92
+ LogError(`[Auth] Could not register metadata provider '${row.Name}' (DriverClass '${row.DriverClass}'): ${message}`);
93
+ }
94
+ }
95
+ if (registered > 0) {
96
+ LogStatusEx({ message: `[Auth] Registered ${registered} provider(s) from metadata.`, verboseOnly: true });
97
+ }
98
+ return registered;
99
+ }
100
+ /**
101
+ * Projects a catalog row onto the runtime {@link AuthProviderConfig} the driver expects.
102
+ *
103
+ * `AdditionalConfiguration` is spread FIRST so that the modelled columns win over anything a
104
+ * driver-specific blob happens to repeat — the columns are the reviewable, described surface,
105
+ * and a JSON blob must not be able to silently redefine the issuer a token is validated against.
106
+ */
107
+ async buildProviderConfig(row, contextUser) {
108
+ const additional = this.parseJsonColumn(row.AdditionalConfiguration, row.Name, 'AdditionalConfiguration');
109
+ const secrets = await this.resolveCredential(row, contextUser);
110
+ const config = {
111
+ ...additional,
112
+ ...secrets,
113
+ name: row.Name,
114
+ type: row.DriverClass
115
+ };
116
+ if (row.ClientID)
117
+ config.clientId = row.ClientID;
118
+ if (row.Domain)
119
+ config.domain = row.Domain;
120
+ if (row.Issuer)
121
+ config.issuer = row.Issuer;
122
+ if (row.Audience)
123
+ config.audience = row.Audience;
124
+ if (row.JWKSUri)
125
+ config.jwksUri = row.JWKSUri;
126
+ if (row.Scopes)
127
+ config.scopes = this.parseScopes(row.Scopes);
128
+ return config;
129
+ }
130
+ /**
131
+ * Splits the delimited `Scopes` column into the parsed list both projections publish.
132
+ *
133
+ * This is the single home of the delimiter convention: `buildProviderConfig` and
134
+ * `GetPublicCatalog` must agree on it, or the server would validate tokens against one scope
135
+ * set while telling the browser to request another.
136
+ */
137
+ parseScopes(raw) {
138
+ return raw ? raw.split(/[\s,]+/).filter((s) => s.length > 0) : [];
139
+ }
140
+ /**
141
+ * Decrypts the row's linked credential, when it has one.
142
+ *
143
+ * Almost every provider validates tokens against a public JWKS and needs no secret at all, so
144
+ * this is the uncommon path — present for confidential-client flows, management APIs, and SCIM.
145
+ */
146
+ async resolveCredential(row, contextUser) {
147
+ if (!row.CredentialID || !row.Credential) {
148
+ return {};
149
+ }
150
+ await CredentialEngine.Instance.Config(false, contextUser);
151
+ const resolved = await CredentialEngine.Instance.getCredential(row.Credential, {
152
+ contextUser,
153
+ subsystem: CREDENTIAL_SUBSYSTEM
154
+ });
155
+ return resolved.values;
156
+ }
157
+ /**
158
+ * Parses a JSON configuration column, treating malformed content as absent.
159
+ *
160
+ * Throwing here would take down an otherwise-valid provider over a stray character in an
161
+ * optional extras blob, so the row is registered without the extras and the problem is logged.
162
+ */
163
+ parseJsonColumn(raw, providerName, columnName) {
164
+ if (!raw?.trim()) {
165
+ return {};
166
+ }
167
+ try {
168
+ const parsed = JSON.parse(raw);
169
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
170
+ return parsed;
171
+ }
172
+ LogError(`[Auth] ${columnName} on provider '${providerName}' is not a JSON object; ignoring it.`);
173
+ }
174
+ catch (error) {
175
+ const message = error instanceof Error ? error.message : String(error);
176
+ LogError(`[Auth] ${columnName} on provider '${providerName}' is not valid JSON (${message}); ignoring it.`);
177
+ }
178
+ return {};
179
+ }
180
+ /**
181
+ * Projects the catalog to the PUBLIC shape served by the unauthenticated catalog endpoint.
182
+ *
183
+ * The projection is an explicit allow-list rather than a redaction of the full row: a column
184
+ * added to this entity later is invisible to anonymous callers until someone deliberately adds
185
+ * it here. `AdditionalConfiguration` and `CredentialID` are structurally absent, never merely
186
+ * omitted at serialization time.
187
+ */
188
+ GetPublicCatalog() {
189
+ return this.Providers.filter((row) => row.ClientVisible).map((row) => {
190
+ const info = {
191
+ name: row.Name,
192
+ driverClass: row.DriverClass,
193
+ displayName: row.DisplayName ?? row.Name,
194
+ sequence: row.Sequence,
195
+ isDefault: row.IsDefault
196
+ };
197
+ if (row.Icon)
198
+ info.icon = row.Icon;
199
+ if (row.ClientID)
200
+ info.clientId = row.ClientID;
201
+ if (row.Issuer)
202
+ info.issuer = row.Issuer;
203
+ if (row.Domain)
204
+ info.domain = row.Domain;
205
+ // Published pre-parsed so the browser never re-derives the delimiter convention —
206
+ // the drivers hand this straight to SDK config typed string[].
207
+ const scopes = this.parseScopes(row.Scopes);
208
+ if (scopes.length > 0)
209
+ info.scopes = scopes;
210
+ const clientConfig = this.parseJsonColumn(row.ClientConfiguration, row.Name, 'ClientConfiguration');
211
+ if (Object.keys(clientConfig).length > 0) {
212
+ info.clientConfiguration = this.toPublicClientConfig(clientConfig, row.Name);
213
+ }
214
+ return info;
215
+ });
216
+ }
217
+ /**
218
+ * Flattens a parsed `ClientConfiguration` blob to the primitive key/value shape the browser
219
+ * contract declares. Nested objects and arrays are dropped with a warning rather than passed
220
+ * through, so a structured blob (the shape a credential would take) cannot ride along to an
221
+ * anonymous caller.
222
+ */
223
+ toPublicClientConfig(parsed, providerName) {
224
+ const result = {};
225
+ for (const [key, value] of Object.entries(parsed)) {
226
+ if (value === null || ['string', 'number', 'boolean'].includes(typeof value)) {
227
+ result[key] = value;
228
+ }
229
+ else {
230
+ LogError(`[Auth] ClientConfiguration key '${key}' on provider '${providerName}' is not a primitive value; it was NOT published to the public catalog.`);
231
+ }
232
+ }
233
+ return result;
234
+ }
235
+ };
236
+ AuthProviderEngine = __decorate([
237
+ RegisterForStartup({
238
+ priority: 20,
239
+ severity: 'warn',
240
+ deferred: false,
241
+ description: 'Loads the metadata authentication-provider catalog and registers it with AuthProviderFactory'
242
+ })
243
+ ], AuthProviderEngine);
244
+ export { AuthProviderEngine };
245
+ //# sourceMappingURL=AuthProviderEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthProviderEngine.js","sourceRoot":"","sources":["../../src/auth/AuthProviderEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;;;;;;;AAEH,OAAO,EACL,UAAU,EAEV,QAAQ,EACR,WAAW,EACX,kBAAkB,EAKnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM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