@logto/schemas 1.17.0 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/alterations/1.18.0-1717567857-social-sign-in-linking.ts +18 -0
  2. package/alterations/1.18.0-1717597875-add-organization-email-domains-table.ts +31 -0
  3. package/alterations/1.18.0-1717818597-organization-mfa-requirement.ts +18 -0
  4. package/alterations/1.18.0-1718340884-rename-org-email-domains-and-add-jit-roles-table.ts +56 -0
  5. package/alterations/1.18.0-1718594164-add-agree-to-terms-policy.ts +40 -0
  6. package/alterations/1.18.0-1718785576-organization-application-relations.ts +37 -0
  7. package/alterations/1.18.0-1718786576-organization-jit-sso-connectors.ts +31 -0
  8. package/alterations/1.18.0-1718807616-organization-role-application-relations.ts +34 -0
  9. package/alterations/1.18.0-1718865814-add-subject-tokens.ts +36 -0
  10. package/alterations/1.18.0-1719014832-organization-role-types.ts +35 -0
  11. package/alterations/1.18.0-1719221205-fix-functions.ts +25 -0
  12. package/alterations/1.18.0-1719312694-custom-ui-assets.ts +18 -0
  13. package/alterations/1.19.0-1720253939-add-organization-branding.ts +18 -0
  14. package/alterations/1.19.0-1720345784-add-color-to-app-sie.ts +18 -0
  15. package/alterations/1.19.0-1720505152-update-custom-ui-assets.ts +20 -0
  16. package/alterations/1.19.0-1721483240-multiple-app-secrets.ts +77 -0
  17. package/alterations/1.19.0-1721645392-add-application-custom-data-column.ts +18 -0
  18. package/alterations/1.19.0-1722926389-argon2d-argon2id.ts +35 -0
  19. package/alterations-js/1.18.0-1717567857-social-sign-in-linking.js +14 -0
  20. package/alterations-js/1.18.0-1717597875-add-organization-email-domains-table.js +26 -0
  21. package/alterations-js/1.18.0-1717818597-organization-mfa-requirement.js +14 -0
  22. package/alterations-js/1.18.0-1718340884-rename-org-email-domains-and-add-jit-roles-table.js +51 -0
  23. package/alterations-js/1.18.0-1718594164-add-agree-to-terms-policy.js +34 -0
  24. package/alterations-js/1.18.0-1718785576-organization-application-relations.js +32 -0
  25. package/alterations-js/1.18.0-1718786576-organization-jit-sso-connectors.js +26 -0
  26. package/alterations-js/1.18.0-1718807616-organization-role-application-relations.js +29 -0
  27. package/alterations-js/1.18.0-1718865814-add-subject-tokens.js +31 -0
  28. package/alterations-js/1.18.0-1719014832-organization-role-types.js +31 -0
  29. package/alterations-js/1.18.0-1719221205-fix-functions.js +20 -0
  30. package/alterations-js/1.18.0-1719312694-custom-ui-assets.js +14 -0
  31. package/alterations-js/1.19.0-1720253939-add-organization-branding.js +14 -0
  32. package/alterations-js/1.19.0-1720345784-add-color-to-app-sie.js +14 -0
  33. package/alterations-js/1.19.0-1720505152-update-custom-ui-assets.js +16 -0
  34. package/alterations-js/1.19.0-1721483240-multiple-app-secrets.js +72 -0
  35. package/alterations-js/1.19.0-1721645392-add-application-custom-data-column.js +14 -0
  36. package/alterations-js/1.19.0-1722926389-argon2d-argon2id.js +30 -0
  37. package/lib/consts/oidc.d.ts +15 -2
  38. package/lib/consts/oidc.js +6 -0
  39. package/lib/consts/subscriptions.d.ts +9 -6
  40. package/lib/consts/subscriptions.js +8 -5
  41. package/lib/consts/system.d.ts +2 -0
  42. package/lib/consts/system.js +2 -0
  43. package/lib/db-entries/application-secret.d.ts +28 -0
  44. package/lib/db-entries/application-secret.js +41 -0
  45. package/lib/db-entries/application-sign-in-experience.d.ts +4 -2
  46. package/lib/db-entries/application-sign-in-experience.js +5 -1
  47. package/lib/db-entries/application.d.ts +6 -2
  48. package/lib/db-entries/application.js +5 -1
  49. package/lib/db-entries/custom-types.d.ts +7 -0
  50. package/lib/db-entries/custom-types.js +8 -0
  51. package/lib/db-entries/index.d.ts +7 -0
  52. package/lib/db-entries/index.js +7 -0
  53. package/lib/db-entries/organization-application-relation.d.ts +20 -0
  54. package/lib/db-entries/organization-application-relation.js +29 -0
  55. package/lib/db-entries/organization-jit-email-domain.d.ts +24 -0
  56. package/lib/db-entries/organization-jit-email-domain.js +29 -0
  57. package/lib/db-entries/organization-jit-role.d.ts +24 -0
  58. package/lib/db-entries/organization-jit-role.js +29 -0
  59. package/lib/db-entries/organization-jit-sso-connector.d.ts +22 -0
  60. package/lib/db-entries/organization-jit-sso-connector.js +29 -0
  61. package/lib/db-entries/organization-role-application-relation.d.ts +22 -0
  62. package/lib/db-entries/organization-role-application-relation.js +33 -0
  63. package/lib/db-entries/organization-role.d.ts +6 -1
  64. package/lib/db-entries/organization-role.js +5 -0
  65. package/lib/db-entries/organization.d.ts +10 -2
  66. package/lib/db-entries/organization.js +9 -1
  67. package/lib/db-entries/sign-in-experience.d.ts +11 -3
  68. package/lib/db-entries/sign-in-experience.js +14 -2
  69. package/lib/db-entries/subject-token.d.ts +28 -0
  70. package/lib/db-entries/subject-token.js +50 -0
  71. package/lib/foundations/jsonb-types/hooks.d.ts +0 -4
  72. package/lib/foundations/jsonb-types/hooks.js +1 -4
  73. package/lib/foundations/jsonb-types/oidc-module.d.ts +33 -1
  74. package/lib/foundations/jsonb-types/oidc-module.js +2 -0
  75. package/lib/foundations/jsonb-types/sign-in-experience.d.ts +47 -0
  76. package/lib/foundations/jsonb-types/sign-in-experience.js +21 -4
  77. package/lib/foundations/jsonb-types/users.d.ts +6 -6
  78. package/lib/foundations/jsonb-types/users.js +2 -2
  79. package/lib/seeds/application.js +1 -0
  80. package/lib/seeds/cloud-api.d.ts +1 -1
  81. package/lib/seeds/sign-in-experience.d.ts +1 -0
  82. package/lib/seeds/sign-in-experience.js +2 -1
  83. package/lib/types/application.d.ts +85 -167
  84. package/lib/types/connector.d.ts +723 -191
  85. package/lib/types/consent.d.ts +181 -42
  86. package/lib/types/cookie.d.ts +7 -1
  87. package/lib/types/cookie.js +3 -1
  88. package/lib/types/domain.d.ts +2 -10
  89. package/lib/types/hook.d.ts +14 -21
  90. package/lib/types/index.d.ts +3 -0
  91. package/lib/types/index.js +3 -0
  92. package/lib/types/interactions.d.ts +313 -29
  93. package/lib/types/interactions.js +92 -9
  94. package/lib/types/log/interaction.d.ts +4 -3
  95. package/lib/types/log/interaction.js +1 -0
  96. package/lib/types/log/token.d.ts +2 -1
  97. package/lib/types/log/token.js +1 -0
  98. package/lib/types/logto-config/index.d.ts +277 -242
  99. package/lib/types/logto-config/jwt-customizer.d.ts +642 -476
  100. package/lib/types/logto-config/jwt-customizer.js +13 -2
  101. package/lib/types/logto-config/oidc-provider.d.ts +6 -6
  102. package/lib/types/mfa.d.ts +16 -16
  103. package/lib/types/oidc-config.d.ts +2 -1
  104. package/lib/types/oidc-config.js +1 -0
  105. package/lib/types/organization.d.ts +12 -3
  106. package/lib/types/organization.js +4 -1
  107. package/lib/types/role.d.ts +6 -1
  108. package/lib/types/role.js +6 -1
  109. package/lib/types/scope.d.ts +7 -6
  110. package/lib/types/sign-in-experience.d.ts +997 -0
  111. package/lib/types/sign-in-experience.js +21 -0
  112. package/lib/types/sso-connector.d.ts +14 -19
  113. package/lib/types/ssr.d.ts +25 -0
  114. package/lib/types/ssr.js +9 -0
  115. package/lib/types/subject-token.d.ts +12 -0
  116. package/lib/types/subject-token.js +5 -0
  117. package/lib/types/system.d.ts +11 -7
  118. package/lib/types/system.js +4 -0
  119. package/lib/types/tenant-organization.d.ts +1 -0
  120. package/lib/types/tenant-organization.js +3 -0
  121. package/lib/types/user-assets.d.ts +25 -5
  122. package/lib/types/user-assets.js +20 -1
  123. package/lib/types/user.d.ts +84 -120
  124. package/lib/utils/application.d.ts +3 -0
  125. package/lib/utils/application.js +7 -0
  126. package/lib/utils/index.d.ts +1 -0
  127. package/lib/utils/index.js +1 -0
  128. package/lib/utils/zod.d.ts +1 -1
  129. package/package.json +9 -9
  130. package/tables/application_secrets.sql +17 -0
  131. package/tables/application_sign_in_experiences.sql +1 -1
  132. package/tables/applications.sql +10 -0
  133. package/tables/organization_application_relations.sql +14 -0
  134. package/tables/organization_jit_email_domains.sql +13 -0
  135. package/tables/organization_jit_roles.sql +14 -0
  136. package/tables/organization_jit_sso_connectors.sql +13 -0
  137. package/tables/organization_role_application_relations.sql +18 -0
  138. package/tables/organization_role_user_relations.sql +3 -1
  139. package/tables/organization_roles.sql +8 -1
  140. package/tables/organizations.sql +4 -0
  141. package/tables/sign_in_experiences.sql +5 -0
  142. package/tables/subject_tokens.sql +16 -0
  143. package/tables/users.sql +1 -1
  144. package/alterations-js/1.0.0-1677208902-update-admin-console-config.d.ts +0 -3
  145. package/alterations-js/1.0.0-1677765137-seed-for-admin-tenant.d.ts +0 -3
  146. package/alterations-js/1.0.0-1677907982-allow-admin-create-multiple-tenants.d.ts +0 -3
  147. package/alterations-js/1.0.0-1678157950-privacy-policy-url.d.ts +0 -3
  148. package/alterations-js/1.0.0-1678199795-add-verification-status-table.d.ts +0 -3
  149. package/alterations-js/1.0.0-1678259693-remove-branding-style-config.d.ts +0 -3
  150. package/alterations-js/1.0.0-1678269972-use-restrictive-policies.d.ts +0 -3
  151. package/alterations-js/1.0.0-1678284778-restrict-internal-roles.d.ts +0 -3
  152. package/alterations-js/1.0.0-1678425761-m2m-app-for-tenants.d.ts +0 -3
  153. package/alterations-js/1.0.0-1678450233-support-custom-content.d.ts +0 -3
  154. package/alterations-js/1.0.0-1678716747-service-logs.d.ts +0 -3
  155. package/alterations-js/1.0.0-1678928481-remove-deprecated-logto-config-item.d.ts +0 -3
  156. package/alterations-js/1.0.0-1678953179-update-get-started-task-config.d.ts +0 -3
  157. package/alterations-js/1.0.0-1679209413-drop-connector-database-storage.d.ts +0 -3
  158. package/alterations-js/1.0.0_beta.10-1-logto-config.d.ts +0 -3
  159. package/alterations-js/1.0.0_beta.10-1663923211-machine-to-machine-app.d.ts +0 -3
  160. package/alterations-js/1.0.0_beta.10-1664265197-custom-phrases.d.ts +0 -3
  161. package/alterations-js/1.0.0_beta.11-1664347703-rename-language-key-to-tag.d.ts +0 -3
  162. package/alterations-js/1.0.0_beta.11-1664356000-add-created-at-column-to-users.d.ts +0 -3
  163. package/alterations-js/1.0.0_beta.11-1664462389-correct-user-created-at-column-by-user-logs.d.ts +0 -3
  164. package/alterations-js/1.0.0_beta.14-1665300135-sign-in-sign-up.d.ts +0 -3
  165. package/alterations-js/1.0.0_beta.14-1667283640-remove-forgot-password.d.ts +0 -3
  166. package/alterations-js/1.0.0_beta.14-1667292082-remove-sign-in-method.d.ts +0 -3
  167. package/alterations-js/1.0.0_beta.14-1667374974-user-suspend.d.ts +0 -3
  168. package/alterations-js/1.0.0_beta.14-1667900481-add-passcode-type-continue.d.ts +0 -3
  169. package/alterations-js/1.0.0_beta.18-1668666590-support-multiple-connector-instances.d.ts +0 -3
  170. package/alterations-js/1.0.0_beta.18-1668666600-remove-connector-enabled.d.ts +0 -3
  171. package/alterations-js/1.0.0_beta.18-1669091623-roles-and-scopes.d.ts +0 -3
  172. package/alterations-js/1.0.0_beta.18-1669702299-sign-up.d.ts +0 -3
  173. package/alterations-js/1.0.0_beta.18-1671039448-add-user-name-index.d.ts +0 -3
  174. package/alterations-js/1.0.0_beta.18-1671080370-terms-of-use.d.ts +0 -3
  175. package/alterations-js/1.0.0_beta.18-1671336831-refactor-log-types.d.ts +0 -3
  176. package/alterations-js/1.0.0_beta.18-1671509870-hooks.d.ts +0 -3
  177. package/alterations-js/1.0.0_beta.18-1672119200-align-passcode-type-with-message-type.d.ts +0 -3
  178. package/alterations-js/1.0.0_rc.0-1672815959-user-roles.d.ts +0 -3
  179. package/alterations-js/1.0.0_rc.0-1672820345-scope-resource-id.d.ts +0 -3
  180. package/alterations-js/1.0.0_rc.0-1672901841-roles-and-scopes-not-null.d.ts +0 -3
  181. package/alterations-js/1.0.0_rc.0-1673001922-support-generic-passcode.d.ts +0 -3
  182. package/alterations-js/1.0.0_rc.0-1673165463-scope-name-index.d.ts +0 -3
  183. package/alterations-js/1.0.0_rc.0-1673349501-sms-sign-in-identifier-to-phone.d.ts +0 -3
  184. package/alterations-js/1.0.0_rc.0-1673465463-ac-scope-name.d.ts +0 -3
  185. package/alterations-js/1.0.0_rc.0-1673853579-ac-default-scope.d.ts +0 -3
  186. package/alterations-js/1.0.0_rc.0-1673863835-ac-scope-role.d.ts +0 -3
  187. package/alterations-js/1.0.0_rc.0-1673882867-fix-alteration-issues.d.ts +0 -3
  188. package/alterations-js/1.0.0_rc.0-1673940577-scope-description-not-null.d.ts +0 -3
  189. package/alterations-js/1.0.0_rc.0-1673941897-application-roles.d.ts +0 -3
  190. package/alterations-js/1.0.0_rc.0-1674032095.1-dedup-resources-constraint.d.ts +0 -4
  191. package/alterations-js/1.0.0_rc.0-1674032095.2-oidc-model-pkey.d.ts +0 -3
  192. package/alterations-js/1.0.0_rc.0-1674032095.3-tenant-table.d.ts +0 -3
  193. package/alterations-js/1.0.0_rc.0-1674032095.4-add-id-column.d.ts +0 -3
  194. package/alterations-js/1.0.0_rc.0-1674032095.5-multi-tenancy.d.ts +0 -3
  195. package/alterations-js/1.0.0_rc.0-1674032095.6-add-tenant-id-trigger.d.ts +0 -3
  196. package/alterations-js/1.0.0_rc.0-1674987042-drop-settings-and-create-systems.d.ts +0 -3
  197. package/alterations-js/1.0.0_rc.0-1675316731-update-seed-data.d.ts +0 -3
  198. package/alterations-js/1.0.0_rc.1-1675788753-multi-tenancy-rls.d.ts +0 -3
  199. package/alterations-js/1.0.0_rc.1-1676115897-add-admin-tenant.d.ts +0 -3
  200. package/alterations-js/1.0.0_rc.1-1676185899-fix-logs-index.d.ts +0 -3
  201. package/alterations-js/1.0.0_rc.1-1676190092-migrate-admin-data.d.ts +0 -3
  202. package/alterations-js/1.0.0_rc.1-1676823841-update-sie-primary-key.d.ts +0 -3
  203. package/alterations-js/1.0.0_rc.1-1676874936-support-custom-css.d.ts +0 -3
  204. package/alterations-js/1.0.0_rc.1-1676886855-connector-database-read-write.d.ts +0 -3
  205. package/alterations-js/1.0.0_rc.1-1676906977-remove-demo-app.d.ts +0 -3
  206. package/alterations-js/1.0.0_rc.1-1676956206-move-console-sie-to-database.d.ts +0 -3
  207. package/alterations-js/1.0.0_rc.1-1677059985-move-console-application-to-database.d.ts +0 -3
  208. package/alterations-js/1.10.1-1695647183-update-private-key-type.d.ts +0 -3
  209. package/alterations-js/1.10.1-1696657546-organization-tables.d.ts +0 -3
  210. package/alterations-js/1.10.1-1697683802-add-sso-connectors-table.d.ts +0 -3
  211. package/alterations-js/1.10.1-1698646271-add-organization-created-flag.d.ts +0 -3
  212. package/alterations-js/1.10.1-1698820410-add-user-sso-identities-table.d.ts +0 -4
  213. package/alterations-js/1.10.1-1698910485-user-logto-data.d.ts +0 -3
  214. package/alterations-js/1.11.0-1699422979-add-sso-connector-id-col-to-user-sso-identities-table.d.ts +0 -3
  215. package/alterations-js/1.11.0-1699598903-remove-sso-only-column-in-sso-connectors-table.d.ts +0 -3
  216. package/alterations-js/1.12.0-1700031616-update-org-role-foreign-keys.d.ts +0 -3
  217. package/alterations-js/1.12.0-1701054133-add-unique-constraint-to-the-sso-connector-name.d.ts +0 -3
  218. package/alterations-js/1.12.0-1701245520-add-single-sign-on-enabled-flag-to-sie.d.ts +0 -3
  219. package/alterations-js/1.13.0-1702274830-add-new-third-party-column-to-applications-table.d.ts +0 -3
  220. package/alterations-js/1.13.0-1702372401-add-application-permissions-tables.d.ts +0 -3
  221. package/alterations-js/1.13.0-1702544178-sync-tenant-orgs.d.ts +0 -18
  222. package/alterations-js/1.13.0-1702871078-protected-application-type.d.ts +0 -3
  223. package/alterations-js/1.13.0-1702877515-protected-app-configs.d.ts +0 -3
  224. package/alterations-js/1.13.0-1702978120-application-sign-in-experience-table.d.ts +0 -3
  225. package/alterations-js/1.13.0-1703229996-daily-token-usage.d.ts +0 -3
  226. package/alterations-js/1.13.0-1703230000-update-tenant-roles.d.ts +0 -11
  227. package/alterations-js/1.13.0-1704692973-remove-legacy-resources.d.ts +0 -3
  228. package/alterations-js/1.13.0-1704934999-add-magic-links-table.d.ts +0 -3
  229. package/alterations-js/1.13.0-1704935001-add-organization-invitation-tables.d.ts +0 -3
  230. package/alterations-js/1.13.0-1705288654-add-application-user-consent-organizations-table.d.ts +0 -3
  231. package/alterations-js/1.13.0-1705991158-update-invitation-indices.d.ts +0 -7
  232. package/alterations-js/1.13.0-1706449174-update-organization-invitation-column.d.ts +0 -3
  233. package/alterations-js/1.13.0-1706510290-protected-app-host-index.d.ts +0 -3
  234. package/alterations-js/1.13.0-1706512952-restore-get-started-page.d.ts +0 -3
  235. package/alterations-js/1.13.0-1706528755-remove-magic-links.d.ts +0 -3
  236. package/alterations-js/1.13.0-1706585206-protected-app-custom-domain-unique.d.ts +0 -3
  237. package/alterations-js/1.13.1-1707360939-grant-is-suspended-read-permission.d.ts +0 -6
  238. package/alterations-js/1.14.0-1708916601-remove-management-api-scopes-assigned-to-user-role.d.ts +0 -3
  239. package/alterations-js/1.14.0-1709190131-enhance-dau-data-accuracy.d.ts +0 -3
  240. package/alterations-js/1.15.0-1709521416-user-password-encrypt-method.d.ts +0 -3
  241. package/alterations-js/1.15.0-1709528944-regenerate-dau-data.d.ts +0 -3
  242. package/alterations-js/1.15.0-1710223946-add-fetch-custom-jwt-cloud-scope.d.ts +0 -3
  243. package/alterations-js/1.15.0-1710408335-make-resource-scopes-description-nullable.d.ts +0 -3
  244. package/alterations-js/1.15.0-1710859622-add-oidc-standard-claim-properties.d.ts +0 -3
  245. package/alterations-js/1.15.0-1711607772-remove-invite-member-scope-from-tenant-member-role.d.ts +0 -3
  246. package/alterations-js/1.15.0-1711624564-add-read-member-scope-to-tenant-roles.d.ts +0 -3
  247. package/alterations-js/1.15.0-1711955211-organization-resource-scope.d.ts +0 -3
  248. package/alterations-js/1.15.0-1712041436-rename-organization-member-role-to-collaborator.d.ts +0 -3
  249. package/alterations-js/1.15.0-1712545011-fix-organization-resource-scope.d.ts +0 -8
  250. package/alterations-js/1.15.0-1712559358-fix-down-organization-resource-scope.d.ts +0 -8
  251. package/alterations-js/1.16.0-1712912361-delete-jwt-customier-with-empty-script.d.ts +0 -3
  252. package/alterations-js/1.16.0-1713942039-add-organization-custom-data.d.ts +0 -4
  253. package/alterations-js/1.16.0-1714270244-application-org-resource-scope.d.ts +0 -3
  254. package/alterations-js/1.17.0-1715826336-add-default-user-role-config.d.ts +0 -3
  255. package/alterations-js/1.17.0-1715829731-rename-data-hook-schema-update-event.d.ts +0 -3
  256. package/alterations-js/1.17.0-1716278409-remove-internal-role-database-policies.d.ts +0 -3
  257. package/alterations-js/1.17.0-1716291265-create-pre-configured-m-api-role.d.ts +0 -7
  258. package/alterations-js/1.17.0-1717148078-remove-service-log-reference.d.ts +0 -3
  259. package/alterations-js/1.2.0-1681267285-fix-get-started-passwordless-status.d.ts +0 -3
  260. package/alterations-js/1.3.0-1683292832-update-hooks.d.ts +0 -3
  261. package/alterations-js/1.5.0-1684382842-add-name-tag-created-at-for-tenants-table.d.ts +0 -3
  262. package/alterations-js/1.5.0-1684739802-create-hook-id-index-for-logs.d.ts +0 -3
  263. package/alterations-js/1.5.0-1684822341-init-domains.d.ts +0 -3
  264. package/alterations-js/1.5.0-1684837981-add-manage-tenant-self-scope-to-user-role.d.ts +0 -3
  265. package/alterations-js/1.5.0-1685285719-support-default-resource.d.ts +0 -3
  266. package/alterations-js/1.6.0-1685691718-domain-unique.d.ts +0 -3
  267. package/alterations-js/1.7.0-1688375200-sync-cloud-m2m-to-logto-config.d.ts +0 -3
  268. package/alterations-js/1.7.0-1688613459-remove-m2m-credentials-from-existing-logto-email-connector-config.d.ts +0 -3
  269. package/alterations-js/1.7.0-1688627407-daily-active-users.d.ts +0 -3
  270. package/alterations-js/1.8.0-1692088012-add-is-suspend-column-to-tenants-table.d.ts +0 -3
  271. package/alterations-js/1.8.0-1692194751-add-affiliate-scopes.d.ts +0 -3
  272. package/alterations-js/1.9.0-1693554904-add-possword-policy.d.ts +0 -4
  273. package/alterations-js/1.9.0-1694399696-add-type-col-to-roles-table.d.ts +0 -3
  274. package/alterations-js/1.9.0-1694418765-specify-check-role-type-function-to-be-public-schema.d.ts +0 -9
  275. package/alterations-js/1.9.0-1694484927-remove-deprecated-challenge-flag.d.ts +0 -3
  276. package/alterations-js/1.9.0-1694487524-sie-mfa.d.ts +0 -3
  277. package/alterations-js/1.9.0-1694509714-keep-existing-password-policy.d.ts +0 -3
  278. package/alterations-js/1.9.0-1694746763-user-verifications.d.ts +0 -3
  279. package/alterations-js/1.9.2-1694854226-init-sentinel.d.ts +0 -3
  280. package/alterations-js/1.9.2-1695198741-remove-m2m-app-admin-access-switch.d.ts +0 -3
  281. package/alterations-js/utils/1704934999-tables.d.ts +0 -11
  282. package/alterations-js/utils/1716643968-id-generation.d.ts +0 -19
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { type User } from '../db-entries/index.js';
3
3
  import { MfaFactor } from '../foundations/index.js';
4
- export declare const userInfoSelectFields: readonly ("name" | "id" | "applicationId" | "username" | "profile" | "createdAt" | "updatedAt" | "customData" | "primaryEmail" | "primaryPhone" | "avatar" | "identities" | "isSuspended" | "lastSignInAt")[];
4
+ export declare const userInfoSelectFields: readonly ("name" | "id" | "applicationId" | "username" | "createdAt" | "profile" | "customData" | "updatedAt" | "primaryEmail" | "primaryPhone" | "avatar" | "identities" | "isSuspended" | "lastSignInAt")[];
5
5
  export declare const userInfoGuard: z.ZodObject<Pick<{
6
6
  tenantId: z.ZodType<string, z.ZodTypeDef, string>;
7
7
  id: z.ZodType<string, z.ZodTypeDef, string>;
@@ -77,8 +77,8 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
77
77
  publicKey: string;
78
78
  counter: number;
79
79
  agent: string;
80
- transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
81
80
  lastUsedAt?: string | undefined;
81
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
82
82
  } | {
83
83
  type: MfaFactor.BackupCode;
84
84
  id: string;
@@ -102,8 +102,8 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
102
102
  publicKey: string;
103
103
  counter: number;
104
104
  agent: string;
105
- transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
106
105
  lastUsedAt?: string | undefined;
106
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
107
107
  } | {
108
108
  type: MfaFactor.BackupCode;
109
109
  id: string;
@@ -118,42 +118,19 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
118
118
  lastSignInAt: z.ZodType<number | null, z.ZodTypeDef, number | null>;
119
119
  createdAt: z.ZodType<number, z.ZodTypeDef, number>;
120
120
  updatedAt: z.ZodType<number, z.ZodTypeDef, number>;
121
- }, "name" | "id" | "applicationId" | "username" | "profile" | "createdAt" | "updatedAt" | "customData" | "primaryEmail" | "primaryPhone" | "avatar" | "identities" | "isSuspended" | "lastSignInAt">, "strip", z.ZodTypeAny, {
121
+ }, "name" | "id" | "applicationId" | "username" | "createdAt" | "profile" | "customData" | "updatedAt" | "primaryEmail" | "primaryPhone" | "avatar" | "identities" | "isSuspended" | "lastSignInAt">, "strip", z.ZodTypeAny, {
122
122
  name: string | null;
123
123
  id: string;
124
124
  applicationId: string | null;
125
125
  username: string | null;
126
- profile: Partial<{
127
- familyName: string;
128
- givenName: string;
129
- middleName: string;
130
- nickname: string;
131
- preferredUsername: string;
132
- profile: string;
133
- website: string;
134
- gender: string;
135
- birthdate: string;
136
- zoneinfo: string;
137
- locale: string;
138
- address: Partial<{
139
- formatted: string;
140
- streetAddress: string;
141
- locality: string;
142
- region: string;
143
- postalCode: string;
144
- country: string;
145
- }>;
146
- }>;
147
126
  createdAt: number;
148
- updatedAt: number;
127
+ profile: import("../foundations/index.js").UserProfile;
149
128
  customData: import("@withtyped/server/lib/types.js").JsonObject;
129
+ updatedAt: number;
150
130
  primaryEmail: string | null;
151
131
  primaryPhone: string | null;
152
132
  avatar: string | null;
153
- identities: Record<string, {
154
- userId: string;
155
- details?: Record<string, import("@withtyped/server/lib/types.js").Json> | undefined;
156
- }>;
133
+ identities: import("../foundations/index.js").Identities;
157
134
  isSuspended: boolean;
158
135
  lastSignInAt: number | null;
159
136
  }, {
@@ -161,46 +138,28 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
161
138
  id: string;
162
139
  applicationId: string | null;
163
140
  username: string | null;
164
- profile: Partial<{
165
- familyName: string;
166
- givenName: string;
167
- middleName: string;
168
- nickname: string;
169
- preferredUsername: string;
170
- profile: string;
171
- website: string;
172
- gender: string;
173
- birthdate: string;
174
- zoneinfo: string;
175
- locale: string;
176
- address: Partial<{
177
- formatted: string;
178
- streetAddress: string;
179
- locality: string;
180
- region: string;
181
- postalCode: string;
182
- country: string;
183
- }>;
184
- }>;
185
141
  createdAt: number;
186
- updatedAt: number;
142
+ profile: import("../foundations/index.js").UserProfile;
187
143
  customData: import("@withtyped/server/lib/types.js").JsonObject;
144
+ updatedAt: number;
188
145
  primaryEmail: string | null;
189
146
  primaryPhone: string | null;
190
147
  avatar: string | null;
191
- identities: Record<string, {
192
- userId: string;
193
- details?: Record<string, import("@withtyped/server/lib/types.js").Json> | undefined;
194
- }>;
148
+ identities: import("../foundations/index.js").Identities;
195
149
  isSuspended: boolean;
196
150
  lastSignInAt: number | null;
197
151
  }>;
198
152
  export type UserInfo = z.infer<typeof userInfoGuard>;
199
- export declare const userProfileResponseGuard: z.ZodObject<{
200
- name: z.ZodType<string | null, z.ZodTypeDef, string | null>;
153
+ export declare const userProfileResponseGuard: z.ZodObject<z.objectUtil.extendShape<Pick<{
154
+ tenantId: z.ZodType<string, z.ZodTypeDef, string>;
201
155
  id: z.ZodType<string, z.ZodTypeDef, string>;
202
- applicationId: z.ZodType<string | null, z.ZodTypeDef, string | null>;
203
156
  username: z.ZodType<string | null, z.ZodTypeDef, string | null>;
157
+ primaryEmail: z.ZodType<string | null, z.ZodTypeDef, string | null>;
158
+ primaryPhone: z.ZodType<string | null, z.ZodTypeDef, string | null>;
159
+ passwordEncrypted: z.ZodType<string | null, z.ZodTypeDef, string | null>;
160
+ passwordEncryptionMethod: z.ZodType<import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null, z.ZodTypeDef, import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null>;
161
+ name: z.ZodType<string | null, z.ZodTypeDef, string | null>;
162
+ avatar: z.ZodType<string | null, z.ZodTypeDef, string | null>;
204
163
  profile: z.ZodType<Partial<{
205
164
  familyName: string;
206
165
  givenName: string;
@@ -242,12 +201,7 @@ export declare const userProfileResponseGuard: z.ZodObject<{
242
201
  country: string;
243
202
  }>;
244
203
  }>>;
245
- createdAt: z.ZodType<number, z.ZodTypeDef, number>;
246
- updatedAt: z.ZodType<number, z.ZodTypeDef, number>;
247
- customData: z.ZodType<import("@withtyped/server/lib/types.js").JsonObject, z.ZodTypeDef, import("@withtyped/server/lib/types.js").JsonObject>;
248
- primaryEmail: z.ZodType<string | null, z.ZodTypeDef, string | null>;
249
- primaryPhone: z.ZodType<string | null, z.ZodTypeDef, string | null>;
250
- avatar: z.ZodType<string | null, z.ZodTypeDef, string | null>;
204
+ applicationId: z.ZodType<string | null, z.ZodTypeDef, string | null>;
251
205
  identities: z.ZodType<Record<string, {
252
206
  userId: string;
253
207
  details?: Record<string, import("@withtyped/server/lib/types.js").Json> | undefined;
@@ -255,46 +209,79 @@ export declare const userProfileResponseGuard: z.ZodObject<{
255
209
  userId: string;
256
210
  details?: Record<string, import("@withtyped/server/lib/types.js").Json> | undefined;
257
211
  }>>;
212
+ customData: z.ZodType<import("@withtyped/server/lib/types.js").JsonObject, z.ZodTypeDef, import("@withtyped/server/lib/types.js").JsonObject>;
213
+ logtoConfig: z.ZodType<import("@withtyped/server/lib/types.js").JsonObject, z.ZodTypeDef, import("@withtyped/server/lib/types.js").JsonObject>;
214
+ mfaVerifications: z.ZodType<({
215
+ type: MfaFactor.TOTP;
216
+ id: string;
217
+ key: string;
218
+ createdAt: string;
219
+ lastUsedAt?: string | undefined;
220
+ } | {
221
+ type: MfaFactor.WebAuthn;
222
+ id: string;
223
+ createdAt: string;
224
+ credentialId: string;
225
+ publicKey: string;
226
+ counter: number;
227
+ agent: string;
228
+ lastUsedAt?: string | undefined;
229
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
230
+ } | {
231
+ type: MfaFactor.BackupCode;
232
+ id: string;
233
+ createdAt: string;
234
+ codes: {
235
+ code: string;
236
+ usedAt?: string | undefined;
237
+ }[];
238
+ lastUsedAt?: string | undefined;
239
+ })[], z.ZodTypeDef, ({
240
+ type: MfaFactor.TOTP;
241
+ id: string;
242
+ key: string;
243
+ createdAt: string;
244
+ lastUsedAt?: string | undefined;
245
+ } | {
246
+ type: MfaFactor.WebAuthn;
247
+ id: string;
248
+ createdAt: string;
249
+ credentialId: string;
250
+ publicKey: string;
251
+ counter: number;
252
+ agent: string;
253
+ lastUsedAt?: string | undefined;
254
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
255
+ } | {
256
+ type: MfaFactor.BackupCode;
257
+ id: string;
258
+ createdAt: string;
259
+ codes: {
260
+ code: string;
261
+ usedAt?: string | undefined;
262
+ }[];
263
+ lastUsedAt?: string | undefined;
264
+ })[]>;
258
265
  isSuspended: z.ZodType<boolean, z.ZodTypeDef, boolean>;
259
266
  lastSignInAt: z.ZodType<number | null, z.ZodTypeDef, number | null>;
267
+ createdAt: z.ZodType<number, z.ZodTypeDef, number>;
268
+ updatedAt: z.ZodType<number, z.ZodTypeDef, number>;
269
+ }, "name" | "id" | "applicationId" | "username" | "createdAt" | "profile" | "customData" | "updatedAt" | "primaryEmail" | "primaryPhone" | "avatar" | "identities" | "isSuspended" | "lastSignInAt">, {
260
270
  hasPassword: z.ZodOptional<z.ZodBoolean>;
261
271
  ssoIdentities: z.ZodOptional<z.ZodArray<import("../foundations/schemas.js").Guard<import("../db-entries/user-sso-identity.js").UserSsoIdentity>, "many">>;
262
- }, "strip", z.ZodTypeAny, {
272
+ }>, "strip", z.ZodTypeAny, {
263
273
  name: string | null;
264
274
  id: string;
265
275
  applicationId: string | null;
266
276
  username: string | null;
267
- profile: Partial<{
268
- familyName: string;
269
- givenName: string;
270
- middleName: string;
271
- nickname: string;
272
- preferredUsername: string;
273
- profile: string;
274
- website: string;
275
- gender: string;
276
- birthdate: string;
277
- zoneinfo: string;
278
- locale: string;
279
- address: Partial<{
280
- formatted: string;
281
- streetAddress: string;
282
- locality: string;
283
- region: string;
284
- postalCode: string;
285
- country: string;
286
- }>;
287
- }>;
288
277
  createdAt: number;
289
- updatedAt: number;
278
+ profile: import("../foundations/index.js").UserProfile;
290
279
  customData: import("@withtyped/server/lib/types.js").JsonObject;
280
+ updatedAt: number;
291
281
  primaryEmail: string | null;
292
282
  primaryPhone: string | null;
293
283
  avatar: string | null;
294
- identities: Record<string, {
295
- userId: string;
296
- details?: Record<string, import("@withtyped/server/lib/types.js").Json> | undefined;
297
- }>;
284
+ identities: import("../foundations/index.js").Identities;
298
285
  isSuspended: boolean;
299
286
  lastSignInAt: number | null;
300
287
  hasPassword?: boolean | undefined;
@@ -304,37 +291,14 @@ export declare const userProfileResponseGuard: z.ZodObject<{
304
291
  id: string;
305
292
  applicationId: string | null;
306
293
  username: string | null;
307
- profile: Partial<{
308
- familyName: string;
309
- givenName: string;
310
- middleName: string;
311
- nickname: string;
312
- preferredUsername: string;
313
- profile: string;
314
- website: string;
315
- gender: string;
316
- birthdate: string;
317
- zoneinfo: string;
318
- locale: string;
319
- address: Partial<{
320
- formatted: string;
321
- streetAddress: string;
322
- locality: string;
323
- region: string;
324
- postalCode: string;
325
- country: string;
326
- }>;
327
- }>;
328
294
  createdAt: number;
329
- updatedAt: number;
295
+ profile: import("../foundations/index.js").UserProfile;
330
296
  customData: import("@withtyped/server/lib/types.js").JsonObject;
297
+ updatedAt: number;
331
298
  primaryEmail: string | null;
332
299
  primaryPhone: string | null;
333
300
  avatar: string | null;
334
- identities: Record<string, {
335
- userId: string;
336
- details?: Record<string, import("@withtyped/server/lib/types.js").Json> | undefined;
337
- }>;
301
+ identities: import("../foundations/index.js").Identities;
338
302
  isSuspended: boolean;
339
303
  lastSignInAt: number | null;
340
304
  hasPassword?: boolean | undefined;
@@ -464,8 +428,8 @@ export declare const featuredUserGuard: z.ZodObject<Pick<{
464
428
  publicKey: string;
465
429
  counter: number;
466
430
  agent: string;
467
- transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
468
431
  lastUsedAt?: string | undefined;
432
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
469
433
  } | {
470
434
  type: MfaFactor.BackupCode;
471
435
  id: string;
@@ -489,8 +453,8 @@ export declare const featuredUserGuard: z.ZodObject<Pick<{
489
453
  publicKey: string;
490
454
  counter: number;
491
455
  agent: string;
492
- transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
493
456
  lastUsedAt?: string | undefined;
457
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
494
458
  } | {
495
459
  type: MfaFactor.BackupCode;
496
460
  id: string;
@@ -0,0 +1,3 @@
1
+ import { ApplicationType } from '../db-entries/custom-types.js';
2
+ /** If the application type has (or can have) secrets. */
3
+ export declare const hasSecrets: (type: ApplicationType) => boolean;
@@ -0,0 +1,7 @@
1
+ import { ApplicationType } from '../db-entries/custom-types.js';
2
+ /** If the application type has (or can have) secrets. */
3
+ export const hasSecrets = (type) => [
4
+ ApplicationType.MachineToMachine,
5
+ ApplicationType.Protected,
6
+ ApplicationType.Traditional,
7
+ ].includes(type);
@@ -1,3 +1,4 @@
1
+ export * from './application.js';
1
2
  export * from './role.js';
2
3
  export * from './management-api.js';
3
4
  export * from './domain.js';
@@ -1,3 +1,4 @@
1
+ export * from './application.js';
1
2
  export * from './role.js';
2
3
  export * from './management-api.js';
3
4
  export * from './domain.js';
@@ -1,4 +1,4 @@
1
1
  import { type z } from 'zod';
2
2
  export type ToZodObject<T> = z.ZodObject<{
3
- [K in keyof T]: z.ZodType<T[K]>;
3
+ [K in keyof T]-?: z.ZodType<T[K]>;
4
4
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/schemas",
3
- "version": "1.17.0",
3
+ "version": "1.19.0",
4
4
  "author": "Silverhand Inc. <contact@silverhand.io>",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -31,16 +31,16 @@
31
31
  "@types/inquirer": "^9.0.0",
32
32
  "@types/node": "^20.9.5",
33
33
  "@types/pluralize": "^0.0.33",
34
- "@vitest/coverage-v8": "^1.4.0",
34
+ "@vitest/coverage-v8": "^2.0.0",
35
35
  "camelcase": "^8.0.0",
36
- "chalk": "^5.0.0",
36
+ "chalk": "^5.3.0",
37
37
  "eslint": "^8.56.0",
38
38
  "lint-staged": "^15.0.0",
39
39
  "pluralize": "^8.0.0",
40
40
  "prettier": "^3.0.0",
41
41
  "roarr": "^7.11.0",
42
- "typescript": "^5.3.3",
43
- "vitest": "^1.4.0"
42
+ "typescript": "^5.5.3",
43
+ "vitest": "^2.0.0"
44
44
  },
45
45
  "eslintConfig": {
46
46
  "extends": "@silverhand",
@@ -63,17 +63,17 @@
63
63
  },
64
64
  "prettier": "@silverhand/eslint-config/.prettierrc",
65
65
  "dependencies": {
66
- "@logto/connector-kit": "^3.0.0",
66
+ "@logto/connector-kit": "^4.0.0",
67
67
  "@logto/core-kit": "^2.5.0",
68
68
  "@logto/language-kit": "^1.1.0",
69
- "@logto/phrases": "^1.11.0",
70
- "@logto/phrases-experience": "^1.6.1",
69
+ "@logto/phrases": "^1.13.0",
70
+ "@logto/phrases-experience": "^1.7.0",
71
71
  "@logto/shared": "^3.1.1",
72
72
  "@withtyped/server": "^0.13.6",
73
73
  "nanoid": "^5.0.1"
74
74
  },
75
75
  "peerDependencies": {
76
- "zod": "^3.22.4"
76
+ "zod": "^3.23.8"
77
77
  },
78
78
  "scripts": {
79
79
  "precommit": "lint-staged",
@@ -0,0 +1,17 @@
1
+ /* init_order = 2 */
2
+
3
+ /** Application secrets for the `client_credentials` grant type and other confidential client use cases. Note that these secrets replace the `secret` column in the `applications` table, while the `secret` column is still used for the internal validation as `oidc-provider` does not support multiple secrets per client. */
4
+ create table application_secrets (
5
+ tenant_id varchar(21) not null
6
+ references tenants (id) on update cascade on delete cascade,
7
+ application_id varchar(21) not null
8
+ references applications (id) on update cascade on delete cascade,
9
+ /** The name of the secret. Should be unique within the application. */
10
+ name varchar(256) not null,
11
+ value varchar(64) not null,
12
+ created_at timestamptz not null default now(),
13
+ expires_at timestamptz,
14
+ primary key (tenant_id, application_id, name),
15
+ constraint application_type
16
+ check (check_application_type(application_id, 'MachineToMachine', 'Traditional', 'Protected'))
17
+ );
@@ -6,10 +6,10 @@ create table application_sign_in_experiences (
6
6
  references tenants (id) on update cascade on delete cascade,
7
7
  application_id varchar(21) not null
8
8
  references applications (id) on update cascade on delete cascade,
9
+ color jsonb /* @use PartialColor */ not null default '{}'::jsonb,
9
10
  branding jsonb /* @use Branding */ not null default '{}'::jsonb,
10
11
  terms_of_use_url varchar(2048),
11
12
  privacy_policy_url varchar(2048),
12
13
  display_name varchar(256),
13
-
14
14
  primary key (tenant_id, application_id)
15
15
  );
@@ -7,12 +7,14 @@ create table applications (
7
7
  references tenants (id) on update cascade on delete cascade,
8
8
  id varchar(21) not null,
9
9
  name varchar(256) not null,
10
+ /** @deprecated The internal client secret. Note it is only used for internal validation, and the actual secret should be stored in the `application_secrets` table. You should NOT use it unless you are sure what you are doing. */
10
11
  secret varchar(64) not null,
11
12
  description text,
12
13
  type application_type not null,
13
14
  oidc_client_metadata jsonb /* @use OidcClientMetadata */ not null,
14
15
  custom_client_metadata jsonb /* @use CustomClientMetadata */ not null default '{}'::jsonb,
15
16
  protected_app_metadata jsonb /* @use ProtectedAppMetadata */,
17
+ custom_data jsonb /* @use JsonObject */ not null default '{}'::jsonb,
16
18
  is_third_party boolean not null default false,
17
19
  created_at timestamptz not null default(now()),
18
20
  primary key (id)
@@ -33,3 +35,11 @@ create unique index applications__protected_app_metadata_custom_domain
33
35
  on applications (
34
36
  (protected_app_metadata->'customDomains'->0->>'domain')
35
37
  );
38
+
39
+ create function check_application_type(
40
+ application_id varchar(21),
41
+ variadic target_type application_type[]
42
+ ) returns boolean as
43
+ $$ begin
44
+ return (select type from applications where id = application_id) = any(target_type);
45
+ end; $$ language plpgsql set search_path = public;
@@ -0,0 +1,14 @@
1
+ /* init_order = 2 */
2
+
3
+ /** The relations between organizations and applications. It indicates membership of applications in organizations. For now only machine-to-machine applications are supported. */
4
+ create table organization_application_relations (
5
+ tenant_id varchar(21) not null
6
+ references tenants (id) on update cascade on delete cascade,
7
+ organization_id varchar(21) not null
8
+ references organizations (id) on update cascade on delete cascade,
9
+ application_id varchar(21) not null
10
+ references applications (id) on update cascade on delete cascade,
11
+ primary key (tenant_id, organization_id, application_id),
12
+ constraint application_type
13
+ check (check_application_type(application_id, 'MachineToMachine'))
14
+ );
@@ -0,0 +1,13 @@
1
+ /* init_order = 2 */
2
+
3
+ /** The email domains that will automatically assign users into an organization when they sign up or are added through the Management API. */
4
+ create table organization_jit_email_domains (
5
+ tenant_id varchar(21) not null
6
+ references tenants (id) on update cascade on delete cascade,
7
+ /** The ID of the organization. */
8
+ organization_id varchar(21) not null
9
+ references organizations (id) on update cascade on delete cascade,
10
+ /** The email domain that will be automatically provisioned. */
11
+ email_domain varchar(128) not null,
12
+ primary key (tenant_id, organization_id, email_domain)
13
+ );
@@ -0,0 +1,14 @@
1
+ /* init_order = 2 */
2
+
3
+ /** The organization roles that will be automatically provisioned to users when they join an organization through JIT. */
4
+ create table organization_jit_roles (
5
+ tenant_id varchar(21) not null
6
+ references tenants (id) on update cascade on delete cascade,
7
+ /** The ID of the organization. */
8
+ organization_id varchar(21) not null
9
+ references organizations (id) on update cascade on delete cascade,
10
+ /** The organization role ID that will be automatically provisioned. */
11
+ organization_role_id varchar(21) not null
12
+ references organization_roles (id) on update cascade on delete cascade,
13
+ primary key (tenant_id, organization_id, organization_role_id)
14
+ );
@@ -0,0 +1,13 @@
1
+ /* init_order = 2 */
2
+
3
+ /** The enterprise SSO connectors that will automatically assign users into an organization when they are authenticated via the SSO connector for the first time. */
4
+ create table organization_jit_sso_connectors (
5
+ tenant_id varchar(21) not null
6
+ references tenants (id) on update cascade on delete cascade,
7
+ /** The ID of the organization. */
8
+ organization_id varchar(21) not null
9
+ references organizations (id) on update cascade on delete cascade,
10
+ sso_connector_id varchar(128) not null
11
+ references sso_connectors (id) on update cascade on delete cascade,
12
+ primary key (tenant_id, organization_id, sso_connector_id)
13
+ );
@@ -0,0 +1,18 @@
1
+ /* init_order = 3 */
2
+
3
+ /** The relations between organizations, organization roles, and applications. A relation means that an application has a role in an organization. */
4
+ create table organization_role_application_relations (
5
+ tenant_id varchar(21) not null
6
+ references tenants (id) on update cascade on delete cascade,
7
+ organization_id varchar(21) not null,
8
+ organization_role_id varchar(21) not null
9
+ references organization_roles (id) on update cascade on delete cascade,
10
+ application_id varchar(21) not null,
11
+ primary key (tenant_id, organization_id, organization_role_id, application_id),
12
+ /** Application's roles in an organization should be synchronized with the application's membership in the organization. */
13
+ foreign key (tenant_id, organization_id, application_id)
14
+ references organization_application_relations (tenant_id, organization_id, application_id)
15
+ on update cascade on delete cascade,
16
+ constraint organization_role_application_relations__role_type
17
+ check (check_organization_role_type(organization_role_id, 'MachineToMachine'))
18
+ );
@@ -12,5 +12,7 @@ create table organization_role_user_relations (
12
12
  /** User's roles in an organization should be synchronized with the user's membership in the organization. */
13
13
  foreign key (tenant_id, organization_id, user_id)
14
14
  references organization_user_relations (tenant_id, organization_id, user_id)
15
- on update cascade on delete cascade
15
+ on update cascade on delete cascade,
16
+ constraint organization_role_user_relations__role_type
17
+ check (check_organization_role_type(organization_role_id, 'User'))
16
18
  );
@@ -1,4 +1,4 @@
1
- /* init_order = 1 */
1
+ /* init_order = 1.1 */
2
2
 
3
3
  /** The roles defined by the organization template. */
4
4
  create table organization_roles (
@@ -10,6 +10,8 @@ create table organization_roles (
10
10
  name varchar(128) not null,
11
11
  /** A brief description of the organization role. */
12
12
  description varchar(256),
13
+ /** The type of the organization role. Same as the `type` field in the `roles` table. */
14
+ type role_type not null default 'User',
13
15
  primary key (id),
14
16
  constraint organization_roles__name
15
17
  unique (tenant_id, name)
@@ -17,3 +19,8 @@ create table organization_roles (
17
19
 
18
20
  create index organization_roles__id
19
21
  on organization_roles (tenant_id, id);
22
+
23
+ create function check_organization_role_type(role_id varchar(21), target_type role_type) returns boolean as
24
+ $$ begin
25
+ return (select type from organization_roles where id = role_id) = target_type;
26
+ end; $$ language plpgsql set search_path = public;
@@ -12,6 +12,10 @@ create table organizations (
12
12
  description varchar(256),
13
13
  /** Additional data associated with the organization. */
14
14
  custom_data jsonb /* @use JsonObject */ not null default '{}'::jsonb,
15
+ /** Whether multi-factor authentication configuration is required for the members of the organization. */
16
+ is_mfa_required boolean not null default false,
17
+ /** The organization's branding configuration. */
18
+ branding jsonb /* @use Branding */ not null default '{}'::jsonb,
15
19
  /** When the organization was created. */
16
20
  created_at timestamptz not null default(now()),
17
21
  primary key (id)
@@ -1,4 +1,5 @@
1
1
  create type sign_in_mode as enum ('SignIn', 'Register', 'SignInAndRegister');
2
+ create type agree_to_terms_policy as enum ('Automatic', 'ManualRegistrationOnly', 'Manual');
2
3
 
3
4
  create table sign_in_experiences (
4
5
  tenant_id varchar(21) not null
@@ -9,12 +10,16 @@ create table sign_in_experiences (
9
10
  language_info jsonb /* @use LanguageInfo */ not null,
10
11
  terms_of_use_url varchar(2048),
11
12
  privacy_policy_url varchar(2048),
13
+ /** The policy that determines how users agree to the terms of use and privacy policy. */
14
+ agree_to_terms_policy agree_to_terms_policy not null default 'Automatic',
12
15
  sign_in jsonb /* @use SignIn */ not null,
13
16
  sign_up jsonb /* @use SignUp */ not null,
17
+ social_sign_in jsonb /* @use SocialSignIn */ not null default '{}'::jsonb,
14
18
  social_sign_in_connector_targets jsonb /* @use ConnectorTargets */ not null default '[]'::jsonb,
15
19
  sign_in_mode sign_in_mode not null default 'SignInAndRegister',
16
20
  custom_css text,
17
21
  custom_content jsonb /* @use CustomContent */ not null default '{}'::jsonb,
22
+ custom_ui_assets jsonb /* @use CustomUiAssets */,
18
23
  password_policy jsonb /* @use PartialPasswordPolicy */ not null default '{}'::jsonb,
19
24
  mfa jsonb /* @use Mfa */ not null default '{}'::jsonb,
20
25
  single_sign_on_enabled boolean not null default false,
@@ -0,0 +1,16 @@
1
+ create table subject_tokens (
2
+ tenant_id varchar(21) not null
3
+ references tenants (id) on update cascade on delete cascade,
4
+ id varchar(25) not null,
5
+ context jsonb /* @use JsonObject */ not null default '{}'::jsonb,
6
+ expires_at timestamptz not null,
7
+ consumed_at timestamptz,
8
+ user_id varchar(21) not null
9
+ references users (id) on update cascade on delete cascade,
10
+ created_at timestamptz not null default(now()),
11
+ /* It is intented to not reference to user or application table, it can be userId or applicationId, for audit only */
12
+ creator_id varchar(32) not null,
13
+ primary key (id)
14
+ );
15
+
16
+ create index subject_token__id on subject_tokens (tenant_id, id);
package/tables/users.sql CHANGED
@@ -1,6 +1,6 @@
1
1
  /* init_order = 1 */
2
2
 
3
- create type users_password_encryption_method as enum ('Argon2i', 'SHA1', 'SHA256', 'MD5', 'Bcrypt');
3
+ create type users_password_encryption_method as enum ('Argon2i', 'Argon2id', 'Argon2d', 'SHA1', 'SHA256', 'MD5', 'Bcrypt');
4
4
 
5
5
  create table users (
6
6
  tenant_id varchar(21) not null
@@ -1,3 +0,0 @@
1
- import type { AlterationScript } from '../lib/types/alteration.js';
2
- declare const alteration: AlterationScript;
3
- export default alteration;
@@ -1,3 +0,0 @@
1
- import type { AlterationScript } from '../lib/types/alteration.js';
2
- declare const alteration: AlterationScript;
3
- export default alteration;
@@ -1,3 +0,0 @@
1
- import type { AlterationScript } from '../lib/types/alteration.js';
2
- declare const alteration: AlterationScript;
3
- export default alteration;
@@ -1,3 +0,0 @@
1
- import type { AlterationScript } from '../lib/types/alteration.js';
2
- declare const alteration: AlterationScript;
3
- export default alteration;