@logto/schemas 1.18.0 → 1.20.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.
- package/alterations/1.19.0-1720253939-add-organization-branding.ts +18 -0
- package/alterations/1.19.0-1720345784-add-color-to-app-sie.ts +18 -0
- package/alterations/1.19.0-1720505152-update-custom-ui-assets.ts +20 -0
- package/alterations/1.19.0-1721483240-multiple-app-secrets.ts +77 -0
- package/alterations/1.19.0-1721645392-add-application-custom-data-column.ts +18 -0
- package/alterations/1.19.0-1722926389-argon2d-argon2id.ts +35 -0
- package/alterations/1.20.0-1723448981-personal-access-tokens.ts +35 -0
- package/alterations/1.20.0-1724229102-add-report-sub-updates-cloud-scope.ts +102 -0
- package/alterations/1.20.0-1724316971-add-verified-identifier-to-verification-statuses.ts +18 -0
- package/alterations/1.20.0-1725971571-add-verification-record.ts +35 -0
- package/alterations-js/1.19.0-1720253939-add-organization-branding.js +14 -0
- package/alterations-js/1.19.0-1720345784-add-color-to-app-sie.js +14 -0
- package/alterations-js/1.19.0-1720505152-update-custom-ui-assets.js +16 -0
- package/alterations-js/1.19.0-1721483240-multiple-app-secrets.js +72 -0
- package/alterations-js/1.19.0-1721645392-add-application-custom-data-column.js +14 -0
- package/alterations-js/1.19.0-1722926389-argon2d-argon2id.js +30 -0
- package/alterations-js/1.20.0-1723448981-personal-access-tokens.js +30 -0
- package/alterations-js/1.20.0-1724229102-add-report-sub-updates-cloud-scope.js +59 -0
- package/alterations-js/1.20.0-1724316971-add-verified-identifier-to-verification-statuses.js +14 -0
- package/alterations-js/1.20.0-1725971571-add-verification-record.js +30 -0
- package/lib/consts/experience.d.ts +8 -5
- package/lib/consts/experience.js +3 -0
- package/lib/consts/oidc.d.ts +48 -4
- package/lib/consts/oidc.js +32 -1
- package/lib/consts/subscriptions.d.ts +1 -0
- package/lib/consts/subscriptions.js +1 -0
- package/lib/consts/system.d.ts +2 -0
- package/lib/consts/system.js +2 -0
- package/lib/db-entries/application-secret.d.ts +28 -0
- package/lib/db-entries/application-secret.js +41 -0
- package/lib/db-entries/application-sign-in-experience.d.ts +4 -2
- package/lib/db-entries/application-sign-in-experience.js +5 -1
- package/lib/db-entries/application.d.ts +6 -2
- package/lib/db-entries/application.js +5 -1
- package/lib/db-entries/custom-types.d.ts +2 -0
- package/lib/db-entries/custom-types.js +2 -0
- package/lib/db-entries/index.d.ts +3 -0
- package/lib/db-entries/index.js +3 -0
- package/lib/db-entries/organization.d.ts +6 -2
- package/lib/db-entries/organization.js +5 -1
- package/lib/db-entries/personal-access-token.d.ts +26 -0
- package/lib/db-entries/personal-access-token.js +41 -0
- package/lib/db-entries/sign-in-experience.d.ts +4 -4
- package/lib/db-entries/sign-in-experience.js +5 -5
- package/lib/db-entries/verification-record.d.ts +26 -0
- package/lib/db-entries/verification-record.js +42 -0
- package/lib/db-entries/verification-status.d.ts +3 -1
- package/lib/db-entries/verification-status.js +4 -0
- package/lib/foundations/jsonb-types/index.d.ts +1 -0
- package/lib/foundations/jsonb-types/index.js +1 -0
- package/lib/foundations/jsonb-types/logs.d.ts +3 -0
- package/lib/foundations/jsonb-types/logs.js +1 -0
- package/lib/foundations/jsonb-types/sign-in-experience.d.ts +37 -3
- package/lib/foundations/jsonb-types/sign-in-experience.js +19 -4
- package/lib/foundations/jsonb-types/users.d.ts +6 -6
- package/lib/foundations/jsonb-types/users.js +2 -2
- package/lib/foundations/jsonb-types/verification-records.d.ts +13 -0
- package/lib/foundations/jsonb-types/verification-records.js +14 -0
- package/lib/seeds/application.js +1 -0
- package/lib/seeds/cloud-api.d.ts +5 -1
- package/lib/seeds/cloud-api.js +5 -0
- package/lib/seeds/sign-in-experience.d.ts +1 -0
- package/lib/seeds/sign-in-experience.js +2 -2
- package/lib/types/application.d.ts +80 -122
- package/lib/types/connector.d.ts +34 -28
- package/lib/types/consent.d.ts +180 -33
- package/lib/types/cookie.d.ts +7 -1
- package/lib/types/cookie.js +3 -1
- package/lib/types/domain.d.ts +2 -10
- package/lib/types/hook.d.ts +14 -21
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/interactions.d.ts +202 -65
- package/lib/types/interactions.js +39 -23
- package/lib/types/log/interaction.d.ts +4 -3
- package/lib/types/log/interaction.js +1 -0
- package/lib/types/logto-config/index.d.ts +267 -242
- package/lib/types/logto-config/jwt-customizer.d.ts +548 -371
- package/lib/types/logto-config/jwt-customizer.js +28 -1
- package/lib/types/logto-config/oidc-provider.d.ts +6 -6
- package/lib/types/mfa.d.ts +16 -16
- package/lib/types/scope.d.ts +7 -6
- package/lib/types/sign-in-experience.d.ts +57 -120
- package/lib/types/sign-in-experience.js +1 -1
- package/lib/types/sso-connector.d.ts +14 -19
- package/lib/types/ssr.d.ts +25 -0
- package/lib/types/ssr.js +9 -0
- package/lib/types/system.d.ts +7 -3
- package/lib/types/system.js +4 -0
- package/lib/types/user-assets.d.ts +25 -5
- package/lib/types/user-assets.js +20 -1
- package/lib/types/user.d.ts +84 -120
- package/lib/utils/application.d.ts +3 -0
- package/lib/utils/application.js +7 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/package.json +9 -9
- package/tables/application_secrets.sql +17 -0
- package/tables/application_sign_in_experiences.sql +1 -1
- package/tables/applications.sql +7 -2
- package/tables/organizations.sql +2 -0
- package/tables/personal_access_tokens.sql +16 -0
- package/tables/sign_in_experiences.sql +1 -1
- package/tables/users.sql +1 -1
- package/tables/verification_records.sql +15 -0
- package/tables/verification_statuses.sql +1 -0
- package/alterations-js/1.0.0-1677208902-update-admin-console-config.d.ts +0 -3
- package/alterations-js/1.0.0-1677765137-seed-for-admin-tenant.d.ts +0 -3
- package/alterations-js/1.0.0-1677907982-allow-admin-create-multiple-tenants.d.ts +0 -3
- package/alterations-js/1.0.0-1678157950-privacy-policy-url.d.ts +0 -3
- package/alterations-js/1.0.0-1678199795-add-verification-status-table.d.ts +0 -3
- package/alterations-js/1.0.0-1678259693-remove-branding-style-config.d.ts +0 -3
- package/alterations-js/1.0.0-1678269972-use-restrictive-policies.d.ts +0 -3
- package/alterations-js/1.0.0-1678284778-restrict-internal-roles.d.ts +0 -3
- package/alterations-js/1.0.0-1678425761-m2m-app-for-tenants.d.ts +0 -3
- package/alterations-js/1.0.0-1678450233-support-custom-content.d.ts +0 -3
- package/alterations-js/1.0.0-1678716747-service-logs.d.ts +0 -3
- package/alterations-js/1.0.0-1678928481-remove-deprecated-logto-config-item.d.ts +0 -3
- package/alterations-js/1.0.0-1678953179-update-get-started-task-config.d.ts +0 -3
- package/alterations-js/1.0.0-1679209413-drop-connector-database-storage.d.ts +0 -3
- package/alterations-js/1.0.0_beta.10-1-logto-config.d.ts +0 -3
- package/alterations-js/1.0.0_beta.10-1663923211-machine-to-machine-app.d.ts +0 -3
- package/alterations-js/1.0.0_beta.10-1664265197-custom-phrases.d.ts +0 -3
- package/alterations-js/1.0.0_beta.11-1664347703-rename-language-key-to-tag.d.ts +0 -3
- package/alterations-js/1.0.0_beta.11-1664356000-add-created-at-column-to-users.d.ts +0 -3
- package/alterations-js/1.0.0_beta.11-1664462389-correct-user-created-at-column-by-user-logs.d.ts +0 -3
- package/alterations-js/1.0.0_beta.14-1665300135-sign-in-sign-up.d.ts +0 -3
- package/alterations-js/1.0.0_beta.14-1667283640-remove-forgot-password.d.ts +0 -3
- package/alterations-js/1.0.0_beta.14-1667292082-remove-sign-in-method.d.ts +0 -3
- package/alterations-js/1.0.0_beta.14-1667374974-user-suspend.d.ts +0 -3
- package/alterations-js/1.0.0_beta.14-1667900481-add-passcode-type-continue.d.ts +0 -3
- package/alterations-js/1.0.0_beta.18-1668666590-support-multiple-connector-instances.d.ts +0 -3
- package/alterations-js/1.0.0_beta.18-1668666600-remove-connector-enabled.d.ts +0 -3
- package/alterations-js/1.0.0_beta.18-1669091623-roles-and-scopes.d.ts +0 -3
- package/alterations-js/1.0.0_beta.18-1669702299-sign-up.d.ts +0 -3
- package/alterations-js/1.0.0_beta.18-1671039448-add-user-name-index.d.ts +0 -3
- package/alterations-js/1.0.0_beta.18-1671080370-terms-of-use.d.ts +0 -3
- package/alterations-js/1.0.0_beta.18-1671336831-refactor-log-types.d.ts +0 -3
- package/alterations-js/1.0.0_beta.18-1671509870-hooks.d.ts +0 -3
- package/alterations-js/1.0.0_beta.18-1672119200-align-passcode-type-with-message-type.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1672815959-user-roles.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1672820345-scope-resource-id.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1672901841-roles-and-scopes-not-null.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1673001922-support-generic-passcode.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1673165463-scope-name-index.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1673349501-sms-sign-in-identifier-to-phone.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1673465463-ac-scope-name.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1673853579-ac-default-scope.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1673863835-ac-scope-role.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1673882867-fix-alteration-issues.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1673940577-scope-description-not-null.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1673941897-application-roles.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1674032095.1-dedup-resources-constraint.d.ts +0 -4
- package/alterations-js/1.0.0_rc.0-1674032095.2-oidc-model-pkey.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1674032095.3-tenant-table.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1674032095.4-add-id-column.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1674032095.5-multi-tenancy.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1674032095.6-add-tenant-id-trigger.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1674987042-drop-settings-and-create-systems.d.ts +0 -3
- package/alterations-js/1.0.0_rc.0-1675316731-update-seed-data.d.ts +0 -3
- package/alterations-js/1.0.0_rc.1-1675788753-multi-tenancy-rls.d.ts +0 -3
- package/alterations-js/1.0.0_rc.1-1676115897-add-admin-tenant.d.ts +0 -3
- package/alterations-js/1.0.0_rc.1-1676185899-fix-logs-index.d.ts +0 -3
- package/alterations-js/1.0.0_rc.1-1676190092-migrate-admin-data.d.ts +0 -3
- package/alterations-js/1.0.0_rc.1-1676823841-update-sie-primary-key.d.ts +0 -3
- package/alterations-js/1.0.0_rc.1-1676874936-support-custom-css.d.ts +0 -3
- package/alterations-js/1.0.0_rc.1-1676886855-connector-database-read-write.d.ts +0 -3
- package/alterations-js/1.0.0_rc.1-1676906977-remove-demo-app.d.ts +0 -3
- package/alterations-js/1.0.0_rc.1-1676956206-move-console-sie-to-database.d.ts +0 -3
- package/alterations-js/1.0.0_rc.1-1677059985-move-console-application-to-database.d.ts +0 -3
- package/alterations-js/1.10.1-1695647183-update-private-key-type.d.ts +0 -3
- package/alterations-js/1.10.1-1696657546-organization-tables.d.ts +0 -3
- package/alterations-js/1.10.1-1697683802-add-sso-connectors-table.d.ts +0 -3
- package/alterations-js/1.10.1-1698646271-add-organization-created-flag.d.ts +0 -3
- package/alterations-js/1.10.1-1698820410-add-user-sso-identities-table.d.ts +0 -4
- package/alterations-js/1.10.1-1698910485-user-logto-data.d.ts +0 -3
- package/alterations-js/1.11.0-1699422979-add-sso-connector-id-col-to-user-sso-identities-table.d.ts +0 -3
- package/alterations-js/1.11.0-1699598903-remove-sso-only-column-in-sso-connectors-table.d.ts +0 -3
- package/alterations-js/1.12.0-1700031616-update-org-role-foreign-keys.d.ts +0 -3
- package/alterations-js/1.12.0-1701054133-add-unique-constraint-to-the-sso-connector-name.d.ts +0 -3
- package/alterations-js/1.12.0-1701245520-add-single-sign-on-enabled-flag-to-sie.d.ts +0 -3
- package/alterations-js/1.13.0-1702274830-add-new-third-party-column-to-applications-table.d.ts +0 -3
- package/alterations-js/1.13.0-1702372401-add-application-permissions-tables.d.ts +0 -3
- package/alterations-js/1.13.0-1702544178-sync-tenant-orgs.d.ts +0 -18
- package/alterations-js/1.13.0-1702871078-protected-application-type.d.ts +0 -3
- package/alterations-js/1.13.0-1702877515-protected-app-configs.d.ts +0 -3
- package/alterations-js/1.13.0-1702978120-application-sign-in-experience-table.d.ts +0 -3
- package/alterations-js/1.13.0-1703229996-daily-token-usage.d.ts +0 -3
- package/alterations-js/1.13.0-1703230000-update-tenant-roles.d.ts +0 -11
- package/alterations-js/1.13.0-1704692973-remove-legacy-resources.d.ts +0 -3
- package/alterations-js/1.13.0-1704934999-add-magic-links-table.d.ts +0 -3
- package/alterations-js/1.13.0-1704935001-add-organization-invitation-tables.d.ts +0 -3
- package/alterations-js/1.13.0-1705288654-add-application-user-consent-organizations-table.d.ts +0 -3
- package/alterations-js/1.13.0-1705991158-update-invitation-indices.d.ts +0 -7
- package/alterations-js/1.13.0-1706449174-update-organization-invitation-column.d.ts +0 -3
- package/alterations-js/1.13.0-1706510290-protected-app-host-index.d.ts +0 -3
- package/alterations-js/1.13.0-1706512952-restore-get-started-page.d.ts +0 -3
- package/alterations-js/1.13.0-1706528755-remove-magic-links.d.ts +0 -3
- package/alterations-js/1.13.0-1706585206-protected-app-custom-domain-unique.d.ts +0 -3
- package/alterations-js/1.13.1-1707360939-grant-is-suspended-read-permission.d.ts +0 -6
- package/alterations-js/1.14.0-1708916601-remove-management-api-scopes-assigned-to-user-role.d.ts +0 -3
- package/alterations-js/1.14.0-1709190131-enhance-dau-data-accuracy.d.ts +0 -3
- package/alterations-js/1.15.0-1709521416-user-password-encrypt-method.d.ts +0 -3
- package/alterations-js/1.15.0-1709528944-regenerate-dau-data.d.ts +0 -3
- package/alterations-js/1.15.0-1710223946-add-fetch-custom-jwt-cloud-scope.d.ts +0 -3
- package/alterations-js/1.15.0-1710408335-make-resource-scopes-description-nullable.d.ts +0 -3
- package/alterations-js/1.15.0-1710859622-add-oidc-standard-claim-properties.d.ts +0 -3
- package/alterations-js/1.15.0-1711607772-remove-invite-member-scope-from-tenant-member-role.d.ts +0 -3
- package/alterations-js/1.15.0-1711624564-add-read-member-scope-to-tenant-roles.d.ts +0 -3
- package/alterations-js/1.15.0-1711955211-organization-resource-scope.d.ts +0 -3
- package/alterations-js/1.15.0-1712041436-rename-organization-member-role-to-collaborator.d.ts +0 -3
- package/alterations-js/1.15.0-1712545011-fix-organization-resource-scope.d.ts +0 -8
- package/alterations-js/1.15.0-1712559358-fix-down-organization-resource-scope.d.ts +0 -8
- package/alterations-js/1.16.0-1712912361-delete-jwt-customier-with-empty-script.d.ts +0 -3
- package/alterations-js/1.16.0-1713942039-add-organization-custom-data.d.ts +0 -4
- package/alterations-js/1.16.0-1714270244-application-org-resource-scope.d.ts +0 -3
- package/alterations-js/1.17.0-1715826336-add-default-user-role-config.d.ts +0 -3
- package/alterations-js/1.17.0-1715829731-rename-data-hook-schema-update-event.d.ts +0 -3
- package/alterations-js/1.17.0-1716278409-remove-internal-role-database-policies.d.ts +0 -3
- package/alterations-js/1.17.0-1716291265-create-pre-configured-m-api-role.d.ts +0 -7
- package/alterations-js/1.17.0-1717148078-remove-service-log-reference.d.ts +0 -3
- package/alterations-js/1.18.0-1717567857-social-sign-in-linking.d.ts +0 -3
- package/alterations-js/1.18.0-1717597875-add-organization-email-domains-table.d.ts +0 -3
- package/alterations-js/1.18.0-1717818597-organization-mfa-requirement.d.ts +0 -3
- package/alterations-js/1.18.0-1718340884-rename-org-email-domains-and-add-jit-roles-table.d.ts +0 -3
- package/alterations-js/1.18.0-1718594164-add-agree-to-terms-policy.d.ts +0 -3
- package/alterations-js/1.18.0-1718785576-organization-application-relations.d.ts +0 -3
- package/alterations-js/1.18.0-1718786576-organization-jit-sso-connectors.d.ts +0 -3
- package/alterations-js/1.18.0-1718807616-organization-role-application-relations.d.ts +0 -3
- package/alterations-js/1.18.0-1718865814-add-subject-tokens.d.ts +0 -3
- package/alterations-js/1.18.0-1719014832-organization-role-types.d.ts +0 -3
- package/alterations-js/1.18.0-1719221205-fix-functions.d.ts +0 -7
- package/alterations-js/1.18.0-1719312694-custom-ui-assets.d.ts +0 -3
- package/alterations-js/1.2.0-1681267285-fix-get-started-passwordless-status.d.ts +0 -3
- package/alterations-js/1.3.0-1683292832-update-hooks.d.ts +0 -3
- package/alterations-js/1.5.0-1684382842-add-name-tag-created-at-for-tenants-table.d.ts +0 -3
- package/alterations-js/1.5.0-1684739802-create-hook-id-index-for-logs.d.ts +0 -3
- package/alterations-js/1.5.0-1684822341-init-domains.d.ts +0 -3
- package/alterations-js/1.5.0-1684837981-add-manage-tenant-self-scope-to-user-role.d.ts +0 -3
- package/alterations-js/1.5.0-1685285719-support-default-resource.d.ts +0 -3
- package/alterations-js/1.6.0-1685691718-domain-unique.d.ts +0 -3
- package/alterations-js/1.7.0-1688375200-sync-cloud-m2m-to-logto-config.d.ts +0 -3
- package/alterations-js/1.7.0-1688613459-remove-m2m-credentials-from-existing-logto-email-connector-config.d.ts +0 -3
- package/alterations-js/1.7.0-1688627407-daily-active-users.d.ts +0 -3
- package/alterations-js/1.8.0-1692088012-add-is-suspend-column-to-tenants-table.d.ts +0 -3
- package/alterations-js/1.8.0-1692194751-add-affiliate-scopes.d.ts +0 -3
- package/alterations-js/1.9.0-1693554904-add-possword-policy.d.ts +0 -4
- package/alterations-js/1.9.0-1694399696-add-type-col-to-roles-table.d.ts +0 -3
- package/alterations-js/1.9.0-1694418765-specify-check-role-type-function-to-be-public-schema.d.ts +0 -9
- package/alterations-js/1.9.0-1694484927-remove-deprecated-challenge-flag.d.ts +0 -3
- package/alterations-js/1.9.0-1694487524-sie-mfa.d.ts +0 -3
- package/alterations-js/1.9.0-1694509714-keep-existing-password-policy.d.ts +0 -3
- package/alterations-js/1.9.0-1694746763-user-verifications.d.ts +0 -3
- package/alterations-js/1.9.2-1694854226-init-sentinel.d.ts +0 -3
- package/alterations-js/1.9.2-1695198741-remove-m2m-app-admin-access-switch.d.ts +0 -3
- package/alterations-js/utils/1704934999-tables.d.ts +0 -11
- package/alterations-js/utils/1716643968-id-generation.d.ts +0 -19
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
const alteration: AlterationScript = {
|
|
6
|
+
up: async (pool) => {
|
|
7
|
+
await pool.query(sql`
|
|
8
|
+
alter table organizations add column branding jsonb not null default '{}'::jsonb;
|
|
9
|
+
`);
|
|
10
|
+
},
|
|
11
|
+
down: async (pool) => {
|
|
12
|
+
await pool.query(sql`
|
|
13
|
+
alter table organizations drop column branding;
|
|
14
|
+
`);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default alteration;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
const alteration: AlterationScript = {
|
|
6
|
+
up: async (pool) => {
|
|
7
|
+
await pool.query(sql`
|
|
8
|
+
alter table application_sign_in_experiences add column color jsonb not null default '{}'::jsonb;
|
|
9
|
+
`);
|
|
10
|
+
},
|
|
11
|
+
down: async (pool) => {
|
|
12
|
+
await pool.query(sql`
|
|
13
|
+
alter table application_sign_in_experiences drop column color;
|
|
14
|
+
`);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default alteration;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
const alteration: AlterationScript = {
|
|
6
|
+
up: async (pool) => {
|
|
7
|
+
await pool.query(sql`
|
|
8
|
+
alter table sign_in_experiences drop column custom_ui_asset_id;
|
|
9
|
+
alter table sign_in_experiences add column custom_ui_assets jsonb;
|
|
10
|
+
`);
|
|
11
|
+
},
|
|
12
|
+
down: async (pool) => {
|
|
13
|
+
await pool.query(sql`
|
|
14
|
+
alter table sign_in_experiences add column custom_ui_asset_id varchar(21);
|
|
15
|
+
alter table sign_in_experiences drop column custom_ui_assets;
|
|
16
|
+
`);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default alteration;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
|
|
6
|
+
|
|
7
|
+
const alteration: AlterationScript = {
|
|
8
|
+
up: async (pool) => {
|
|
9
|
+
await pool.query(sql`
|
|
10
|
+
-- Remove existing constraint
|
|
11
|
+
alter table organization_application_relations drop constraint application_type;
|
|
12
|
+
|
|
13
|
+
-- Drop the function
|
|
14
|
+
drop function check_application_type;
|
|
15
|
+
|
|
16
|
+
-- Create a new function that accepts a variadic array of application types
|
|
17
|
+
create function check_application_type(
|
|
18
|
+
application_id varchar(21),
|
|
19
|
+
variadic target_type application_type[]
|
|
20
|
+
) returns boolean as
|
|
21
|
+
$$ begin
|
|
22
|
+
return (select type from applications where id = application_id) = any(target_type);
|
|
23
|
+
end; $$ language plpgsql set search_path = public;
|
|
24
|
+
|
|
25
|
+
-- Add back the constraint
|
|
26
|
+
alter table organization_application_relations
|
|
27
|
+
add constraint application_type
|
|
28
|
+
check (check_application_type(application_id, 'MachineToMachine'));
|
|
29
|
+
|
|
30
|
+
-- Create the new table
|
|
31
|
+
create table application_secrets (
|
|
32
|
+
tenant_id varchar(21) not null
|
|
33
|
+
references tenants (id) on update cascade on delete cascade,
|
|
34
|
+
application_id varchar(21) not null
|
|
35
|
+
references applications (id) on update cascade on delete cascade,
|
|
36
|
+
/** The name of the secret. Should be unique within the application. */
|
|
37
|
+
name varchar(256) not null,
|
|
38
|
+
value varchar(64) not null,
|
|
39
|
+
expires_at timestamptz,
|
|
40
|
+
created_at timestamptz not null default now(),
|
|
41
|
+
primary key (tenant_id, application_id, name),
|
|
42
|
+
constraint application_type
|
|
43
|
+
check (check_application_type(application_id, 'MachineToMachine', 'Traditional', 'Protected'))
|
|
44
|
+
);
|
|
45
|
+
`);
|
|
46
|
+
await applyTableRls(pool, 'application_secrets');
|
|
47
|
+
},
|
|
48
|
+
down: async (pool) => {
|
|
49
|
+
await dropTableRls(pool, 'application_secrets');
|
|
50
|
+
await pool.query(sql`
|
|
51
|
+
-- Remove the table
|
|
52
|
+
drop table application_secrets;
|
|
53
|
+
|
|
54
|
+
-- Remove the constraint
|
|
55
|
+
alter table organization_application_relations drop constraint application_type;
|
|
56
|
+
|
|
57
|
+
-- Drop the function
|
|
58
|
+
drop function check_application_type;
|
|
59
|
+
|
|
60
|
+
-- Restore the original function
|
|
61
|
+
create function check_application_type(
|
|
62
|
+
application_id varchar(21),
|
|
63
|
+
target_type application_type
|
|
64
|
+
) returns boolean as
|
|
65
|
+
$$ begin
|
|
66
|
+
return (select type from applications where id = application_id) = target_type;
|
|
67
|
+
end; $$ language plpgsql set search_path = public;
|
|
68
|
+
|
|
69
|
+
-- Add back the constraint
|
|
70
|
+
alter table organization_application_relations
|
|
71
|
+
add constraint application_type
|
|
72
|
+
check (check_application_type(application_id, 'MachineToMachine'));
|
|
73
|
+
`);
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export default alteration;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
const alteration: AlterationScript = {
|
|
6
|
+
up: async (pool) => {
|
|
7
|
+
await pool.query(sql`
|
|
8
|
+
alter table applications add column custom_data jsonb not null default '{}'::jsonb;
|
|
9
|
+
`);
|
|
10
|
+
},
|
|
11
|
+
down: async (pool) => {
|
|
12
|
+
await pool.query(sql`
|
|
13
|
+
alter table applications drop column custom_data;
|
|
14
|
+
`);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default alteration;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
const alteration: AlterationScript = {
|
|
6
|
+
up: async (pool) => {
|
|
7
|
+
await pool.query(sql`
|
|
8
|
+
alter type users_password_encryption_method add value 'Argon2id';
|
|
9
|
+
alter type users_password_encryption_method add value 'Argon2d';
|
|
10
|
+
`);
|
|
11
|
+
},
|
|
12
|
+
down: async (pool) => {
|
|
13
|
+
const { rows } = await pool.query(sql`
|
|
14
|
+
select id from users
|
|
15
|
+
where password_encryption_method = ${'Argon2id'}
|
|
16
|
+
or password_encryption_method = ${'Argon2d'}
|
|
17
|
+
`);
|
|
18
|
+
if (rows.length > 0) {
|
|
19
|
+
throw new Error('There are users with password encryption methods Argon2id or Argon2d.');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
await pool.query(sql`
|
|
23
|
+
create type users_password_encryption_method_revised as enum ('Argon2i', 'SHA1', 'SHA256', 'MD5', 'Bcrypt');
|
|
24
|
+
|
|
25
|
+
alter table users
|
|
26
|
+
alter column password_encryption_method type users_password_encryption_method_revised
|
|
27
|
+
using password_encryption_method::text::users_password_encryption_method_revised;
|
|
28
|
+
|
|
29
|
+
drop type users_password_encryption_method;
|
|
30
|
+
alter type users_password_encryption_method_revised rename to users_password_encryption_method;
|
|
31
|
+
`);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default alteration;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
|
|
6
|
+
|
|
7
|
+
const alteration: AlterationScript = {
|
|
8
|
+
up: async (pool) => {
|
|
9
|
+
await pool.query(sql`
|
|
10
|
+
create table personal_access_tokens (
|
|
11
|
+
tenant_id varchar(21) not null
|
|
12
|
+
references tenants (id) on update cascade on delete cascade,
|
|
13
|
+
user_id varchar(21) not null
|
|
14
|
+
references users (id) on update cascade on delete cascade,
|
|
15
|
+
/** The name of the secret. Should be unique within the user. */
|
|
16
|
+
name varchar(256) not null,
|
|
17
|
+
value varchar(64) not null,
|
|
18
|
+
created_at timestamptz not null default now(),
|
|
19
|
+
expires_at timestamptz,
|
|
20
|
+
primary key (tenant_id, user_id, name)
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
create index personal_access_token__value on personal_access_tokens (tenant_id, value);
|
|
24
|
+
`);
|
|
25
|
+
await applyTableRls(pool, 'personal_access_tokens');
|
|
26
|
+
},
|
|
27
|
+
down: async (pool) => {
|
|
28
|
+
await dropTableRls(pool, 'personal_access_tokens');
|
|
29
|
+
await pool.query(sql`
|
|
30
|
+
drop table personal_access_tokens;
|
|
31
|
+
`);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default alteration;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
import { generateStandardId } from './utils/1716643968-id-generation.js';
|
|
6
|
+
|
|
7
|
+
type Resource = {
|
|
8
|
+
tenantId: string;
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
indicator: string;
|
|
12
|
+
isDefault: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type Scope = {
|
|
16
|
+
tenantId: string;
|
|
17
|
+
id: string;
|
|
18
|
+
resourceId: string;
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type Role = {
|
|
24
|
+
tenantId: string;
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const cloudApiIndicator = 'https://cloud.logto.io/api';
|
|
31
|
+
|
|
32
|
+
const cloudConnectionAppRoleName = 'tenantApplication';
|
|
33
|
+
|
|
34
|
+
const adminTenantId = 'admin';
|
|
35
|
+
|
|
36
|
+
const reportSubscriptionUpdatesScopeName = 'report:subscription:updates';
|
|
37
|
+
const reportSubscriptionUpdatesScopeDescription =
|
|
38
|
+
'Allow reporting changes on Stripe subscription to Logto Cloud.';
|
|
39
|
+
|
|
40
|
+
const alteration: AlterationScript = {
|
|
41
|
+
up: async (pool) => {
|
|
42
|
+
// Get the Cloud API resource
|
|
43
|
+
const cloudApiResource = await pool.maybeOne<Resource>(sql`
|
|
44
|
+
select * from resources
|
|
45
|
+
where tenant_id = ${adminTenantId}
|
|
46
|
+
and indicator = ${cloudApiIndicator}
|
|
47
|
+
`);
|
|
48
|
+
|
|
49
|
+
if (!cloudApiResource) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Get cloud connection application role
|
|
54
|
+
const tenantApplicationRole = await pool.one<Role>(sql`
|
|
55
|
+
select * from roles
|
|
56
|
+
where tenant_id = ${adminTenantId}
|
|
57
|
+
and name = ${cloudConnectionAppRoleName} and type = 'MachineToMachine'
|
|
58
|
+
`);
|
|
59
|
+
|
|
60
|
+
// Create the `report:subscription:updates` scope
|
|
61
|
+
const reportSubscriptionUpdatesCloudScope = await pool.one<Scope>(sql`
|
|
62
|
+
insert into scopes (id, tenant_id, resource_id, name, description)
|
|
63
|
+
values (${generateStandardId()}, ${adminTenantId}, ${
|
|
64
|
+
cloudApiResource.id
|
|
65
|
+
}, ${reportSubscriptionUpdatesScopeName}, ${reportSubscriptionUpdatesScopeDescription})
|
|
66
|
+
on conflict (tenant_id, name, resource_id) do nothing
|
|
67
|
+
returning *;
|
|
68
|
+
`);
|
|
69
|
+
|
|
70
|
+
// Assign the `report:subscription:updates` scope to cloud connection application role
|
|
71
|
+
await pool.query(sql`
|
|
72
|
+
insert into roles_scopes (id, tenant_id, role_id, scope_id)
|
|
73
|
+
values (${generateStandardId()}, ${adminTenantId}, ${tenantApplicationRole.id}, ${
|
|
74
|
+
reportSubscriptionUpdatesCloudScope.id
|
|
75
|
+
}) on conflict (tenant_id, role_id, scope_id) do nothing;
|
|
76
|
+
`);
|
|
77
|
+
},
|
|
78
|
+
down: async (pool) => {
|
|
79
|
+
// Get the Cloud API resource
|
|
80
|
+
const cloudApiResource = await pool.maybeOne<Resource>(sql`
|
|
81
|
+
select * from resources
|
|
82
|
+
where tenant_id = ${adminTenantId}
|
|
83
|
+
and indicator = ${cloudApiIndicator}
|
|
84
|
+
`);
|
|
85
|
+
|
|
86
|
+
if (!cloudApiResource) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Remove the `report:subscription:updates` scope
|
|
91
|
+
await pool.query(sql`
|
|
92
|
+
delete from scopes
|
|
93
|
+
where
|
|
94
|
+
tenant_id = ${adminTenantId} and
|
|
95
|
+
name = ${reportSubscriptionUpdatesScopeName} and
|
|
96
|
+
description = ${reportSubscriptionUpdatesScopeDescription} and
|
|
97
|
+
resource_id = ${cloudApiResource.id}
|
|
98
|
+
`);
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default alteration;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
const alteration: AlterationScript = {
|
|
6
|
+
up: async (pool) => {
|
|
7
|
+
await pool.query(sql`
|
|
8
|
+
alter table verification_statuses add column verified_identifier varchar(255);
|
|
9
|
+
`);
|
|
10
|
+
},
|
|
11
|
+
down: async (pool) => {
|
|
12
|
+
await pool.query(sql`
|
|
13
|
+
alter table verification_statuses drop column verified_identifier;
|
|
14
|
+
`);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default alteration;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
|
|
6
|
+
|
|
7
|
+
const alteration: AlterationScript = {
|
|
8
|
+
up: async (pool) => {
|
|
9
|
+
await pool.query(sql`
|
|
10
|
+
create table verification_records (
|
|
11
|
+
tenant_id varchar(21) not null
|
|
12
|
+
references tenants (id) on update cascade on delete cascade,
|
|
13
|
+
id varchar(21) not null,
|
|
14
|
+
user_id varchar(21)
|
|
15
|
+
references users (id) on update cascade on delete cascade,
|
|
16
|
+
created_at timestamptz not null default(now()),
|
|
17
|
+
expires_at timestamptz not null,
|
|
18
|
+
data jsonb /* @use VerificationRecordData */ not null default '{}'::jsonb,
|
|
19
|
+
primary key (id)
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
create index verification_records__id
|
|
23
|
+
on verification_records (tenant_id, id);
|
|
24
|
+
`);
|
|
25
|
+
await applyTableRls(pool, 'verification_records');
|
|
26
|
+
},
|
|
27
|
+
down: async (pool) => {
|
|
28
|
+
await dropTableRls(pool, 'verification_records');
|
|
29
|
+
await pool.query(sql`
|
|
30
|
+
drop table verification_records;
|
|
31
|
+
`);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default alteration;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
const alteration = {
|
|
3
|
+
up: async (pool) => {
|
|
4
|
+
await pool.query(sql `
|
|
5
|
+
alter table organizations add column branding jsonb not null default '{}'::jsonb;
|
|
6
|
+
`);
|
|
7
|
+
},
|
|
8
|
+
down: async (pool) => {
|
|
9
|
+
await pool.query(sql `
|
|
10
|
+
alter table organizations drop column branding;
|
|
11
|
+
`);
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default alteration;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
const alteration = {
|
|
3
|
+
up: async (pool) => {
|
|
4
|
+
await pool.query(sql `
|
|
5
|
+
alter table application_sign_in_experiences add column color jsonb not null default '{}'::jsonb;
|
|
6
|
+
`);
|
|
7
|
+
},
|
|
8
|
+
down: async (pool) => {
|
|
9
|
+
await pool.query(sql `
|
|
10
|
+
alter table application_sign_in_experiences drop column color;
|
|
11
|
+
`);
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default alteration;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
const alteration = {
|
|
3
|
+
up: async (pool) => {
|
|
4
|
+
await pool.query(sql `
|
|
5
|
+
alter table sign_in_experiences drop column custom_ui_asset_id;
|
|
6
|
+
alter table sign_in_experiences add column custom_ui_assets jsonb;
|
|
7
|
+
`);
|
|
8
|
+
},
|
|
9
|
+
down: async (pool) => {
|
|
10
|
+
await pool.query(sql `
|
|
11
|
+
alter table sign_in_experiences add column custom_ui_asset_id varchar(21);
|
|
12
|
+
alter table sign_in_experiences drop column custom_ui_assets;
|
|
13
|
+
`);
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
export default alteration;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
|
|
3
|
+
const alteration = {
|
|
4
|
+
up: async (pool) => {
|
|
5
|
+
await pool.query(sql `
|
|
6
|
+
-- Remove existing constraint
|
|
7
|
+
alter table organization_application_relations drop constraint application_type;
|
|
8
|
+
|
|
9
|
+
-- Drop the function
|
|
10
|
+
drop function check_application_type;
|
|
11
|
+
|
|
12
|
+
-- Create a new function that accepts a variadic array of application types
|
|
13
|
+
create function check_application_type(
|
|
14
|
+
application_id varchar(21),
|
|
15
|
+
variadic target_type application_type[]
|
|
16
|
+
) returns boolean as
|
|
17
|
+
$$ begin
|
|
18
|
+
return (select type from applications where id = application_id) = any(target_type);
|
|
19
|
+
end; $$ language plpgsql set search_path = public;
|
|
20
|
+
|
|
21
|
+
-- Add back the constraint
|
|
22
|
+
alter table organization_application_relations
|
|
23
|
+
add constraint application_type
|
|
24
|
+
check (check_application_type(application_id, 'MachineToMachine'));
|
|
25
|
+
|
|
26
|
+
-- Create the new table
|
|
27
|
+
create table application_secrets (
|
|
28
|
+
tenant_id varchar(21) not null
|
|
29
|
+
references tenants (id) on update cascade on delete cascade,
|
|
30
|
+
application_id varchar(21) not null
|
|
31
|
+
references applications (id) on update cascade on delete cascade,
|
|
32
|
+
/** The name of the secret. Should be unique within the application. */
|
|
33
|
+
name varchar(256) not null,
|
|
34
|
+
value varchar(64) not null,
|
|
35
|
+
expires_at timestamptz,
|
|
36
|
+
created_at timestamptz not null default now(),
|
|
37
|
+
primary key (tenant_id, application_id, name),
|
|
38
|
+
constraint application_type
|
|
39
|
+
check (check_application_type(application_id, 'MachineToMachine', 'Traditional', 'Protected'))
|
|
40
|
+
);
|
|
41
|
+
`);
|
|
42
|
+
await applyTableRls(pool, 'application_secrets');
|
|
43
|
+
},
|
|
44
|
+
down: async (pool) => {
|
|
45
|
+
await dropTableRls(pool, 'application_secrets');
|
|
46
|
+
await pool.query(sql `
|
|
47
|
+
-- Remove the table
|
|
48
|
+
drop table application_secrets;
|
|
49
|
+
|
|
50
|
+
-- Remove the constraint
|
|
51
|
+
alter table organization_application_relations drop constraint application_type;
|
|
52
|
+
|
|
53
|
+
-- Drop the function
|
|
54
|
+
drop function check_application_type;
|
|
55
|
+
|
|
56
|
+
-- Restore the original function
|
|
57
|
+
create function check_application_type(
|
|
58
|
+
application_id varchar(21),
|
|
59
|
+
target_type application_type
|
|
60
|
+
) returns boolean as
|
|
61
|
+
$$ begin
|
|
62
|
+
return (select type from applications where id = application_id) = target_type;
|
|
63
|
+
end; $$ language plpgsql set search_path = public;
|
|
64
|
+
|
|
65
|
+
-- Add back the constraint
|
|
66
|
+
alter table organization_application_relations
|
|
67
|
+
add constraint application_type
|
|
68
|
+
check (check_application_type(application_id, 'MachineToMachine'));
|
|
69
|
+
`);
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
export default alteration;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
const alteration = {
|
|
3
|
+
up: async (pool) => {
|
|
4
|
+
await pool.query(sql `
|
|
5
|
+
alter table applications add column custom_data jsonb not null default '{}'::jsonb;
|
|
6
|
+
`);
|
|
7
|
+
},
|
|
8
|
+
down: async (pool) => {
|
|
9
|
+
await pool.query(sql `
|
|
10
|
+
alter table applications drop column custom_data;
|
|
11
|
+
`);
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default alteration;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
const alteration = {
|
|
3
|
+
up: async (pool) => {
|
|
4
|
+
await pool.query(sql `
|
|
5
|
+
alter type users_password_encryption_method add value 'Argon2id';
|
|
6
|
+
alter type users_password_encryption_method add value 'Argon2d';
|
|
7
|
+
`);
|
|
8
|
+
},
|
|
9
|
+
down: async (pool) => {
|
|
10
|
+
const { rows } = await pool.query(sql `
|
|
11
|
+
select id from users
|
|
12
|
+
where password_encryption_method = ${'Argon2id'}
|
|
13
|
+
or password_encryption_method = ${'Argon2d'}
|
|
14
|
+
`);
|
|
15
|
+
if (rows.length > 0) {
|
|
16
|
+
throw new Error('There are users with password encryption methods Argon2id or Argon2d.');
|
|
17
|
+
}
|
|
18
|
+
await pool.query(sql `
|
|
19
|
+
create type users_password_encryption_method_revised as enum ('Argon2i', 'SHA1', 'SHA256', 'MD5', 'Bcrypt');
|
|
20
|
+
|
|
21
|
+
alter table users
|
|
22
|
+
alter column password_encryption_method type users_password_encryption_method_revised
|
|
23
|
+
using password_encryption_method::text::users_password_encryption_method_revised;
|
|
24
|
+
|
|
25
|
+
drop type users_password_encryption_method;
|
|
26
|
+
alter type users_password_encryption_method_revised rename to users_password_encryption_method;
|
|
27
|
+
`);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export default alteration;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
|
|
3
|
+
const alteration = {
|
|
4
|
+
up: async (pool) => {
|
|
5
|
+
await pool.query(sql `
|
|
6
|
+
create table personal_access_tokens (
|
|
7
|
+
tenant_id varchar(21) not null
|
|
8
|
+
references tenants (id) on update cascade on delete cascade,
|
|
9
|
+
user_id varchar(21) not null
|
|
10
|
+
references users (id) on update cascade on delete cascade,
|
|
11
|
+
/** The name of the secret. Should be unique within the user. */
|
|
12
|
+
name varchar(256) not null,
|
|
13
|
+
value varchar(64) not null,
|
|
14
|
+
created_at timestamptz not null default now(),
|
|
15
|
+
expires_at timestamptz,
|
|
16
|
+
primary key (tenant_id, user_id, name)
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
create index personal_access_token__value on personal_access_tokens (tenant_id, value);
|
|
20
|
+
`);
|
|
21
|
+
await applyTableRls(pool, 'personal_access_tokens');
|
|
22
|
+
},
|
|
23
|
+
down: async (pool) => {
|
|
24
|
+
await dropTableRls(pool, 'personal_access_tokens');
|
|
25
|
+
await pool.query(sql `
|
|
26
|
+
drop table personal_access_tokens;
|
|
27
|
+
`);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export default alteration;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
import { generateStandardId } from './utils/1716643968-id-generation.js';
|
|
3
|
+
const cloudApiIndicator = 'https://cloud.logto.io/api';
|
|
4
|
+
const cloudConnectionAppRoleName = 'tenantApplication';
|
|
5
|
+
const adminTenantId = 'admin';
|
|
6
|
+
const reportSubscriptionUpdatesScopeName = 'report:subscription:updates';
|
|
7
|
+
const reportSubscriptionUpdatesScopeDescription = 'Allow reporting changes on Stripe subscription to Logto Cloud.';
|
|
8
|
+
const alteration = {
|
|
9
|
+
up: async (pool) => {
|
|
10
|
+
// Get the Cloud API resource
|
|
11
|
+
const cloudApiResource = await pool.maybeOne(sql `
|
|
12
|
+
select * from resources
|
|
13
|
+
where tenant_id = ${adminTenantId}
|
|
14
|
+
and indicator = ${cloudApiIndicator}
|
|
15
|
+
`);
|
|
16
|
+
if (!cloudApiResource) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// Get cloud connection application role
|
|
20
|
+
const tenantApplicationRole = await pool.one(sql `
|
|
21
|
+
select * from roles
|
|
22
|
+
where tenant_id = ${adminTenantId}
|
|
23
|
+
and name = ${cloudConnectionAppRoleName} and type = 'MachineToMachine'
|
|
24
|
+
`);
|
|
25
|
+
// Create the `report:subscription:updates` scope
|
|
26
|
+
const reportSubscriptionUpdatesCloudScope = await pool.one(sql `
|
|
27
|
+
insert into scopes (id, tenant_id, resource_id, name, description)
|
|
28
|
+
values (${generateStandardId()}, ${adminTenantId}, ${cloudApiResource.id}, ${reportSubscriptionUpdatesScopeName}, ${reportSubscriptionUpdatesScopeDescription})
|
|
29
|
+
on conflict (tenant_id, name, resource_id) do nothing
|
|
30
|
+
returning *;
|
|
31
|
+
`);
|
|
32
|
+
// Assign the `report:subscription:updates` scope to cloud connection application role
|
|
33
|
+
await pool.query(sql `
|
|
34
|
+
insert into roles_scopes (id, tenant_id, role_id, scope_id)
|
|
35
|
+
values (${generateStandardId()}, ${adminTenantId}, ${tenantApplicationRole.id}, ${reportSubscriptionUpdatesCloudScope.id}) on conflict (tenant_id, role_id, scope_id) do nothing;
|
|
36
|
+
`);
|
|
37
|
+
},
|
|
38
|
+
down: async (pool) => {
|
|
39
|
+
// Get the Cloud API resource
|
|
40
|
+
const cloudApiResource = await pool.maybeOne(sql `
|
|
41
|
+
select * from resources
|
|
42
|
+
where tenant_id = ${adminTenantId}
|
|
43
|
+
and indicator = ${cloudApiIndicator}
|
|
44
|
+
`);
|
|
45
|
+
if (!cloudApiResource) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// Remove the `report:subscription:updates` scope
|
|
49
|
+
await pool.query(sql `
|
|
50
|
+
delete from scopes
|
|
51
|
+
where
|
|
52
|
+
tenant_id = ${adminTenantId} and
|
|
53
|
+
name = ${reportSubscriptionUpdatesScopeName} and
|
|
54
|
+
description = ${reportSubscriptionUpdatesScopeDescription} and
|
|
55
|
+
resource_id = ${cloudApiResource.id}
|
|
56
|
+
`);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
export default alteration;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
const alteration = {
|
|
3
|
+
up: async (pool) => {
|
|
4
|
+
await pool.query(sql `
|
|
5
|
+
alter table verification_statuses add column verified_identifier varchar(255);
|
|
6
|
+
`);
|
|
7
|
+
},
|
|
8
|
+
down: async (pool) => {
|
|
9
|
+
await pool.query(sql `
|
|
10
|
+
alter table verification_statuses drop column verified_identifier;
|
|
11
|
+
`);
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default alteration;
|