@boxyhq/saml-jackson 1.33.0 → 1.33.1-beta.1

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 (288) hide show
  1. package/dist/controller/oauth/oidc-client.d.ts +3 -3
  2. package/dist/controller/oauth/oidc-client.js +2 -1
  3. package/dist/controller/oauth/oidc-client.js.map +1 -1
  4. package/dist/controller/oauth/oidc-issuer.d.ts +2 -0
  5. package/dist/controller/oauth/oidc-issuer.js +25 -0
  6. package/dist/controller/oauth/oidc-issuer.js.map +1 -0
  7. package/dist/controller/oauth.js +36 -35
  8. package/dist/controller/oauth.js.map +1 -1
  9. package/dist/controller/sso-handler.js +1 -1
  10. package/dist/controller/sso-handler.js.map +1 -1
  11. package/dist/controller/utils.d.ts +5 -3
  12. package/dist/controller/utils.js +10 -2
  13. package/dist/controller/utils.js.map +1 -1
  14. package/dist/src/controller/admin.d.ts +27 -0
  15. package/dist/src/controller/admin.js +60 -0
  16. package/dist/src/controller/admin.js.map +1 -0
  17. package/dist/src/controller/analytics.d.ts +16 -0
  18. package/dist/src/controller/analytics.js +79 -0
  19. package/dist/src/controller/analytics.js.map +1 -0
  20. package/dist/src/controller/api.d.ts +557 -0
  21. package/dist/src/controller/api.js +806 -0
  22. package/dist/src/controller/api.js.map +1 -0
  23. package/dist/src/controller/connection/oidc.d.ts +7 -0
  24. package/dist/src/controller/connection/oidc.js +181 -0
  25. package/dist/src/controller/connection/oidc.js.map +1 -0
  26. package/dist/src/controller/connection/saml.d.ts +7 -0
  27. package/dist/src/controller/connection/saml.js +250 -0
  28. package/dist/src/controller/connection/saml.js.map +1 -0
  29. package/dist/src/controller/error.d.ts +10 -0
  30. package/dist/src/controller/error.js +13 -0
  31. package/dist/src/controller/error.js.map +1 -0
  32. package/dist/src/controller/health-check.d.ts +11 -0
  33. package/dist/src/controller/health-check.js +51 -0
  34. package/dist/src/controller/health-check.js.map +1 -0
  35. package/dist/src/controller/logout.d.ts +18 -0
  36. package/dist/src/controller/logout.js +132 -0
  37. package/dist/src/controller/logout.js.map +1 -0
  38. package/dist/src/controller/oauth/allowed.d.ts +1 -0
  39. package/dist/src/controller/oauth/allowed.js +30 -0
  40. package/dist/src/controller/oauth/allowed.js.map +1 -0
  41. package/dist/src/controller/oauth/code-verifier.d.ts +1 -0
  42. package/dist/src/controller/oauth/code-verifier.js +8 -0
  43. package/dist/src/controller/oauth/code-verifier.js.map +1 -0
  44. package/dist/src/controller/oauth/oidc-client.d.ts +12 -0
  45. package/dist/src/controller/oauth/oidc-client.js +89 -0
  46. package/dist/src/controller/oauth/oidc-client.js.map +1 -0
  47. package/dist/src/controller/oauth/redirect.d.ts +1 -0
  48. package/dist/src/controller/oauth/redirect.js +13 -0
  49. package/dist/src/controller/oauth/redirect.js.map +1 -0
  50. package/dist/src/controller/oauth.d.ts +142 -0
  51. package/dist/src/controller/oauth.js +1112 -0
  52. package/dist/src/controller/oauth.js.map +1 -0
  53. package/dist/src/controller/oidc-discovery.d.ts +22 -0
  54. package/dist/src/controller/oidc-discovery.js +47 -0
  55. package/dist/src/controller/oidc-discovery.js.map +1 -0
  56. package/dist/src/controller/setup-link.d.ts +307 -0
  57. package/dist/src/controller/setup-link.js +462 -0
  58. package/dist/src/controller/setup-link.js.map +1 -0
  59. package/dist/src/controller/sp-config.d.ts +22 -0
  60. package/dist/src/controller/sp-config.js +89 -0
  61. package/dist/src/controller/sp-config.js.map +1 -0
  62. package/dist/src/controller/sso-handler.d.ts +66 -0
  63. package/dist/src/controller/sso-handler.js +306 -0
  64. package/dist/src/controller/sso-handler.js.map +1 -0
  65. package/dist/src/controller/utils.d.ts +84 -0
  66. package/dist/src/controller/utils.js +328 -0
  67. package/dist/src/controller/utils.js.map +1 -0
  68. package/dist/src/cron/lock.d.ts +18 -0
  69. package/dist/src/cron/lock.js +98 -0
  70. package/dist/src/cron/lock.js.map +1 -0
  71. package/dist/src/db/db.d.ts +5 -0
  72. package/dist/src/db/db.js +178 -0
  73. package/dist/src/db/db.js.map +1 -0
  74. package/dist/src/db/defaultDb.d.ts +2 -0
  75. package/dist/src/db/defaultDb.js +18 -0
  76. package/dist/src/db/defaultDb.js.map +1 -0
  77. package/dist/src/db/dynamoDb.d.ts +19 -0
  78. package/dist/src/db/dynamoDb.js +320 -0
  79. package/dist/src/db/dynamoDb.js.map +1 -0
  80. package/dist/src/db/encrypter.d.ts +3 -0
  81. package/dist/src/db/encrypter.js +22 -0
  82. package/dist/src/db/encrypter.js.map +1 -0
  83. package/dist/src/db/mem.d.ts +23 -0
  84. package/dist/src/db/mem.js +186 -0
  85. package/dist/src/db/mem.js.map +1 -0
  86. package/dist/src/db/mongo.d.ts +22 -0
  87. package/dist/src/db/mongo.js +177 -0
  88. package/dist/src/db/mongo.js.map +1 -0
  89. package/dist/src/db/planetscale/entity/JacksonIndex.d.ts +5 -0
  90. package/dist/src/db/planetscale/entity/JacksonIndex.js +32 -0
  91. package/dist/src/db/planetscale/entity/JacksonIndex.js.map +1 -0
  92. package/dist/src/db/planetscale/entity/JacksonStore.d.ts +9 -0
  93. package/dist/src/db/planetscale/entity/JacksonStore.js +63 -0
  94. package/dist/src/db/planetscale/entity/JacksonStore.js.map +1 -0
  95. package/dist/src/db/planetscale/entity/JacksonTTL.d.ts +4 -0
  96. package/dist/src/db/planetscale/entity/JacksonTTL.js +27 -0
  97. package/dist/src/db/planetscale/entity/JacksonTTL.js.map +1 -0
  98. package/dist/src/db/redis.d.ts +18 -0
  99. package/dist/src/db/redis.js +214 -0
  100. package/dist/src/db/redis.js.map +1 -0
  101. package/dist/src/db/sql/entity/JacksonIndex.d.ts +7 -0
  102. package/dist/src/db/sql/entity/JacksonIndex.js +39 -0
  103. package/dist/src/db/sql/entity/JacksonIndex.js.map +1 -0
  104. package/dist/src/db/sql/entity/JacksonStore.d.ts +9 -0
  105. package/dist/src/db/sql/entity/JacksonStore.js +61 -0
  106. package/dist/src/db/sql/entity/JacksonStore.js.map +1 -0
  107. package/dist/src/db/sql/entity/JacksonTTL.d.ts +4 -0
  108. package/dist/src/db/sql/entity/JacksonTTL.js +27 -0
  109. package/dist/src/db/sql/entity/JacksonTTL.js.map +1 -0
  110. package/dist/src/db/sql/mariadb/entity/JacksonIndex.d.ts +7 -0
  111. package/dist/src/db/sql/mariadb/entity/JacksonIndex.js +39 -0
  112. package/dist/src/db/sql/mariadb/entity/JacksonIndex.js.map +1 -0
  113. package/dist/src/db/sql/mariadb/entity/JacksonStore.d.ts +9 -0
  114. package/dist/src/db/sql/mariadb/entity/JacksonStore.js +63 -0
  115. package/dist/src/db/sql/mariadb/entity/JacksonStore.js.map +1 -0
  116. package/dist/src/db/sql/mariadb/entity/JacksonTTL.d.ts +4 -0
  117. package/dist/src/db/sql/mariadb/entity/JacksonTTL.js +27 -0
  118. package/dist/src/db/sql/mariadb/entity/JacksonTTL.js.map +1 -0
  119. package/dist/src/db/sql/mssql/entity/JacksonIndex.d.ts +7 -0
  120. package/dist/src/db/sql/mssql/entity/JacksonIndex.js +39 -0
  121. package/dist/src/db/sql/mssql/entity/JacksonIndex.js.map +1 -0
  122. package/dist/src/db/sql/mssql/entity/JacksonStore.d.ts +9 -0
  123. package/dist/src/db/sql/mssql/entity/JacksonStore.js +61 -0
  124. package/dist/src/db/sql/mssql/entity/JacksonStore.js.map +1 -0
  125. package/dist/src/db/sql/mssql/entity/JacksonTTL.d.ts +4 -0
  126. package/dist/src/db/sql/mssql/entity/JacksonTTL.js +27 -0
  127. package/dist/src/db/sql/mssql/entity/JacksonTTL.js.map +1 -0
  128. package/dist/src/db/sql/mssql.d.ts +1 -0
  129. package/dist/src/db/sql/mssql.js +44 -0
  130. package/dist/src/db/sql/mssql.js.map +1 -0
  131. package/dist/src/db/sql/sql.d.ts +32 -0
  132. package/dist/src/db/sql/sql.js +318 -0
  133. package/dist/src/db/sql/sql.js.map +1 -0
  134. package/dist/src/db/sql/sqlite/entity/JacksonIndex.d.ts +7 -0
  135. package/dist/src/db/sql/sqlite/entity/JacksonIndex.js +39 -0
  136. package/dist/src/db/sql/sqlite/entity/JacksonIndex.js.map +1 -0
  137. package/dist/src/db/sql/sqlite/entity/JacksonStore.d.ts +9 -0
  138. package/dist/src/db/sql/sqlite/entity/JacksonStore.js +61 -0
  139. package/dist/src/db/sql/sqlite/entity/JacksonStore.js.map +1 -0
  140. package/dist/src/db/sql/sqlite/entity/JacksonTTL.d.ts +4 -0
  141. package/dist/src/db/sql/sqlite/entity/JacksonTTL.js +27 -0
  142. package/dist/src/db/sql/sqlite/entity/JacksonTTL.js.map +1 -0
  143. package/dist/src/db/store.d.ts +5 -0
  144. package/dist/src/db/store.js +65 -0
  145. package/dist/src/db/store.js.map +1 -0
  146. package/dist/src/db/utils.d.ts +16 -0
  147. package/dist/src/db/utils.js +28 -0
  148. package/dist/src/db/utils.js.map +1 -0
  149. package/dist/src/directory-sync/batch-events/queue.d.ts +40 -0
  150. package/dist/src/directory-sync/batch-events/queue.js +225 -0
  151. package/dist/src/directory-sync/batch-events/queue.js.map +1 -0
  152. package/dist/src/directory-sync/index.d.ts +27 -0
  153. package/dist/src/directory-sync/index.js +97 -0
  154. package/dist/src/directory-sync/index.js.map +1 -0
  155. package/dist/src/directory-sync/non-scim/google/api.d.ts +36 -0
  156. package/dist/src/directory-sync/non-scim/google/api.js +143 -0
  157. package/dist/src/directory-sync/non-scim/google/api.js.map +1 -0
  158. package/dist/src/directory-sync/non-scim/google/index.d.ts +12 -0
  159. package/dist/src/directory-sync/non-scim/google/index.js +10 -0
  160. package/dist/src/directory-sync/non-scim/google/index.js.map +1 -0
  161. package/dist/src/directory-sync/non-scim/google/oauth.d.ts +27 -0
  162. package/dist/src/directory-sync/non-scim/google/oauth.js +105 -0
  163. package/dist/src/directory-sync/non-scim/google/oauth.js.map +1 -0
  164. package/dist/src/directory-sync/non-scim/index.d.ts +24 -0
  165. package/dist/src/directory-sync/non-scim/index.js +85 -0
  166. package/dist/src/directory-sync/non-scim/index.js.map +1 -0
  167. package/dist/src/directory-sync/non-scim/syncGroupMembers.d.ts +23 -0
  168. package/dist/src/directory-sync/non-scim/syncGroupMembers.js +105 -0
  169. package/dist/src/directory-sync/non-scim/syncGroupMembers.js.map +1 -0
  170. package/dist/src/directory-sync/non-scim/syncGroups.d.ts +24 -0
  171. package/dist/src/directory-sync/non-scim/syncGroups.js +120 -0
  172. package/dist/src/directory-sync/non-scim/syncGroups.js.map +1 -0
  173. package/dist/src/directory-sync/non-scim/syncUsers.d.ts +24 -0
  174. package/dist/src/directory-sync/non-scim/syncUsers.js +120 -0
  175. package/dist/src/directory-sync/non-scim/syncUsers.js.map +1 -0
  176. package/dist/src/directory-sync/non-scim/utils.d.ts +36 -0
  177. package/dist/src/directory-sync/non-scim/utils.js +109 -0
  178. package/dist/src/directory-sync/non-scim/utils.js.map +1 -0
  179. package/dist/src/directory-sync/request.d.ts +14 -0
  180. package/dist/src/directory-sync/request.js +29 -0
  181. package/dist/src/directory-sync/request.js.map +1 -0
  182. package/dist/src/directory-sync/scim/Base.d.ts +12 -0
  183. package/dist/src/directory-sync/scim/Base.js +23 -0
  184. package/dist/src/directory-sync/scim/Base.js.map +1 -0
  185. package/dist/src/directory-sync/scim/DirectoryConfig.d.ts +343 -0
  186. package/dist/src/directory-sync/scim/DirectoryConfig.js +580 -0
  187. package/dist/src/directory-sync/scim/DirectoryConfig.js.map +1 -0
  188. package/dist/src/directory-sync/scim/DirectoryGroups.d.ts +28 -0
  189. package/dist/src/directory-sync/scim/DirectoryGroups.js +252 -0
  190. package/dist/src/directory-sync/scim/DirectoryGroups.js.map +1 -0
  191. package/dist/src/directory-sync/scim/DirectoryUsers.d.ts +25 -0
  192. package/dist/src/directory-sync/scim/DirectoryUsers.js +193 -0
  193. package/dist/src/directory-sync/scim/DirectoryUsers.js.map +1 -0
  194. package/dist/src/directory-sync/scim/Groups.d.ts +166 -0
  195. package/dist/src/directory-sync/scim/Groups.js +348 -0
  196. package/dist/src/directory-sync/scim/Groups.js.map +1 -0
  197. package/dist/src/directory-sync/scim/Users.d.ts +99 -0
  198. package/dist/src/directory-sync/scim/Users.js +215 -0
  199. package/dist/src/directory-sync/scim/Users.js.map +1 -0
  200. package/dist/src/directory-sync/scim/WebhookEventsLogger.d.ts +101 -0
  201. package/dist/src/directory-sync/scim/WebhookEventsLogger.js +165 -0
  202. package/dist/src/directory-sync/scim/WebhookEventsLogger.js.map +1 -0
  203. package/dist/src/directory-sync/scim/transform.d.ts +6 -0
  204. package/dist/src/directory-sync/scim/transform.js +37 -0
  205. package/dist/src/directory-sync/scim/transform.js.map +1 -0
  206. package/dist/src/directory-sync/scim/utils.d.ts +33 -0
  207. package/dist/src/directory-sync/scim/utils.js +129 -0
  208. package/dist/src/directory-sync/scim/utils.js.map +1 -0
  209. package/dist/src/directory-sync/types.d.ts +195 -0
  210. package/dist/src/directory-sync/types.js +10 -0
  211. package/dist/src/directory-sync/types.js.map +1 -0
  212. package/dist/src/directory-sync/utils.d.ts +19 -0
  213. package/dist/src/directory-sync/utils.js +56 -0
  214. package/dist/src/directory-sync/utils.js.map +1 -0
  215. package/dist/src/ee/branding/index.d.ts +17 -0
  216. package/dist/src/ee/branding/index.js +49 -0
  217. package/dist/src/ee/branding/index.js.map +1 -0
  218. package/dist/src/ee/common/checkLicense.d.ts +3 -0
  219. package/dist/src/ee/common/checkLicense.js +23 -0
  220. package/dist/src/ee/common/checkLicense.js.map +1 -0
  221. package/dist/src/ee/identity-federation/app.d.ts +328 -0
  222. package/dist/src/ee/identity-federation/app.js +532 -0
  223. package/dist/src/ee/identity-federation/app.js.map +1 -0
  224. package/dist/src/ee/identity-federation/idp-login.d.ts +18 -0
  225. package/dist/src/ee/identity-federation/idp-login.js +98 -0
  226. package/dist/src/ee/identity-federation/idp-login.js.map +1 -0
  227. package/dist/src/ee/identity-federation/index.d.ts +15 -0
  228. package/dist/src/ee/identity-federation/index.js +43 -0
  229. package/dist/src/ee/identity-federation/index.js.map +1 -0
  230. package/dist/src/ee/identity-federation/sso.d.ts +24 -0
  231. package/dist/src/ee/identity-federation/sso.js +124 -0
  232. package/dist/src/ee/identity-federation/sso.js.map +1 -0
  233. package/dist/src/ee/identity-federation/types.d.ts +38 -0
  234. package/dist/src/ee/identity-federation/types.js +2 -0
  235. package/dist/src/ee/identity-federation/types.js.map +1 -0
  236. package/dist/src/ee/ory/ory.d.ts +18 -0
  237. package/dist/src/ee/ory/ory.js +195 -0
  238. package/dist/src/ee/ory/ory.js.map +1 -0
  239. package/dist/src/ee/product/index.d.ts +14 -0
  240. package/dist/src/ee/product/index.js +45 -0
  241. package/dist/src/ee/product/index.js.map +1 -0
  242. package/dist/src/event/axios.d.ts +2 -0
  243. package/dist/src/event/axios.js +27 -0
  244. package/dist/src/event/axios.js.map +1 -0
  245. package/dist/src/event/index.d.ts +11 -0
  246. package/dist/src/event/index.js +53 -0
  247. package/dist/src/event/index.js.map +1 -0
  248. package/dist/src/event/types.d.ts +21 -0
  249. package/dist/src/event/types.js +2 -0
  250. package/dist/src/event/types.js.map +1 -0
  251. package/dist/src/event/utils.d.ts +4 -0
  252. package/dist/src/event/utils.js +33 -0
  253. package/dist/src/event/utils.js.map +1 -0
  254. package/dist/src/event/webhook.d.ts +3 -0
  255. package/dist/src/event/webhook.js +34 -0
  256. package/dist/src/event/webhook.js.map +1 -0
  257. package/dist/src/index.d.ts +35 -0
  258. package/dist/src/index.js +161 -0
  259. package/dist/src/index.js.map +1 -0
  260. package/dist/src/loadConnection.d.ts +4 -0
  261. package/dist/src/loadConnection.js +38 -0
  262. package/dist/src/loadConnection.js.map +1 -0
  263. package/dist/src/opentelemetry/metrics.d.ts +14 -0
  264. package/dist/src/opentelemetry/metrics.js +64 -0
  265. package/dist/src/opentelemetry/metrics.js.map +1 -0
  266. package/dist/src/saml/claims.d.ts +12 -0
  267. package/dist/src/saml/claims.js +57 -0
  268. package/dist/src/saml/claims.js.map +1 -0
  269. package/dist/src/saml/lib.d.ts +8 -0
  270. package/dist/src/saml/lib.js +29 -0
  271. package/dist/src/saml/lib.js.map +1 -0
  272. package/dist/src/saml/x509.d.ts +9 -0
  273. package/dist/src/saml/x509.js +93 -0
  274. package/dist/src/saml/x509.js.map +1 -0
  275. package/dist/src/sso-traces/index.d.ts +114 -0
  276. package/dist/src/sso-traces/index.js +229 -0
  277. package/dist/src/sso-traces/index.js.map +1 -0
  278. package/dist/src/sso-traces/types.d.ts +44 -0
  279. package/dist/src/sso-traces/types.js +2 -0
  280. package/dist/src/sso-traces/types.js.map +1 -0
  281. package/dist/src/typings.d.ts +540 -0
  282. package/dist/src/typings.js +5 -0
  283. package/dist/src/typings.js.map +1 -0
  284. package/dist/typeorm.d.ts +3 -0
  285. package/dist/typeorm.js +58 -0
  286. package/dist/typeorm.js.map +1 -0
  287. package/dist/typings.d.ts +1 -1
  288. package/package.json +7 -7
@@ -0,0 +1,43 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { SSO } from './sso';
11
+ import { App } from './app';
12
+ import { SSOHandler } from '../../controller/sso-handler';
13
+ import { IdPLogin } from './idp-login';
14
+ // This is the main entry point for the Identity Federation module
15
+ const IdentityFederation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ db, opts, ssoTraces, }) {
16
+ const appStore = db.store('samlfed:apps');
17
+ const sessionStore = db.store('oauth:session', opts.db.ttl);
18
+ const connectionStore = db.store('saml:config');
19
+ const ssoHandler = new SSOHandler({
20
+ connection: connectionStore,
21
+ session: sessionStore,
22
+ opts,
23
+ });
24
+ const app = new App({ store: appStore, opts });
25
+ const sso = new SSO({ app, ssoHandler, ssoTraces, opts });
26
+ const idpLogin = new IdPLogin({ app, ssoHandler, ssoTraces, opts });
27
+ const response = {
28
+ app,
29
+ sso,
30
+ idpLogin,
31
+ };
32
+ return response;
33
+ });
34
+ export default IdentityFederation;
35
+ export * from './types';
36
+ // SAML Federation flow:
37
+ // SP (Eg: Twilio Flex) --> SAML Jackson --> IdP (Eg: Okta) --> SAML Jackson --> SP (Eg: Twilio Flex)
38
+ // 1. SP send SAML Request to Jackson's SSO endpoint
39
+ // 2. Jackson process SAML Request and create a new session to store SP request information
40
+ // 3. Jackson create a new SAML Request and send it to chosen IdP
41
+ // 4. After successful authentication, IdP send (POST) SAML Response to Jackson's ACS endpoint
42
+ // 5. Jackson process SAML Response from the IdP and create a new SAML Response to send (POST) back to the SP's ACS endpoint
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ee/identity-federation/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,kEAAkE;AAClE,MAAM,kBAAkB,GAAG,KAQxB,EAAE,4CAR6B,EAChC,EAAE,EACF,IAAI,EACJ,SAAS,GAKV;IACC,MAAM,QAAQ,GAAG,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,EAAE,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAC5D,MAAM,eAAe,GAAG,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAEhD,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC;QAChC,UAAU,EAAE,eAAe;QAC3B,OAAO,EAAE,YAAY;QACrB,IAAI;KACL,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEpE,MAAM,QAAQ,GAAG;QACf,GAAG;QACH,GAAG;QACH,QAAQ;KACT,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,eAAe,kBAAkB,CAAC;AAElC,cAAc,SAAS,CAAC;AAExB,wBAAwB;AACxB,qGAAqG;AACrG,oDAAoD;AACpD,2FAA2F;AAC3F,iEAAiE;AACjE,8FAA8F;AAC9F,4HAA4H"}
@@ -0,0 +1,24 @@
1
+ import { App } from './app';
2
+ import { SSOHandler } from '../../controller/sso-handler';
3
+ import type { JacksonOption, SSOTracesInstance } from '../../typings';
4
+ export declare class SSO {
5
+ private app;
6
+ private ssoHandler;
7
+ private ssoTraces;
8
+ private opts;
9
+ constructor({ app, ssoHandler, ssoTraces, opts, }: {
10
+ app: App;
11
+ ssoHandler: SSOHandler;
12
+ ssoTraces: SSOTracesInstance;
13
+ opts: JacksonOption;
14
+ });
15
+ getAuthorizeUrl: ({ request, relayState, idp_hint, samlBinding, }: {
16
+ request: string;
17
+ relayState: string;
18
+ samlBinding: "HTTP-POST" | "HTTP-Redirect";
19
+ idp_hint?: string;
20
+ }) => Promise<{
21
+ redirect_url: any;
22
+ authorize_form: any;
23
+ }>;
24
+ }
@@ -0,0 +1,124 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import saml from '@boxyhq/saml20';
11
+ import { JacksonError } from '../../controller/error';
12
+ import { getErrorMessage, isConnectionActive } from '../../controller/utils';
13
+ import { throwIfInvalidLicense } from '../common/checkLicense';
14
+ const isSAMLConnection = (connection) => {
15
+ return 'idpMetadata' in connection;
16
+ };
17
+ export class SSO {
18
+ constructor({ app, ssoHandler, ssoTraces, opts, }) {
19
+ // Accept the SAML Request from Service Provider, and create a new SAML Request to be sent to Identity Provider
20
+ this.getAuthorizeUrl = (_a) => __awaiter(this, [_a], void 0, function* ({ request, relayState, idp_hint, samlBinding, }) {
21
+ yield throwIfInvalidLicense(this.opts.boxyhqLicenseKey);
22
+ const isPostBinding = samlBinding === 'HTTP-POST';
23
+ let connection;
24
+ let app;
25
+ let id, acsUrl, entityId, publicKey, providerName, decodedRequest;
26
+ const context = {
27
+ isSAMLFederated: true,
28
+ relayState,
29
+ };
30
+ try {
31
+ decodedRequest = yield saml.decodeBase64(request, !isPostBinding);
32
+ context.samlRequest = decodedRequest || request;
33
+ const parsedSAMLRequest = yield saml.parseSAMLRequest(decodedRequest, isPostBinding);
34
+ id = parsedSAMLRequest.id;
35
+ entityId = parsedSAMLRequest.audience;
36
+ publicKey = parsedSAMLRequest.publicKey;
37
+ providerName = parsedSAMLRequest.providerName;
38
+ context.entityId = entityId;
39
+ context.providerName = providerName;
40
+ // Verify the request if it is signed
41
+ if (publicKey && !saml.hasValidSignature(decodedRequest, publicKey, null)) {
42
+ throw new JacksonError('Invalid SAML Request signature.', 400);
43
+ }
44
+ app = yield this.app.getByEntityId(entityId);
45
+ acsUrl = parsedSAMLRequest.acsUrl || app.acsUrl; // acsUrl is optional in the SAMLRequest
46
+ context.tenant = app.tenant;
47
+ context.product = app.product;
48
+ context.acsUrl = acsUrl;
49
+ if (app.acsUrl !== acsUrl) {
50
+ throw new JacksonError("Assertion Consumer Service URL doesn't match.", 400);
51
+ }
52
+ const response = yield this.ssoHandler.resolveConnection({
53
+ tenant: app.tenant,
54
+ product: app.product,
55
+ idp_hint,
56
+ authFlow: 'saml',
57
+ idFedAppId: app.id,
58
+ originalParams: {
59
+ RelayState: relayState,
60
+ SAMLRequest: request,
61
+ samlBinding,
62
+ },
63
+ tenants: app.tenants,
64
+ });
65
+ // If there is a redirect URL, then we need to redirect to that URL
66
+ if ('redirectUrl' in response) {
67
+ return {
68
+ redirect_url: response.redirectUrl,
69
+ authorize_form: null,
70
+ };
71
+ }
72
+ // If there is a connection, use that connection
73
+ if ('connection' in response) {
74
+ connection = response.connection;
75
+ }
76
+ if (!connection) {
77
+ throw new JacksonError('No SSO connection found.', 404);
78
+ }
79
+ context.clientID = connection.clientID;
80
+ if (!isConnectionActive(connection)) {
81
+ throw new JacksonError('SSO connection is deactivated. Please contact your administrator.', 403);
82
+ }
83
+ const requestParams = {
84
+ id,
85
+ acsUrl,
86
+ entityId,
87
+ publicKey,
88
+ providerName,
89
+ relayState,
90
+ tenant: app.tenant,
91
+ product: app.product,
92
+ };
93
+ return isSAMLConnection(connection)
94
+ ? yield this.ssoHandler.createSAMLRequest({
95
+ connection,
96
+ requestParams,
97
+ mappings: app.mappings,
98
+ })
99
+ : yield this.ssoHandler.createOIDCRequest({
100
+ connection,
101
+ requestParams,
102
+ mappings: app.mappings,
103
+ ssoTraces: {
104
+ instance: this.ssoTraces,
105
+ context,
106
+ },
107
+ });
108
+ }
109
+ catch (err) {
110
+ const error_description = getErrorMessage(err);
111
+ this.ssoTraces.saveTrace({
112
+ error: error_description,
113
+ context,
114
+ });
115
+ throw err;
116
+ }
117
+ });
118
+ this.app = app;
119
+ this.ssoHandler = ssoHandler;
120
+ this.ssoTraces = ssoTraces;
121
+ this.opts = opts;
122
+ }
123
+ }
124
+ //# sourceMappingURL=sso.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sso.js","sourceRoot":"","sources":["../../../../src/ee/identity-federation/sso.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAGlC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAUtD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,gBAAgB,GAAG,CAAC,UAAyC,EAA+B,EAAE;IAClG,OAAO,aAAa,IAAI,UAAU,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG;IAMd,YAAY,EACV,GAAG,EACH,UAAU,EACV,SAAS,EACT,IAAI,GAML;QAOD,+GAA+G;QACxG,oBAAe,GAAG,KAUtB,EAAE,0CAV2B,EAC9B,OAAO,EACP,UAAU,EACV,QAAQ,EACR,WAAW,GAMZ;YACC,MAAM,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAExD,MAAM,aAAa,GAAG,WAAW,KAAK,WAAW,CAAC;YAClD,IAAI,UAAqD,CAAC;YAC1D,IAAI,GAAsC,CAAC;YAC3C,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,CAAC;YAClE,MAAM,OAAO,GAAG;gBACd,eAAe,EAAE,IAAI;gBACrB,UAAU;aACuB,CAAC;YAEpC,IAAI,CAAC;gBACH,cAAc,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC;gBAClE,OAAO,CAAC,WAAW,GAAG,cAAc,IAAI,OAAO,CAAC;gBAEhD,MAAM,iBAAiB,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,EAAE;4BACT,QAAQ,EAAE,IAAI,CAAC,SAAS;4BACxB,OAAO;yBACR;qBACF,CAAC,CAAC;YACT,CAAC;YAAC,OAAO,GAAY,EAAE,CAAC;gBACtB,MAAM,iBAAiB,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;gBAE/C,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;oBACvB,KAAK,EAAE,iBAAiB;oBACxB,OAAO;iBACR,CAAC,CAAC;gBAEH,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC,CAAA,CAAC;QAlIA,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CA+HF"}
@@ -0,0 +1,38 @@
1
+ import IdentityFederation from '.';
2
+ export type IIdentityFederationController = Awaited<ReturnType<typeof IdentityFederation>>;
3
+ export type AttributeMapping = {
4
+ key: string;
5
+ value: string;
6
+ };
7
+ export type IdentityFederationApp = {
8
+ id: string;
9
+ type?: string;
10
+ clientID?: string;
11
+ clientSecret?: string;
12
+ redirectUrl?: string[] | string;
13
+ name: string;
14
+ tenant: string;
15
+ product: string;
16
+ acsUrl: string;
17
+ entityId: string;
18
+ logoUrl: string | null;
19
+ faviconUrl: string | null;
20
+ primaryColor: string | null;
21
+ tenants?: string[];
22
+ mappings?: AttributeMapping[] | null;
23
+ };
24
+ export type IdentityFederationAppWithMetadata = IdentityFederationApp & {
25
+ metadata: {
26
+ entityId: string;
27
+ ssoUrl: string;
28
+ x509cert: string;
29
+ xml: string;
30
+ };
31
+ };
32
+ export type AppRequestParams = {
33
+ id: string;
34
+ } | {
35
+ tenant: string;
36
+ product: string;
37
+ type?: string;
38
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/ee/identity-federation/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import { JacksonOption, OryConfig, OryRes } from '../../typings';
2
+ import { ProductController } from '../product';
3
+ export declare class OryController {
4
+ private opts;
5
+ private productController;
6
+ constructor({ opts, productController }: {
7
+ opts: JacksonOption;
8
+ productController: ProductController;
9
+ });
10
+ private getOrgName;
11
+ private getIssuerUrl;
12
+ private addOrUpdateConnection;
13
+ private createOrganization;
14
+ private sanitizeConfig;
15
+ createConnection(config: OryConfig, tenant: string, product: string): Promise<OryRes | null>;
16
+ updateConnection(config: OryConfig, tenant: string, product: string): Promise<OryRes | null>;
17
+ private isEnabled;
18
+ }
@@ -0,0 +1,195 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import axios from 'axios';
11
+ import { throwIfInvalidLicense } from '../common/checkLicense';
12
+ const basePath = 'https://api.console.ory.sh';
13
+ const providerId = 'sso_boxyhq';
14
+ const dataMapping = 'base64://bG9jYWwgY2xhaW1zID0gewogIGVtYWlsX3ZlcmlmaWVkOiB0cnVlLAp9ICsgc3RkLmV4dFZhcignY2xhaW1zJyk7Cgp7CiAgaWRlbnRpdHk6IHsKICAgIHRyYWl0czogewogICAgICBbaWYgJ2VtYWlsJyBpbiBjbGFpbXMgJiYgY2xhaW1zLmVtYWlsX3ZlcmlmaWVkIHRoZW4gJ2VtYWlsJyBlbHNlIG51bGxdOiBjbGFpbXMuZW1haWwsCiAgICB9LAogIH0sCn0=';
15
+ const issuerUrl = 'https://sso.eu.boxyhq.com';
16
+ export class OryController {
17
+ constructor({ opts, productController }) {
18
+ this.opts = opts;
19
+ this.productController = productController;
20
+ }
21
+ getOrgName(tenant, product) {
22
+ return this.opts.boxyhqHosted ? tenant : `${tenant}:${product}`;
23
+ }
24
+ getIssuerUrl() {
25
+ if (this.opts.boxyhqHosted) {
26
+ return issuerUrl;
27
+ }
28
+ else {
29
+ return this.opts.externalUrl;
30
+ }
31
+ }
32
+ addOrUpdateConnection(config, tenant, product) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const project = yield axios.get(`${basePath}/projects/${config.projectId}`, {
35
+ headers: {
36
+ Authorization: `Bearer ${config.sdkToken}`,
37
+ },
38
+ });
39
+ let index = '-';
40
+ try {
41
+ for (const idx in project.data.services.identity.config.selfservice.methods.oidc.config.providers) {
42
+ const provider = project.data.services.identity.config.selfservice.methods.oidc.config.providers[idx];
43
+ if (provider.id === providerId && provider.organization_id === config.organizationId) {
44
+ index = idx;
45
+ break;
46
+ }
47
+ }
48
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
49
+ }
50
+ catch (err) {
51
+ // empty
52
+ }
53
+ const op = index === '-' ? 'add' : 'replace';
54
+ yield axios.patch(`${basePath}/normalized/projects/${config.projectId}/revision/${project.data.revision_id}`, [
55
+ { op: 'replace', path: '/kratos_selfservice_methods_oidc_enabled', value: true },
56
+ {
57
+ op,
58
+ path: `/kratos_selfservice_methods_oidc_config_providers/${index}`,
59
+ value: {
60
+ provider_id: providerId,
61
+ provider: 'generic',
62
+ label: 'SSO',
63
+ client_id: `tenant=${tenant}&product=${product}`,
64
+ client_secret: this.opts.clientSecretVerifier,
65
+ organization_id: config.organizationId,
66
+ scope: [],
67
+ mapper_url: dataMapping,
68
+ additional_id_token_audiences: [],
69
+ issuer_url: this.getIssuerUrl(),
70
+ },
71
+ },
72
+ ], {
73
+ headers: {
74
+ Authorization: `Bearer ${config.sdkToken}`,
75
+ },
76
+ });
77
+ });
78
+ }
79
+ createOrganization(config, label) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ var _a;
82
+ if (!config.sdkToken || !config.projectId) {
83
+ throw new Error('Ory SDK Token or Project ID not set');
84
+ }
85
+ if (config && config.organizationId) {
86
+ try {
87
+ const res = yield axios.get(`${basePath}/projects/${config.projectId}/organizations/${config.organizationId}`, {
88
+ headers: {
89
+ Authorization: `Bearer ${config.sdkToken}`,
90
+ },
91
+ });
92
+ return res.data.organization.id;
93
+ }
94
+ catch (err) {
95
+ // if org doesn't exist fall through to section that creates it below
96
+ if (((_a = err.response) === null || _a === void 0 ? void 0 : _a.status) !== 404) {
97
+ throw err;
98
+ }
99
+ }
100
+ }
101
+ const res = yield axios.post(`${basePath}/projects/${config.projectId}/organizations`, {
102
+ label,
103
+ domains: config.domains,
104
+ }, {
105
+ headers: {
106
+ Authorization: `Bearer ${config.sdkToken}`,
107
+ },
108
+ });
109
+ return res.data.id;
110
+ });
111
+ }
112
+ sanitizeConfig(config, tenant) {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ var _a, _b;
115
+ if (!config.sdkToken) {
116
+ config.sdkToken = (_a = this.opts.ory) === null || _a === void 0 ? void 0 : _a.sdkToken;
117
+ }
118
+ if (!config.projectId) {
119
+ config.projectId = (_b = this.opts.ory) === null || _b === void 0 ? void 0 : _b.projectId;
120
+ }
121
+ config.domains = config.domains || [];
122
+ if (!config.domains.includes(tenant)) {
123
+ config.domains.push(tenant);
124
+ }
125
+ return config;
126
+ });
127
+ }
128
+ createConnection(config, tenant, product) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ if (!(yield this.isEnabled(config, tenant, product))) {
131
+ return null;
132
+ }
133
+ const organizationId = yield this.createOrganization(config, this.getOrgName(tenant, product));
134
+ config.organizationId = organizationId;
135
+ let error;
136
+ try {
137
+ yield this.addOrUpdateConnection(config, tenant, product);
138
+ }
139
+ catch (err) {
140
+ error = err;
141
+ }
142
+ return { projectId: config.projectId, domains: config.domains, organizationId, error };
143
+ });
144
+ }
145
+ updateConnection(config, tenant, product) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ if (!(yield this.isEnabled(config, tenant, product))) {
148
+ return null;
149
+ }
150
+ const organizationId = yield this.createOrganization(config, this.getOrgName(tenant, product));
151
+ let error;
152
+ try {
153
+ yield this.addOrUpdateConnection(config, tenant, product);
154
+ }
155
+ catch (err) {
156
+ error = err;
157
+ }
158
+ return { projectId: config.projectId, domains: config.domains, organizationId, error };
159
+ });
160
+ }
161
+ isEnabled(config, tenant, product) {
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ var _a, _b;
164
+ if (this.opts.boxyhqHosted) {
165
+ const productConfig = yield this.productController.get(product);
166
+ if (!productConfig ||
167
+ !productConfig.ory ||
168
+ !productConfig.ory.sdkToken ||
169
+ !productConfig.ory.projectId) {
170
+ return false;
171
+ }
172
+ config.sdkToken = productConfig.ory.sdkToken;
173
+ config.projectId = productConfig.ory.projectId;
174
+ this.sanitizeConfig(config, tenant);
175
+ return true;
176
+ }
177
+ else {
178
+ if (!((_a = this.opts.ory) === null || _a === void 0 ? void 0 : _a.sdkToken) || !((_b = this.opts.ory) === null || _b === void 0 ? void 0 : _b.projectId)) {
179
+ return false;
180
+ }
181
+ try {
182
+ yield throwIfInvalidLicense(this.opts.boxyhqLicenseKey);
183
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
184
+ }
185
+ catch (err) {
186
+ console.error('Ory is not enabled because of invalid license');
187
+ return false;
188
+ }
189
+ this.sanitizeConfig(config, tenant);
190
+ return true;
191
+ }
192
+ });
193
+ }
194
+ }
195
+ //# sourceMappingURL=ory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ory.js","sourceRoot":"","sources":["../../../../src/ee/ory/ory.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;A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AAC,GAAG,0CAAE,QAAQ,CAAA,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,GAAG,0CAAE,SAAS,CAAA,EAAE,CAAC;oBAC1D,OAAO,KAAK,CAAC;gBACf,CAAC;gBACD,IAAI,CAAC;oBACH,MAAM,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;oBACxD,6DAA6D;gBAC/D,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;oBAC/D,OAAO,KAAK,CAAC;gBACf,CAAC;gBACD,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBACpC,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;KAAA;CACF"}
@@ -0,0 +1,14 @@
1
+ import type { Storable, JacksonOption, ProductConfig } from '../../typings';
2
+ export declare class ProductController {
3
+ private productStore;
4
+ private opts;
5
+ constructor({ productStore, opts }: {
6
+ productStore: Storable;
7
+ opts: JacksonOption;
8
+ });
9
+ get(productId: string): Promise<ProductConfig>;
10
+ upsert(params: Partial<ProductConfig> & {
11
+ id: string;
12
+ }): Promise<void>;
13
+ delete(productId: string): Promise<void>;
14
+ }
@@ -0,0 +1,45 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { JacksonError } from '../../controller/error';
11
+ import { throwIfInvalidLicense } from '../common/checkLicense';
12
+ export class ProductController {
13
+ constructor({ productStore, opts }) {
14
+ this.productStore = productStore;
15
+ this.opts = opts;
16
+ }
17
+ get(productId) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ yield throwIfInvalidLicense(this.opts.boxyhqLicenseKey);
20
+ const productConfig = (yield this.productStore.get(productId));
21
+ // if (!productConfig) {
22
+ // console.error(`Product config not found for ${productId}`);
23
+ // }
24
+ return Object.assign(Object.assign({}, productConfig), { id: productId, name: (productConfig === null || productConfig === void 0 ? void 0 : productConfig.name) || null, teamId: (productConfig === null || productConfig === void 0 ? void 0 : productConfig.teamId) || null, teamName: (productConfig === null || productConfig === void 0 ? void 0 : productConfig.teamName) || null, logoUrl: (productConfig === null || productConfig === void 0 ? void 0 : productConfig.logoUrl) || null, faviconUrl: (productConfig === null || productConfig === void 0 ? void 0 : productConfig.faviconUrl) || null, companyName: (productConfig === null || productConfig === void 0 ? void 0 : productConfig.companyName) || null, primaryColor: (productConfig === null || productConfig === void 0 ? void 0 : productConfig.primaryColor) || '#25c2a0' });
25
+ });
26
+ }
27
+ upsert(params) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ yield throwIfInvalidLicense(this.opts.boxyhqLicenseKey);
30
+ if (!('id' in params)) {
31
+ throw new JacksonError('Provide a product id', 400);
32
+ }
33
+ const productConfig = (yield this.productStore.get(params.id));
34
+ const toUpdate = productConfig ? Object.assign(Object.assign({}, productConfig), params) : params;
35
+ yield this.productStore.put(params.id, toUpdate);
36
+ });
37
+ }
38
+ delete(productId) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ yield throwIfInvalidLicense(this.opts.boxyhqLicenseKey);
41
+ yield this.productStore.delete(productId);
42
+ });
43
+ }
44
+ }
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ee/product/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OA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C;gBACtB,MAAM,IAAI,YAAY,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;YACtD,CAAC;YAED,MAAM,aAAa,GAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAkB,CAAC;YAEhF,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC,iCAAM,aAAa,GAAK,MAAM,EAAG,CAAC,CAAC,MAAM,CAAC;YAE1E,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QACnD,CAAC;KAAA;IAEY,MAAM,CAAC,SAAiB;;YACnC,MAAM,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAExD,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;KAAA;CACF"}
@@ -0,0 +1,2 @@
1
+ declare const axiosInstance: any;
2
+ export default axiosInstance;
@@ -0,0 +1,27 @@
1
+ import axios from 'axios';
2
+ const retry = 3;
3
+ const retryDelay = 3000;
4
+ const axiosInstance = axios.create();
5
+ // Axios interceptors to handle the Webhook retries
6
+ axiosInstance.interceptors.response.use(undefined, (err) => {
7
+ const config = err.config;
8
+ if (!config) {
9
+ return Promise.reject(err);
10
+ }
11
+ config.__retryCount = config.__retryCount || 0;
12
+ if (config.__retryCount >= retry) {
13
+ return Promise.reject(err);
14
+ }
15
+ config.__retryCount += 1;
16
+ const backoff = new Promise(function (resolve) {
17
+ setTimeout(function () {
18
+ resolve(1);
19
+ }, retryDelay);
20
+ });
21
+ return backoff.then(function () {
22
+ console.info(`Retrying sending webhook event to ${config.url}... Attempt ${config.__retryCount}`);
23
+ return axiosInstance(config);
24
+ });
25
+ });
26
+ export default axiosInstance;
27
+ //# sourceMappingURL=axios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios.js","sourceRoot":"","sources":["../../../src/event/axios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,KAAK,GAAG,CAAC,CAAC;AAChB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;AAErC,mDAAmD;AACnD,aAAa,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,GAAQ,EAAE,EAAE;IAC9D,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAE1B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,CAAC,CAAC;IAE/C,IAAI,MAAM,CAAC,YAAY,IAAI,KAAK,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,YAAY,IAAI,CAAC,CAAC;IAEzB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,UAAU,OAAO;QAC3C,UAAU,CAAC;YACT,OAAO,CAAC,CAAC,CAAC,CAAC;QACb,CAAC,EAAE,UAAU,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,IAAI,CAAC;QAClB,OAAO,CAAC,IAAI,CAAC,qCAAqC,MAAM,CAAC,GAAG,eAAe,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;QAClG,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Directory, JacksonOption, SAMLSSORecord, EventType, SSOConnectionEventType, Webhook, EventPayloadSchema, OIDCSSORecord } from '../typings';
2
+ export default class Event {
3
+ private webhook;
4
+ private dsync;
5
+ constructor({ opts }: {
6
+ opts: JacksonOption;
7
+ });
8
+ notify<T extends EventType>(event: T, data: T extends SSOConnectionEventType ? SAMLSSORecord | OIDCSSORecord : Directory): Promise<any>;
9
+ private constructPayload;
10
+ sendWebhookEvent(webhook: Webhook | undefined, payload: EventPayloadSchema): Promise<any>;
11
+ }
@@ -0,0 +1,53 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { sendPayloadToWebhook } from './webhook';
11
+ import { transformSAMLSSOConnection, transformDirectoryConnection, transformOIDCSSOConnection, } from './utils';
12
+ export default class Event {
13
+ constructor({ opts }) {
14
+ this.webhook = opts.webhook;
15
+ this.dsync = opts.dsync;
16
+ }
17
+ notify(event, data) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const payload = this.constructPayload(event, data);
20
+ return this.sendWebhookEvent(this.webhook, payload);
21
+ });
22
+ }
23
+ constructPayload(event, data) {
24
+ let transformedData;
25
+ if ('idpMetadata' in data) {
26
+ transformedData = transformSAMLSSOConnection(data);
27
+ }
28
+ else if ('oidcProvider' in data) {
29
+ transformedData = transformOIDCSSOConnection(data);
30
+ }
31
+ else {
32
+ transformedData = transformDirectoryConnection(data);
33
+ }
34
+ const { tenant, product } = data;
35
+ const payload = {
36
+ event,
37
+ tenant,
38
+ product,
39
+ data: transformedData,
40
+ };
41
+ return payload;
42
+ }
43
+ sendWebhookEvent(webhook, payload) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ var _a;
46
+ if (!(webhook === null || webhook === void 0 ? void 0 : webhook.endpoint) || !webhook.secret) {
47
+ return;
48
+ }
49
+ return yield sendPayloadToWebhook(webhook, payload, (_a = this.dsync) === null || _a === void 0 ? void 0 : _a.debugWebhooks);
50
+ });
51
+ }
52
+ }
53
+ //# sourceMappingURL=index.js.map