@contember/engine-tenant-api 1.2.1 → 1.3.0-alpha.2
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/dist/src/TenantContainer.d.ts +1 -1
- package/dist/src/TenantContainer.d.ts.map +1 -1
- package/dist/src/TenantContainer.js +2 -0
- package/dist/src/TenantContainer.js.map +1 -1
- package/dist/src/bin/runMigrations.d.ts +2 -0
- package/dist/src/bin/runMigrations.d.ts.map +1 -0
- package/dist/src/bin/runMigrations.js +28 -0
- package/dist/src/bin/runMigrations.js.map +1 -0
- package/dist/src/migrations/2018-08-02-174310-init.d.ts +3 -0
- package/dist/src/migrations/2018-08-02-174310-init.d.ts.map +1 -0
- package/dist/src/migrations/2018-08-02-174310-init.js +64 -0
- package/dist/src/migrations/2018-08-02-174310-init.js.map +1 -0
- package/dist/src/migrations/2018-09-03-140621-identity-project.d.ts +3 -0
- package/dist/src/migrations/2018-09-03-140621-identity-project.d.ts.map +1 -0
- package/dist/src/migrations/2018-09-03-140621-identity-project.js +33 -0
- package/dist/src/migrations/2018-09-03-140621-identity-project.js.map +1 -0
- package/dist/src/migrations/2018-10-26-165450-setup-api-key.d.ts +3 -0
- package/dist/src/migrations/2018-10-26-165450-setup-api-key.d.ts.map +1 -0
- package/dist/src/migrations/2018-10-26-165450-setup-api-key.js +27 -0
- package/dist/src/migrations/2018-10-26-165450-setup-api-key.js.map +1 -0
- package/dist/src/migrations/2018-10-26-175155-variables.d.ts +3 -0
- package/dist/src/migrations/2018-10-26-175155-variables.d.ts.map +1 -0
- package/dist/src/migrations/2018-10-26-175155-variables.js +23 -0
- package/dist/src/migrations/2018-10-26-175155-variables.js.map +1 -0
- package/dist/src/migrations/2019-02-18-110949-project-slug.d.ts +3 -0
- package/dist/src/migrations/2019-02-18-110949-project-slug.d.ts.map +1 -0
- package/dist/src/migrations/2019-02-18-110949-project-slug.js +18 -0
- package/dist/src/migrations/2019-02-18-110949-project-slug.js.map +1 -0
- package/dist/src/migrations/2019-02-18-160155-session-expiration.d.ts +3 -0
- package/dist/src/migrations/2019-02-18-160155-session-expiration.d.ts.map +1 -0
- package/dist/src/migrations/2019-02-18-160155-session-expiration.js +11 -0
- package/dist/src/migrations/2019-02-18-160155-session-expiration.js.map +1 -0
- package/dist/src/migrations/2019-05-03-163729-api-key-disabled-at.d.ts +3 -0
- package/dist/src/migrations/2019-05-03-163729-api-key-disabled-at.d.ts.map +1 -0
- package/dist/src/migrations/2019-05-03-163729-api-key-disabled-at.js +18 -0
- package/dist/src/migrations/2019-05-03-163729-api-key-disabled-at.js.map +1 -0
- package/dist/src/migrations/2019-08-14-153300-project-slug-unique.d.ts +3 -0
- package/dist/src/migrations/2019-08-14-153300-project-slug-unique.d.ts.map +1 -0
- package/dist/src/migrations/2019-08-14-153300-project-slug-unique.js +11 -0
- package/dist/src/migrations/2019-08-14-153300-project-slug-unique.js.map +1 -0
- package/dist/src/migrations/2019-09-06-111000-membership.d.ts +3 -0
- package/dist/src/migrations/2019-09-06-111000-membership.d.ts.map +1 -0
- package/dist/src/migrations/2019-09-06-111000-membership.js +51 -0
- package/dist/src/migrations/2019-09-06-111000-membership.js.map +1 -0
- package/dist/src/migrations/2019-09-06-111001-drop-old-member.d.ts +3 -0
- package/dist/src/migrations/2019-09-06-111001-drop-old-member.d.ts.map +1 -0
- package/dist/src/migrations/2019-09-06-111001-drop-old-member.js +11 -0
- package/dist/src/migrations/2019-09-06-111001-drop-old-member.js.map +1 -0
- package/dist/src/migrations/2020-01-29-idenity-note.d.ts +3 -0
- package/dist/src/migrations/2020-01-29-idenity-note.d.ts.map +1 -0
- package/dist/src/migrations/2020-01-29-idenity-note.js +18 -0
- package/dist/src/migrations/2020-01-29-idenity-note.js.map +1 -0
- package/dist/src/migrations/2020-04-17-fix-person-index.d.ts +3 -0
- package/dist/src/migrations/2020-04-17-fix-person-index.d.ts.map +1 -0
- package/dist/src/migrations/2020-04-17-fix-person-index.js +12 -0
- package/dist/src/migrations/2020-04-17-fix-person-index.js.map +1 -0
- package/dist/src/migrations/2020-05-01-170000-api-key-index.d.ts +3 -0
- package/dist/src/migrations/2020-05-01-170000-api-key-index.d.ts.map +1 -0
- package/dist/src/migrations/2020-05-01-170000-api-key-index.js +10 -0
- package/dist/src/migrations/2020-05-01-170000-api-key-index.js.map +1 -0
- package/dist/src/migrations/2020-06-08-134000-tenant-credentials.d.ts.map +1 -1
- package/dist/src/migrations/2020-06-08-134000-tenant-credentials.js +2 -50
- package/dist/src/migrations/2020-06-08-134000-tenant-credentials.js.map +1 -1
- package/dist/src/migrations/2020-08-07-110000-person-otp.d.ts +3 -0
- package/dist/src/migrations/2020-08-07-110000-person-otp.d.ts.map +1 -0
- package/dist/src/migrations/2020-08-07-110000-person-otp.js +12 -0
- package/dist/src/migrations/2020-08-07-110000-person-otp.js.map +1 -0
- package/dist/src/migrations/2020-08-17-162200-mail-templates.d.ts +3 -0
- package/dist/src/migrations/2020-08-17-162200-mail-templates.d.ts.map +1 -0
- package/dist/src/migrations/2020-08-17-162200-mail-templates.js +23 -0
- package/dist/src/migrations/2020-08-17-162200-mail-templates.js.map +1 -0
- package/dist/src/migrations/2020-08-21-143400-person-password-reset.d.ts +3 -0
- package/dist/src/migrations/2020-08-21-143400-person-password-reset.d.ts.map +1 -0
- package/dist/src/migrations/2020-08-21-143400-person-password-reset.js +23 -0
- package/dist/src/migrations/2020-08-21-143400-person-password-reset.js.map +1 -0
- package/dist/src/migrations/2020-09-07-094200-identity-provider.d.ts +3 -0
- package/dist/src/migrations/2020-09-07-094200-identity-provider.d.ts.map +1 -0
- package/dist/src/migrations/2020-09-07-094200-identity-provider.js +17 -0
- package/dist/src/migrations/2020-09-07-094200-identity-provider.js.map +1 -0
- package/dist/src/migrations/2021-03-28-134000-timestamp.d.ts +3 -0
- package/dist/src/migrations/2021-03-28-134000-timestamp.d.ts.map +1 -0
- package/dist/src/migrations/2021-03-28-134000-timestamp.js +27 -0
- package/dist/src/migrations/2021-03-28-134000-timestamp.js.map +1 -0
- package/dist/src/migrations/2021-07-26-105000-project-config.d.ts +3 -0
- package/dist/src/migrations/2021-07-26-105000-project-config.d.ts.map +1 -0
- package/dist/src/migrations/2021-07-26-105000-project-config.js +12 -0
- package/dist/src/migrations/2021-07-26-105000-project-config.js.map +1 -0
- package/dist/src/migrations/2021-07-26-132000-project-secrets.d.ts +3 -0
- package/dist/src/migrations/2021-07-26-132000-project-secrets.d.ts.map +1 -0
- package/dist/src/migrations/2021-07-26-132000-project-secrets.js +24 -0
- package/dist/src/migrations/2021-07-26-132000-project-secrets.js.map +1 -0
- package/dist/src/migrations/2021-07-27-174000-project-alias-index.d.ts +3 -0
- package/dist/src/migrations/2021-07-27-174000-project-alias-index.d.ts.map +1 -0
- package/dist/src/migrations/2021-07-27-174000-project-alias-index.js +10 -0
- package/dist/src/migrations/2021-07-27-174000-project-alias-index.js.map +1 -0
- package/dist/src/migrations/2021-11-24-130000-person-password-null.d.ts +3 -0
- package/dist/src/migrations/2021-11-24-130000-person-password-null.d.ts.map +1 -0
- package/dist/src/migrations/2021-11-24-130000-person-password-null.js +10 -0
- package/dist/src/migrations/2021-11-24-130000-person-password-null.js.map +1 -0
- package/dist/src/migrations/2021-11-24-161500-mail-template-project-null.d.ts +3 -0
- package/dist/src/migrations/2021-11-24-161500-mail-template-project-null.d.ts.map +1 -0
- package/dist/src/migrations/2021-11-24-161500-mail-template-project-null.js +18 -0
- package/dist/src/migrations/2021-11-24-161500-mail-template-project-null.js.map +1 -0
- package/dist/src/migrations/2022-01-04-144000-person-unique-identity.d.ts +3 -0
- package/dist/src/migrations/2022-01-04-144000-person-unique-identity.d.ts.map +1 -0
- package/dist/src/migrations/2022-01-04-144000-person-unique-identity.js +11 -0
- package/dist/src/migrations/2022-01-04-144000-person-unique-identity.js.map +1 -0
- package/dist/src/migrations/2022-02-09-111800-fix-crypted.d.ts +3 -0
- package/dist/src/migrations/2022-02-09-111800-fix-crypted.d.ts.map +1 -0
- package/dist/src/migrations/2022-02-09-111800-fix-crypted.js +22 -0
- package/dist/src/migrations/2022-02-09-111800-fix-crypted.js.map +1 -0
- package/dist/src/migrations/2022-02-11-153000-idp-auto-sign-up.d.ts +3 -0
- package/dist/src/migrations/2022-02-11-153000-idp-auto-sign-up.d.ts.map +1 -0
- package/dist/src/migrations/2022-02-11-153000-idp-auto-sign-up.js +11 -0
- package/dist/src/migrations/2022-02-11-153000-idp-auto-sign-up.js.map +1 -0
- package/dist/src/migrations/2022-06-29-105000-person-idp.d.ts +3 -0
- package/dist/src/migrations/2022-06-29-105000-person-idp.d.ts.map +1 -0
- package/dist/src/migrations/2022-06-29-105000-person-idp.js +23 -0
- package/dist/src/migrations/2022-06-29-105000-person-idp.js.map +1 -0
- package/dist/src/migrations/2022-07-07-135000-person-email-opt-uniq.d.ts +3 -0
- package/dist/src/migrations/2022-07-07-135000-person-email-opt-uniq.d.ts.map +1 -0
- package/dist/src/migrations/2022-07-07-135000-person-email-opt-uniq.js +12 -0
- package/dist/src/migrations/2022-07-07-135000-person-email-opt-uniq.js.map +1 -0
- package/dist/src/migrations/2022-07-07-141000-person-display-name.d.ts +3 -0
- package/dist/src/migrations/2022-07-07-141000-person-display-name.d.ts.map +1 -0
- package/dist/src/migrations/2022-07-07-141000-person-display-name.js +13 -0
- package/dist/src/migrations/2022-07-07-141000-person-display-name.js.map +1 -0
- package/dist/src/migrations/2022-07-14-145000-person-login-options.d.ts +3 -0
- package/dist/src/migrations/2022-07-14-145000-person-login-options.d.ts.map +1 -0
- package/dist/src/migrations/2022-07-14-145000-person-login-options.js +15 -0
- package/dist/src/migrations/2022-07-14-145000-person-login-options.js.map +1 -0
- package/dist/src/migrations/2022-11-08-project-update-notification.d.ts +3 -0
- package/dist/src/migrations/2022-11-08-project-update-notification.d.ts.map +1 -0
- package/dist/src/migrations/2022-11-08-project-update-notification.js +64 -0
- package/dist/src/migrations/2022-11-08-project-update-notification.js.map +1 -0
- package/dist/src/migrations/runner.d.ts +1 -1
- package/dist/src/migrations/runner.d.ts.map +1 -1
- package/dist/src/migrations/runner.js +68 -5
- package/dist/src/migrations/runner.js.map +1 -1
- package/dist/src/migrations/snapshot-factory.d.ts +5 -0
- package/dist/src/migrations/snapshot-factory.d.ts.map +1 -0
- package/dist/src/migrations/snapshot-factory.js +18 -0
- package/dist/src/migrations/snapshot-factory.js.map +1 -0
- package/dist/src/migrations/snapshot.d.ts +4 -0
- package/dist/src/migrations/snapshot.d.ts.map +1 -0
- package/dist/src/migrations/snapshot.js +202 -0
- package/dist/src/migrations/snapshot.js.map +1 -0
- package/dist/src/migrations/tenantCredentials.d.ts +4 -0
- package/dist/src/migrations/tenantCredentials.d.ts.map +1 -0
- package/dist/src/migrations/tenantCredentials.js +57 -0
- package/dist/src/migrations/tenantCredentials.js.map +1 -0
- package/dist/src/migrations/types.d.ts +2 -0
- package/dist/src/migrations/types.d.ts.map +1 -1
- package/dist/src/model/commands/idp/UpdateIdpCommand.d.ts +1 -0
- package/dist/src/model/commands/idp/UpdateIdpCommand.d.ts.map +1 -1
- package/dist/src/model/queries/membership/ProjectMembersQuery.d.ts +3 -3
- package/dist/src/model/queries/membership/ProjectMembersQuery.d.ts.map +1 -1
- package/dist/src/model/queries/membership/ProjectMembersQuery.js +22 -10
- package/dist/src/model/queries/membership/ProjectMembersQuery.js.map +1 -1
- package/dist/src/model/service/IDPSignInManager.d.ts +3 -3
- package/dist/src/model/service/IDPSignInManager.d.ts.map +1 -1
- package/dist/src/model/service/IDPSignInManager.js +13 -5
- package/dist/src/model/service/IDPSignInManager.js.map +1 -1
- package/dist/src/model/service/ProjectMemberManager.d.ts +2 -2
- package/dist/src/model/service/ProjectMemberManager.d.ts.map +1 -1
- package/dist/src/model/service/ProjectMemberManager.js +2 -2
- package/dist/src/model/service/ProjectMemberManager.js.map +1 -1
- package/dist/src/model/service/idp/IDPHandlerRegistry.d.ts +2 -2
- package/dist/src/model/service/idp/IDPHandlerRegistry.d.ts.map +1 -1
- package/dist/src/model/service/idp/IDPHandlerRegistry.js.map +1 -1
- package/dist/src/model/service/idp/IDPManager.d.ts.map +1 -1
- package/dist/src/model/service/idp/IDPManager.js +7 -2
- package/dist/src/model/service/idp/IDPManager.js.map +1 -1
- package/dist/src/model/service/idp/IdentityProviderHandler.d.ts +6 -9
- package/dist/src/model/service/idp/IdentityProviderHandler.d.ts.map +1 -1
- package/dist/src/model/service/idp/index.d.ts +3 -1
- package/dist/src/model/service/idp/index.d.ts.map +1 -1
- package/dist/src/model/service/idp/index.js +3 -1
- package/dist/src/model/service/idp/index.js.map +1 -1
- package/dist/src/model/service/idp/providers/AppleProvider.d.ts +29 -0
- package/dist/src/model/service/idp/providers/AppleProvider.d.ts.map +1 -0
- package/dist/src/model/service/idp/providers/AppleProvider.js +79 -0
- package/dist/src/model/service/idp/providers/AppleProvider.js.map +1 -0
- package/dist/src/model/service/idp/providers/FacebookProvider.d.ts +27 -0
- package/dist/src/model/service/idp/providers/FacebookProvider.d.ts.map +1 -0
- package/dist/src/model/service/idp/providers/FacebookProvider.js +137 -0
- package/dist/src/model/service/idp/providers/FacebookProvider.js.map +1 -0
- package/dist/src/model/service/idp/providers/OIDCHelpers.d.ts +10 -0
- package/dist/src/model/service/idp/providers/OIDCHelpers.d.ts.map +1 -0
- package/dist/src/model/service/idp/providers/OIDCHelpers.js +56 -0
- package/dist/src/model/service/idp/providers/OIDCHelpers.js.map +1 -0
- package/dist/src/model/service/idp/providers/OIDCProvider.d.ts +19 -0
- package/dist/src/model/service/idp/providers/OIDCProvider.d.ts.map +1 -0
- package/dist/src/model/service/idp/providers/OIDCProvider.js +40 -0
- package/dist/src/model/service/idp/providers/OIDCProvider.js.map +1 -0
- package/dist/src/model/service/idp/providers/OIDCTypes.d.ts +62 -0
- package/dist/src/model/service/idp/providers/OIDCTypes.d.ts.map +1 -0
- package/dist/src/model/service/idp/providers/OIDCTypes.js +56 -0
- package/dist/src/model/service/idp/providers/OIDCTypes.js.map +1 -0
- package/dist/src/model/service/idp/providers/helpers.d.ts +3 -0
- package/dist/src/model/service/idp/providers/helpers.d.ts.map +1 -0
- package/dist/src/model/service/idp/providers/helpers.js +40 -0
- package/dist/src/model/service/idp/providers/helpers.js.map +1 -0
- package/dist/src/model/utils/DatabaseContext.d.ts +1 -0
- package/dist/src/model/utils/DatabaseContext.d.ts.map +1 -1
- package/dist/src/model/utils/DatabaseContext.js +5 -0
- package/dist/src/model/utils/DatabaseContext.js.map +1 -1
- package/dist/src/resolvers/mutation/idp/UpdateIDPMutationResolver.d.ts.map +1 -1
- package/dist/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js +4 -3
- package/dist/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/person/IDPMutationResolver.d.ts.map +1 -1
- package/dist/src/resolvers/mutation/person/IDPMutationResolver.js +10 -3
- package/dist/src/resolvers/mutation/person/IDPMutationResolver.js.map +1 -1
- package/dist/src/resolvers/types/ProjectTypeResolver.d.ts.map +1 -1
- package/dist/src/resolvers/types/ProjectTypeResolver.js +14 -6
- package/dist/src/resolvers/types/ProjectTypeResolver.js.map +1 -1
- package/dist/src/schema/index.d.ts +26 -8
- package/dist/src/schema/index.d.ts.map +1 -1
- package/dist/src/schema/index.js +1 -0
- package/dist/src/schema/index.js.map +1 -1
- package/dist/src/schema/tenant.graphql.d.ts.map +1 -1
- package/dist/src/schema/tenant.graphql.js +32 -6
- package/dist/src/schema/tenant.graphql.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/cases/integration/db/invite.test.js +2 -2
- package/dist/tests/cases/integration/db/unmanagedInvite.test.js +2 -2
- package/dist/{src → tests/cases}/migrations/2020-06-08-134000-tenant-credentials.test.d.ts +1 -1
- package/dist/tests/cases/migrations/2020-06-08-134000-tenant-credentials.test.d.ts.map +1 -0
- package/dist/{src → tests/cases}/migrations/2020-06-08-134000-tenant-credentials.test.js +19 -9
- package/dist/tests/cases/migrations/2020-06-08-134000-tenant-credentials.test.js.map +1 -0
- package/dist/tests/src/IdPMock.d.ts +4 -4
- package/dist/tests/src/IdPMock.d.ts.map +1 -1
- package/dist/tests/src/IdPMock.js +2 -2
- package/dist/tests/src/IdPMock.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -13
- package/src/TenantContainer.ts +4 -2
- package/src/bin/runMigrations.ts +32 -0
- package/src/migrations/{2018-08-02-174310-init.sql → 2018-08-02-174310-init.ts} +8 -1
- package/src/migrations/{2018-09-03-140621-identity-project.sql → 2018-09-03-140621-identity-project.ts} +8 -0
- package/src/migrations/{2018-10-26-165450-setup-api-key.sql → 2018-10-26-165450-setup-api-key.ts} +8 -0
- package/src/migrations/{2018-10-26-175155-variables.sql → 2018-10-26-175155-variables.ts} +7 -0
- package/src/migrations/{2019-02-18-110949-project-slug.sql → 2019-02-18-110949-project-slug.ts} +8 -0
- package/src/migrations/2019-02-18-160155-session-expiration.ts +10 -0
- package/src/migrations/{2019-05-03-163729-api-key-disabled-at.sql → 2019-05-03-163729-api-key-disabled-at.ts} +8 -0
- package/src/migrations/2019-08-14-153300-project-slug-unique.ts +10 -0
- package/src/migrations/{2019-09-06-111000-membership.sql → 2019-09-06-111000-membership.ts} +8 -0
- package/src/migrations/2019-09-06-111001-drop-old-member.ts +10 -0
- package/src/migrations/2020-01-29-idenity-note.ts +18 -0
- package/src/migrations/2020-04-17-fix-person-index.ts +12 -0
- package/src/migrations/2020-05-01-170000-api-key-index.ts +10 -0
- package/src/migrations/2020-06-08-134000-tenant-credentials.ts +3 -54
- package/src/migrations/2020-08-07-110000-person-otp.ts +12 -0
- package/src/migrations/{2020-08-17-162200-mail-templates.sql → 2020-08-17-162200-mail-templates.ts} +8 -0
- package/src/migrations/{2020-08-21-143400-person-password-reset.sql → 2020-08-21-143400-person-password-reset.ts} +8 -0
- package/src/migrations/{2020-09-07-094200-identity-provider.sql → 2020-09-07-094200-identity-provider.ts} +8 -0
- package/src/migrations/{2021-03-28-134000-timestamp.sql → 2021-03-28-134000-timestamp.ts} +9 -0
- package/src/migrations/2021-07-26-105000-project-config.ts +12 -0
- package/src/migrations/{2021-07-26-132000-project-secrets.sql → 2021-07-26-132000-project-secrets.ts} +8 -0
- package/src/migrations/2021-07-27-174000-project-alias-index.ts +10 -0
- package/src/migrations/2021-11-24-130000-person-password-null.ts +10 -0
- package/src/migrations/{2021-11-24-161500-mail-template-project-null.sql → 2021-11-24-161500-mail-template-project-null.ts} +8 -0
- package/src/migrations/2022-01-04-144000-person-unique-identity.ts +10 -0
- package/src/migrations/{2022-02-09-111800-fix-crypted.sql → 2022-02-09-111800-fix-crypted.ts} +8 -0
- package/src/migrations/2022-02-11-153000-idp-auto-sign-up.ts +10 -0
- package/src/migrations/{2022-06-29-105000-person-idp.sql → 2022-06-29-105000-person-idp.ts} +8 -0
- package/src/migrations/2022-07-07-135000-person-email-opt-uniq.ts +11 -0
- package/src/migrations/2022-07-07-141000-person-display-name.ts +13 -0
- package/src/migrations/{2022-07-14-145000-person-login-options.sql → 2022-07-14-145000-person-login-options.ts} +9 -0
- package/src/migrations/2022-11-08-project-update-notification.ts +64 -0
- package/src/migrations/runner.ts +72 -8
- package/src/migrations/snapshot-factory.ts +21 -0
- package/src/migrations/snapshot-template-end.txt +10 -0
- package/src/migrations/snapshot-template-start.txt +6 -0
- package/src/migrations/snapshot.ts +202 -0
- package/src/migrations/tenantCredentials.ts +58 -0
- package/src/migrations/types.ts +3 -0
- package/src/model/commands/idp/UpdateIdpCommand.ts +1 -0
- package/src/model/queries/membership/ProjectMembersQuery.ts +23 -14
- package/src/model/service/IDPSignInManager.ts +13 -10
- package/src/model/service/ProjectMemberManager.ts +3 -3
- package/src/model/service/idp/IDPHandlerRegistry.ts +3 -3
- package/src/model/service/idp/IDPManager.ts +6 -2
- package/src/model/service/idp/IdentityProviderHandler.ts +7 -15
- package/src/model/service/idp/index.ts +3 -1
- package/src/model/service/idp/providers/AppleProvider.ts +65 -0
- package/src/model/service/idp/providers/FacebookProvider.ts +125 -0
- package/src/model/service/idp/providers/OIDCHelpers.ts +54 -0
- package/src/model/service/idp/providers/OIDCProvider.ts +40 -0
- package/src/model/service/idp/providers/OIDCTypes.ts +61 -0
- package/src/model/service/idp/providers/helpers.ts +12 -0
- package/src/model/utils/DatabaseContext.ts +6 -0
- package/src/resolvers/mutation/idp/UpdateIDPMutationResolver.ts +1 -0
- package/src/resolvers/mutation/person/IDPMutationResolver.ts +9 -7
- package/src/resolvers/types/ProjectTypeResolver.ts +9 -2
- package/src/schema/index.ts +28 -8
- package/src/schema/tenant.graphql.ts +32 -6
- package/src/tsconfig.json +10 -30
- package/tests/cases/integration/db/invite.test.ts +2 -2
- package/tests/cases/integration/db/unmanagedInvite.test.ts +2 -2
- package/{src → tests/cases}/migrations/2020-06-08-134000-tenant-credentials.test.ts +17 -9
- package/tests/src/IdPMock.ts +4 -4
- package/tests/tsconfig.json +2 -6
- package/tsconfig.json +2 -6
- package/dist/src/migrations/2020-06-08-134000-tenant-credentials.test.d.ts.map +0 -1
- package/dist/src/migrations/2020-06-08-134000-tenant-credentials.test.js.map +0 -1
- package/dist/src/model/service/idp/OIDCProvider.d.ts +0 -25
- package/dist/src/model/service/idp/OIDCProvider.d.ts.map +0 -1
- package/dist/src/model/service/idp/OIDCProvider.js +0 -108
- package/dist/src/model/service/idp/OIDCProvider.js.map +0 -1
- package/src/migrations/2019-02-18-160155-session-expiration.sql +0 -2
- package/src/migrations/2019-08-14-153300-project-slug-unique.sql +0 -2
- package/src/migrations/2019-09-06-111001-drop-old-member.sql +0 -2
- package/src/migrations/2020-01-29-idenity-note.sql +0 -9
- package/src/migrations/2020-04-17-fix-person-index.sql +0 -3
- package/src/migrations/2020-05-01-170000-api-key-index.sql +0 -1
- package/src/migrations/2020-08-07-110000-person-otp.sql +0 -3
- package/src/migrations/2021-07-26-105000-project-config.sql +0 -3
- package/src/migrations/2021-07-27-174000-project-alias-index.sql +0 -1
- package/src/migrations/2021-11-24-130000-person-password-null.sql +0 -1
- package/src/migrations/2022-01-04-144000-person-unique-identity.sql +0 -2
- package/src/migrations/2022-02-11-153000-idp-auto-sign-up.sql +0 -2
- package/src/migrations/2022-07-07-135000-person-email-opt-uniq.sql +0 -3
- package/src/migrations/2022-07-07-141000-person-display-name.sql +0 -4
- package/src/model/service/idp/OIDCProvider.ts +0 -100
|
@@ -75,8 +75,12 @@ export class IDPManager {
|
|
|
75
75
|
return new ResponseError(UpdateIdpErrorCode.NotFound, `IDP ${slug} not found`)
|
|
76
76
|
}
|
|
77
77
|
try {
|
|
78
|
-
const
|
|
79
|
-
|
|
78
|
+
const type = data.type ?? existing.type
|
|
79
|
+
const configuration = data.configuration ?? existing.configuration
|
|
80
|
+
const providerService = this.idpRegistry.getHandler(type)
|
|
81
|
+
if (data.configuration !== undefined || type !== existing.type) {
|
|
82
|
+
providerService.validateConfiguration(configuration)
|
|
83
|
+
}
|
|
80
84
|
} catch (e) {
|
|
81
85
|
if (e instanceof InvalidIDPConfigurationError) {
|
|
82
86
|
return new ResponseError(UpdateIdpErrorCode.InvalidConfiguration, `Invalid IDP configuration: ${e.message}`)
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
export interface InitIDPAuthResult
|
|
1
|
+
export interface InitIDPAuthResult {
|
|
2
2
|
authUrl: string
|
|
3
|
-
sessionData:
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface IDPResponse {
|
|
7
|
-
url: string
|
|
3
|
+
sessionData: unknown
|
|
8
4
|
}
|
|
9
5
|
|
|
10
6
|
export interface IDPClaim {
|
|
@@ -13,15 +9,11 @@ export interface IDPClaim {
|
|
|
13
9
|
name?: string
|
|
14
10
|
}
|
|
15
11
|
|
|
16
|
-
export interface IdentityProviderHandler<
|
|
17
|
-
|
|
12
|
+
export interface IdentityProviderHandler<Configuration extends {}> {
|
|
13
|
+
|
|
14
|
+
initAuth: (configuration: Configuration, data: unknown) => Promise<InitIDPAuthResult>
|
|
18
15
|
|
|
19
|
-
processResponse(
|
|
20
|
-
configuration: Configuration,
|
|
21
|
-
redirectUrl: string,
|
|
22
|
-
idpResponse: IDPResponse,
|
|
23
|
-
sessionData: SessionData,
|
|
24
|
-
): Promise<IDPClaim>
|
|
16
|
+
processResponse: (configuration: Configuration, responseData: unknown) => Promise<IDPClaim>
|
|
25
17
|
|
|
26
|
-
validateConfiguration(config: unknown)
|
|
18
|
+
validateConfiguration: (config: unknown) => Configuration
|
|
27
19
|
}
|
|
@@ -4,4 +4,6 @@ export * from './IDPHandlerRegistry'
|
|
|
4
4
|
export * from './IDPResponseError'
|
|
5
5
|
export * from './IDPValidationError'
|
|
6
6
|
export * from './InvalidIDPConfigurationError'
|
|
7
|
-
export * from './
|
|
7
|
+
export * from './providers/AppleProvider'
|
|
8
|
+
export * from './providers/OIDCProvider'
|
|
9
|
+
export * from './providers/FacebookProvider'
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as Typesafe from '@contember/typesafe'
|
|
2
|
+
import { IdentityProviderHandler, IDPClaim, InitIDPAuthResult } from '../IdentityProviderHandler'
|
|
3
|
+
import { OIDCConfigurationOptions, OIDCInitData, OIDCResponseData, OIDCSessionData } from './OIDCTypes'
|
|
4
|
+
import { catchTypesafe } from './helpers'
|
|
5
|
+
import { IDPValidationError } from '../IDPValidationError'
|
|
6
|
+
import { InvalidIDPConfigurationError } from '../InvalidIDPConfigurationError'
|
|
7
|
+
import { handleOIDCResponse, initOIDCAuth } from './OIDCHelpers'
|
|
8
|
+
import { Client, Issuer } from 'openid-client'
|
|
9
|
+
import { importPKCS8, SignJWT } from 'jose'
|
|
10
|
+
|
|
11
|
+
export const AppleConfiguration = Typesafe.intersection(
|
|
12
|
+
Typesafe.object({
|
|
13
|
+
keyId: Typesafe.string,
|
|
14
|
+
teamId: Typesafe.string,
|
|
15
|
+
clientId: Typesafe.string,
|
|
16
|
+
privateKey: Typesafe.string,
|
|
17
|
+
}),
|
|
18
|
+
OIDCConfigurationOptions,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
type AppleConfiguration = ReturnType<typeof AppleConfiguration>
|
|
22
|
+
|
|
23
|
+
const APPLE_OIDC_CONFIGURATION_ENDPOINT = 'https://appleid.apple.com/.well-known/openid-configuration'
|
|
24
|
+
|
|
25
|
+
export class AppleProvider implements IdentityProviderHandler<AppleConfiguration> {
|
|
26
|
+
private issuer: Issuer<Client> | undefined
|
|
27
|
+
|
|
28
|
+
validateConfiguration = catchTypesafe(AppleConfiguration, InvalidIDPConfigurationError)
|
|
29
|
+
|
|
30
|
+
public async initAuth(configuration: AppleConfiguration, data: unknown): Promise<InitIDPAuthResult> {
|
|
31
|
+
const initData = catchTypesafe(OIDCInitData, IDPValidationError)(data)
|
|
32
|
+
const client = await this.createOIDCClient(configuration)
|
|
33
|
+
return await initOIDCAuth(client, {
|
|
34
|
+
claims: configuration.claims,
|
|
35
|
+
...initData,
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public async processResponse(configuration: AppleConfiguration, data: unknown): Promise<IDPClaim> {
|
|
40
|
+
const responseData = catchTypesafe(OIDCResponseData, IDPValidationError)(data)
|
|
41
|
+
const client = await this.createOIDCClient(configuration)
|
|
42
|
+
return await handleOIDCResponse(client, responseData)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
private async createOIDCClient(configuration: AppleConfiguration): Promise<Client> {
|
|
47
|
+
this.issuer ??= await Issuer.discover(APPLE_OIDC_CONFIGURATION_ENDPOINT)
|
|
48
|
+
const privateKey = await importPKCS8(configuration.privateKey, 'ES256')
|
|
49
|
+
|
|
50
|
+
const jwt = await new SignJWT({})
|
|
51
|
+
.setProtectedHeader({ alg: 'ES256', typ: 'JWT', kid: configuration.keyId })
|
|
52
|
+
.setIssuedAt()
|
|
53
|
+
.setIssuer(configuration.teamId)
|
|
54
|
+
.setAudience('https://appleid.apple.com')
|
|
55
|
+
.setSubject(configuration.clientId)
|
|
56
|
+
.setExpirationTime('10m')
|
|
57
|
+
.sign(privateKey)
|
|
58
|
+
|
|
59
|
+
return new this.issuer.Client({
|
|
60
|
+
client_id: configuration.clientId,
|
|
61
|
+
client_secret: jwt,
|
|
62
|
+
response_types: [configuration.responseType || 'code'],
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as Typesafe from '@contember/typesafe'
|
|
2
|
+
import { Client, Issuer } from 'openid-client'
|
|
3
|
+
import { IdentityProviderHandler, IDPClaim, InitIDPAuthResult } from '../IdentityProviderHandler'
|
|
4
|
+
import { IDPValidationError } from '../IDPValidationError'
|
|
5
|
+
import { InvalidIDPConfigurationError } from '../InvalidIDPConfigurationError'
|
|
6
|
+
import { catchTypesafe } from './helpers'
|
|
7
|
+
import { BaseOIDCConfiguration, OIDCInitData, OIDCResponseData } from './OIDCTypes'
|
|
8
|
+
import { handleOIDCResponse, initOIDCAuth } from './OIDCHelpers'
|
|
9
|
+
import { createHmac } from 'node:crypto'
|
|
10
|
+
import { IDPResponseError } from '../IDPResponseError'
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const FacebookConfiguration = BaseOIDCConfiguration
|
|
15
|
+
type FacebookConfiguration = ReturnType<typeof FacebookConfiguration>
|
|
16
|
+
|
|
17
|
+
const FacebookResponseData = Typesafe.union(
|
|
18
|
+
OIDCResponseData,
|
|
19
|
+
Typesafe.object({
|
|
20
|
+
authResponse: Typesafe.object({
|
|
21
|
+
accessToken: Typesafe.string,
|
|
22
|
+
signedRequest: Typesafe.string,
|
|
23
|
+
}),
|
|
24
|
+
}),
|
|
25
|
+
)
|
|
26
|
+
const FacebookResponsePayload = Typesafe.object({
|
|
27
|
+
user_id: Typesafe.string,
|
|
28
|
+
code: Typesafe.string,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
type FacebookResponseData = ReturnType<typeof FacebookResponseData>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export class FacebookProvider implements IdentityProviderHandler<FacebookConfiguration> {
|
|
35
|
+
// based on https://www.facebook.com/.well-known/openid-configuration/
|
|
36
|
+
// facebook .well-known endpoint does have "token_endpoint" field
|
|
37
|
+
private facebookIssuer = new Issuer({
|
|
38
|
+
issuer: 'https://www.facebook.com',
|
|
39
|
+
authorization_endpoint: 'https://facebook.com/dialog/oauth/',
|
|
40
|
+
jwks_uri: 'https://www.facebook.com/.well-known/oauth/openid/jwks/',
|
|
41
|
+
response_types_supported: [
|
|
42
|
+
'id_token',
|
|
43
|
+
'token id_token',
|
|
44
|
+
],
|
|
45
|
+
subject_types_supported: [
|
|
46
|
+
'pairwise',
|
|
47
|
+
],
|
|
48
|
+
id_token_signing_alg_values_supported: [
|
|
49
|
+
'RS256',
|
|
50
|
+
],
|
|
51
|
+
claims_supported: [
|
|
52
|
+
'iss',
|
|
53
|
+
'aud',
|
|
54
|
+
'sub',
|
|
55
|
+
'iat',
|
|
56
|
+
'exp',
|
|
57
|
+
'jti',
|
|
58
|
+
'nonce',
|
|
59
|
+
'at_hash',
|
|
60
|
+
'name',
|
|
61
|
+
'given_name',
|
|
62
|
+
'middle_name',
|
|
63
|
+
'family_name',
|
|
64
|
+
'email',
|
|
65
|
+
'picture',
|
|
66
|
+
'user_friends',
|
|
67
|
+
'user_birthday',
|
|
68
|
+
'user_age_range',
|
|
69
|
+
'user_link',
|
|
70
|
+
'user_hometown',
|
|
71
|
+
'user_location',
|
|
72
|
+
'user_gender',
|
|
73
|
+
],
|
|
74
|
+
token_endpoint: 'https://graph.facebook.com/v11.0/oauth/access_token',
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
validateConfiguration = catchTypesafe(FacebookConfiguration, InvalidIDPConfigurationError)
|
|
78
|
+
|
|
79
|
+
public async initAuth(configuration: FacebookConfiguration, data: unknown): Promise<InitIDPAuthResult> {
|
|
80
|
+
const initData = catchTypesafe(OIDCInitData, IDPValidationError)(data)
|
|
81
|
+
const client = await this.createOIDCClient(configuration)
|
|
82
|
+
return await initOIDCAuth(client, {
|
|
83
|
+
claims: configuration.claims,
|
|
84
|
+
...initData,
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public async processResponse(configuration: FacebookConfiguration, data: unknown): Promise<IDPClaim> {
|
|
89
|
+
const responseData = catchTypesafe(FacebookResponseData, IDPValidationError)(data)
|
|
90
|
+
|
|
91
|
+
if (!('authResponse' in responseData)) {
|
|
92
|
+
const client = await this.createOIDCClient(configuration)
|
|
93
|
+
return await handleOIDCResponse(client, responseData)
|
|
94
|
+
} else {
|
|
95
|
+
const [sig, payload] = responseData.authResponse.signedRequest.split('.')
|
|
96
|
+
const data = catchTypesafe(FacebookResponsePayload, IDPValidationError)(JSON.parse(Buffer.from(payload, 'base64').toString('utf8')))
|
|
97
|
+
const hmac = createHmac('sha256', configuration.clientSecret)
|
|
98
|
+
const signature = hmac.update(payload).digest()
|
|
99
|
+
const isSignatureValid = signature.compare(Buffer.from(sig, 'base64')) === 0
|
|
100
|
+
if (!isSignatureValid) {
|
|
101
|
+
throw new IDPValidationError('Invalid signature')
|
|
102
|
+
}
|
|
103
|
+
const url = `https://graph.facebook.com/${data.user_id}?fields=id,email,name&access_token=${responseData.authResponse.accessToken}`
|
|
104
|
+
const response = await fetch(url)
|
|
105
|
+
if (!response.ok) {
|
|
106
|
+
throw new IDPResponseError(`Invalid Facebook response: [${response.status}] ${await response.text()}`)
|
|
107
|
+
}
|
|
108
|
+
const apiData = await response.json()
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
externalIdentifier: data.user_id,
|
|
112
|
+
name: apiData.name,
|
|
113
|
+
email: apiData.email,
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private async createOIDCClient(configuration: FacebookConfiguration): Promise<Client> {
|
|
119
|
+
return new this.facebookIssuer.Client({
|
|
120
|
+
client_id: configuration.clientId,
|
|
121
|
+
client_secret: configuration.clientSecret,
|
|
122
|
+
response_types: [configuration.responseType || 'code'],
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Client, custom, errors, generators } from 'openid-client'
|
|
2
|
+
import { OIDCResponseData } from './OIDCTypes'
|
|
3
|
+
import { IDPValidationError } from '../IDPValidationError'
|
|
4
|
+
import { IDPResponseError } from '../IDPResponseError'
|
|
5
|
+
import { IDPClaim, InitIDPAuthResult } from '../IdentityProviderHandler'
|
|
6
|
+
|
|
7
|
+
custom.setHttpOptionsDefaults({
|
|
8
|
+
timeout: 5000,
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
export const initOIDCAuth = async (client: Client, { redirectUrl, claims, responseMode }: { redirectUrl: string; claims?: string; responseMode?: string }): Promise<InitIDPAuthResult> => {
|
|
12
|
+
const nonce = generators.nonce()
|
|
13
|
+
const state = generators.state()
|
|
14
|
+
const url = client.authorizationUrl({
|
|
15
|
+
redirect_uri: redirectUrl,
|
|
16
|
+
response_mode: responseMode,
|
|
17
|
+
scope: claims ?? 'openid email',
|
|
18
|
+
nonce,
|
|
19
|
+
state,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
authUrl: url,
|
|
24
|
+
sessionData: { nonce, state },
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const handleOIDCResponse = async (client: Client, { sessionData, redirectUrl, ...otherData }: OIDCResponseData): Promise<IDPClaim> => {
|
|
29
|
+
const params = 'parameters' in otherData ? otherData.parameters : client.callbackParams(otherData.url)
|
|
30
|
+
if (params.state && !sessionData?.state) {
|
|
31
|
+
throw new IDPValidationError(`state is present in parameters, but missing in session data`)
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const result = await client.callback(redirectUrl, params, sessionData)
|
|
35
|
+
const claims = result.claims()
|
|
36
|
+
return {
|
|
37
|
+
externalIdentifier: claims.sub,
|
|
38
|
+
email: claims.email,
|
|
39
|
+
name: claims.name,
|
|
40
|
+
}
|
|
41
|
+
} catch (e: any) {
|
|
42
|
+
if (e instanceof errors.RPError) {
|
|
43
|
+
throw new IDPValidationError(e.message)
|
|
44
|
+
}
|
|
45
|
+
if (e instanceof errors.OPError) {
|
|
46
|
+
const body = e.response?.body as any
|
|
47
|
+
if (typeof body === 'object' && typeof body?.error === 'object' && typeof body.error?.message === 'string') {
|
|
48
|
+
throw new IDPResponseError(body.error.message)
|
|
49
|
+
}
|
|
50
|
+
throw new IDPResponseError(e.message)
|
|
51
|
+
}
|
|
52
|
+
throw e
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Client, Issuer } from 'openid-client'
|
|
2
|
+
import { IdentityProviderHandler, IDPClaim, InitIDPAuthResult } from '../IdentityProviderHandler'
|
|
3
|
+
import { InvalidIDPConfigurationError } from '../InvalidIDPConfigurationError'
|
|
4
|
+
import { catchTypesafe } from './helpers'
|
|
5
|
+
import { OIDCConfiguration, OIDCInitData, OIDCResponseData } from './OIDCTypes'
|
|
6
|
+
import { handleOIDCResponse, initOIDCAuth } from './OIDCHelpers'
|
|
7
|
+
import { IDPValidationError } from '../IDPValidationError'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export class OIDCProvider implements IdentityProviderHandler<OIDCConfiguration> {
|
|
11
|
+
private issuerCache: Record<string, Issuer<Client>> = {}
|
|
12
|
+
|
|
13
|
+
validateConfiguration = catchTypesafe(OIDCConfiguration, InvalidIDPConfigurationError)
|
|
14
|
+
|
|
15
|
+
public async initAuth(configuration: OIDCConfiguration, data: unknown): Promise<InitIDPAuthResult> {
|
|
16
|
+
const initData = catchTypesafe(OIDCInitData, IDPValidationError)(data)
|
|
17
|
+
const client = await this.createOIDCClient(configuration)
|
|
18
|
+
return await initOIDCAuth(client, {
|
|
19
|
+
claims: configuration.claims,
|
|
20
|
+
...initData,
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public async processResponse(configuration: OIDCConfiguration, data: unknown): Promise<IDPClaim> {
|
|
25
|
+
const responseData = catchTypesafe(OIDCResponseData, IDPValidationError)(data)
|
|
26
|
+
const client = await this.createOIDCClient(configuration)
|
|
27
|
+
return await handleOIDCResponse(client, responseData)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
private async createOIDCClient(configuration: OIDCConfiguration): Promise<Client> {
|
|
32
|
+
this.issuerCache[configuration.url] ??= await Issuer.discover(configuration.url)
|
|
33
|
+
|
|
34
|
+
return new this.issuerCache[configuration.url].Client({
|
|
35
|
+
client_id: configuration.clientId,
|
|
36
|
+
client_secret: configuration.clientSecret,
|
|
37
|
+
response_types: [configuration.responseType || 'code'],
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as Typesafe from '@contember/typesafe'
|
|
2
|
+
import { ResponseType } from 'openid-client'
|
|
3
|
+
|
|
4
|
+
export interface OIDCSessionData {
|
|
5
|
+
nonce: string
|
|
6
|
+
state: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const OIDCConfigurationOptions = Typesafe.partial({
|
|
10
|
+
responseType: Typesafe.enumeration<ResponseType>('code', 'code id_token', 'code id_token token', 'code token', 'id_token', 'id_token token', 'none'),
|
|
11
|
+
claims: Typesafe.string,
|
|
12
|
+
})
|
|
13
|
+
export const BaseOIDCConfiguration = Typesafe.intersection(
|
|
14
|
+
Typesafe.object({
|
|
15
|
+
url: Typesafe.string,
|
|
16
|
+
clientId: Typesafe.string,
|
|
17
|
+
clientSecret: Typesafe.string,
|
|
18
|
+
}),
|
|
19
|
+
OIDCConfigurationOptions,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
export const OIDCConfiguration = Typesafe.intersection(
|
|
23
|
+
BaseOIDCConfiguration,
|
|
24
|
+
Typesafe.object({
|
|
25
|
+
url: Typesafe.string,
|
|
26
|
+
}),
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
export type OIDCConfiguration = ReturnType<typeof OIDCConfiguration>
|
|
30
|
+
|
|
31
|
+
export const OIDCResponseData = Typesafe.intersection(
|
|
32
|
+
Typesafe.union(
|
|
33
|
+
Typesafe.object({
|
|
34
|
+
url: Typesafe.string,
|
|
35
|
+
}),
|
|
36
|
+
Typesafe.object({
|
|
37
|
+
parameters: Typesafe.record(Typesafe.string, Typesafe.string),
|
|
38
|
+
}),
|
|
39
|
+
),
|
|
40
|
+
Typesafe.partial({
|
|
41
|
+
redirectUrl: Typesafe.string,
|
|
42
|
+
sessionData: Typesafe.partial({
|
|
43
|
+
nonce: Typesafe.string,
|
|
44
|
+
state: Typesafe.string,
|
|
45
|
+
}),
|
|
46
|
+
|
|
47
|
+
}),
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
export type OIDCResponseData = ReturnType<typeof OIDCResponseData>
|
|
51
|
+
|
|
52
|
+
export const OIDCInitData = Typesafe.noExtraProps(Typesafe.intersection(
|
|
53
|
+
Typesafe.object({
|
|
54
|
+
redirectUrl: Typesafe.string,
|
|
55
|
+
}),
|
|
56
|
+
Typesafe.partial({
|
|
57
|
+
responseMode: Typesafe.string,
|
|
58
|
+
}),
|
|
59
|
+
))
|
|
60
|
+
|
|
61
|
+
export type OIDCInitData = ReturnType<typeof OIDCInitData>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as Typesafe from '@contember/typesafe'
|
|
2
|
+
|
|
3
|
+
export const catchTypesafe = <T extends Typesafe.Json>(type: Typesafe.Type<T>, errorConstructor: { new(message: string): Error }) => (value: unknown): T => {
|
|
4
|
+
try {
|
|
5
|
+
return type(value)
|
|
6
|
+
} catch (e) {
|
|
7
|
+
if (e instanceof Typesafe.ParseError) {
|
|
8
|
+
throw new errorConstructor(e.message)
|
|
9
|
+
}
|
|
10
|
+
throw e
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -27,6 +27,12 @@ export class DatabaseContext<Conn extends Connection.ConnectionLike = Connection
|
|
|
27
27
|
})
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
public async scope<T>(cb: (dbContext: DatabaseContext<Connection.AcquiredConnectionLike>) => Promise<T>): Promise<T> {
|
|
31
|
+
return await this.client.scope(async db => {
|
|
32
|
+
return await cb(new DatabaseContext(db, this.providers))
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
public batchLoad<Arg, Result, Item>(loaderArgs: BatchLoaderArgs<Arg, Result, Item>, arg: Arg): Promise<Item> {
|
|
31
37
|
const existing = this.loaders.get(loaderArgs)
|
|
32
38
|
if (existing) {
|
|
@@ -15,6 +15,7 @@ export class UpdateIDPMutationResolver implements MutationResolvers {
|
|
|
15
15
|
})
|
|
16
16
|
const result = await this.idpManager.updateIDP(context.db, args.identityProvider, {
|
|
17
17
|
configuration: args.configuration,
|
|
18
|
+
type: args.type ?? undefined,
|
|
18
19
|
options: {
|
|
19
20
|
autoSignUp: args.options?.autoSignUp ?? undefined,
|
|
20
21
|
exclusive: args.options?.exclusive ?? undefined,
|
|
@@ -6,9 +6,7 @@ import {
|
|
|
6
6
|
SignInIdpResponse,
|
|
7
7
|
} from '../../../schema'
|
|
8
8
|
import { TenantResolverContext } from '../../TenantResolverContext'
|
|
9
|
-
import { IDPSignInManager, PermissionActions
|
|
10
|
-
import { createResolverContext } from '../../TenantResolverContextFactory'
|
|
11
|
-
import { IdentityTypeResolver } from '../../types'
|
|
9
|
+
import { IDPSignInManager, PermissionActions } from '../../../model'
|
|
12
10
|
import { createErrorResponse } from '../../errorUtils'
|
|
13
11
|
import { SignInResponseFactory } from '../../responseHelpers/SignInResponseFactory'
|
|
14
12
|
|
|
@@ -27,7 +25,9 @@ export class IDPMutationResolver implements MutationResolvers {
|
|
|
27
25
|
action: PermissionActions.PERSON_CREATE_IDP_URL,
|
|
28
26
|
message: 'You are not allowed to create a redirect URL for IDP',
|
|
29
27
|
})
|
|
30
|
-
const result = await this.idpSignInManager.initSignInIDP(context.db, args.identityProvider, args.
|
|
28
|
+
const result = await this.idpSignInManager.initSignInIDP(context.db, args.identityProvider, args.data ?? {
|
|
29
|
+
redirectUrl: args.redirectUrl,
|
|
30
|
+
})
|
|
31
31
|
if (!result.ok) {
|
|
32
32
|
return createErrorResponse(result.error, result.errorMessage)
|
|
33
33
|
}
|
|
@@ -42,9 +42,11 @@ export class IDPMutationResolver implements MutationResolvers {
|
|
|
42
42
|
const signIn = await this.idpSignInManager.signInIDP(
|
|
43
43
|
context.db,
|
|
44
44
|
args.identityProvider,
|
|
45
|
-
args.
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
args.data ?? {
|
|
46
|
+
sessionData: args.sessionData,
|
|
47
|
+
url: args.idpResponse?.url,
|
|
48
|
+
redirectUrl: args.redirectUrl,
|
|
49
|
+
},
|
|
48
50
|
args.expiration ?? undefined,
|
|
49
51
|
)
|
|
50
52
|
if (!signIn.ok) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ProjectIdentityRelation, ProjectMembersArgs, ProjectResolvers } from '../../schema'
|
|
1
|
+
import { MemberType, ProjectIdentityRelation, ProjectMembersArgs, ProjectResolvers } from '../../schema'
|
|
2
2
|
import { TenantResolverContext } from '../TenantResolverContext'
|
|
3
3
|
import { PermissionActions, Project, ProjectMemberManager, ProjectSchemaResolver } from '../../model'
|
|
4
4
|
import { getRoleVariables } from '@contember/schema-utils'
|
|
5
5
|
import { Acl } from '@contember/schema'
|
|
6
|
+
import { UserInputError } from '@contember/graphql-utils'
|
|
6
7
|
|
|
7
8
|
export class ProjectTypeResolver implements ProjectResolvers {
|
|
8
9
|
constructor(
|
|
@@ -20,8 +21,14 @@ export class ProjectTypeResolver implements ProjectResolvers {
|
|
|
20
21
|
if (!(await verifier(PermissionActions.PROJECT_VIEW_MEMBER([])))) {
|
|
21
22
|
return []
|
|
22
23
|
}
|
|
24
|
+
if (args.input?.filter?.email && args.input.filter.memberType === MemberType.ApiKey) {
|
|
25
|
+
throw new UserInputError(`Cannot use email filter for ApiKey member type.`)
|
|
26
|
+
}
|
|
27
|
+
if (args.memberType && args.input) {
|
|
28
|
+
throw new UserInputError(`Cannot use both deprecated memberType parameter and new input parameter`)
|
|
29
|
+
}
|
|
23
30
|
|
|
24
|
-
const members = await this.projectMemberManager.getProjectMembers(context.db, parent.id, verifier, args.
|
|
31
|
+
const members = await this.projectMemberManager.getProjectMembers(context.db, parent.id, verifier, args.input ?? { filter: { memberType: args.memberType } })
|
|
25
32
|
return members.map(it => ({
|
|
26
33
|
...it,
|
|
27
34
|
identity: { ...it.identity, projects: [] },
|
package/src/schema/index.ts
CHANGED
|
@@ -413,6 +413,7 @@ export type InitSignInIdpError = {
|
|
|
413
413
|
}
|
|
414
414
|
|
|
415
415
|
export enum InitSignInIdpErrorCode {
|
|
416
|
+
IdpValidationFailed = 'IDP_VALIDATION_FAILED',
|
|
416
417
|
ProviderNotFound = 'PROVIDER_NOT_FOUND'
|
|
417
418
|
}
|
|
418
419
|
|
|
@@ -533,7 +534,7 @@ export type Mutation = {
|
|
|
533
534
|
readonly __typename?: 'Mutation'
|
|
534
535
|
readonly addIDP?: Maybe<AddIdpResponse>
|
|
535
536
|
readonly addMailTemplate?: Maybe<AddMailTemplateResponse>
|
|
536
|
-
/** @deprecated use
|
|
537
|
+
/** @deprecated use addMailTemplate */
|
|
537
538
|
readonly addProjectMailTemplate?: Maybe<AddMailTemplateResponse>
|
|
538
539
|
readonly addProjectMember?: Maybe<AddProjectMemberResponse>
|
|
539
540
|
readonly changeMyPassword?: Maybe<ChangeMyPasswordResponse>
|
|
@@ -552,7 +553,7 @@ export type Mutation = {
|
|
|
552
553
|
readonly invite?: Maybe<InviteResponse>
|
|
553
554
|
readonly prepareOtp?: Maybe<PrepareOtpResponse>
|
|
554
555
|
readonly removeMailTemplate?: Maybe<RemoveMailTemplateResponse>
|
|
555
|
-
/** @deprecated use
|
|
556
|
+
/** @deprecated use removeMailTemplate */
|
|
556
557
|
readonly removeProjectMailTemplate?: Maybe<RemoveMailTemplateResponse>
|
|
557
558
|
readonly removeProjectMember?: Maybe<RemoveProjectMemberResponse>
|
|
558
559
|
readonly resetPassword?: Maybe<ResetPasswordResponse>
|
|
@@ -664,8 +665,9 @@ export type MutationEnableIdpArgs = {
|
|
|
664
665
|
|
|
665
666
|
|
|
666
667
|
export type MutationInitSignInIdpArgs = {
|
|
668
|
+
data?: InputMaybe<Scalars['Json']>
|
|
667
669
|
identityProvider: Scalars['String']
|
|
668
|
-
redirectUrl
|
|
670
|
+
redirectUrl?: InputMaybe<Scalars['String']>
|
|
669
671
|
}
|
|
670
672
|
|
|
671
673
|
|
|
@@ -721,11 +723,12 @@ export type MutationSignInArgs = {
|
|
|
721
723
|
|
|
722
724
|
|
|
723
725
|
export type MutationSignInIdpArgs = {
|
|
726
|
+
data?: InputMaybe<Scalars['Json']>
|
|
724
727
|
expiration?: InputMaybe<Scalars['Int']>
|
|
725
728
|
identityProvider: Scalars['String']
|
|
726
|
-
idpResponse
|
|
727
|
-
redirectUrl
|
|
728
|
-
sessionData
|
|
729
|
+
idpResponse?: InputMaybe<IdpResponseInput>
|
|
730
|
+
redirectUrl?: InputMaybe<Scalars['String']>
|
|
731
|
+
sessionData?: InputMaybe<Scalars['Json']>
|
|
729
732
|
}
|
|
730
733
|
|
|
731
734
|
|
|
@@ -757,6 +760,7 @@ export type MutationUpdateIdpArgs = {
|
|
|
757
760
|
configuration?: InputMaybe<Scalars['Json']>
|
|
758
761
|
identityProvider: Scalars['String']
|
|
759
762
|
options?: InputMaybe<IdpOptions>
|
|
763
|
+
type?: InputMaybe<Scalars['String']>
|
|
760
764
|
}
|
|
761
765
|
|
|
762
766
|
|
|
@@ -807,6 +811,7 @@ export type Project = {
|
|
|
807
811
|
|
|
808
812
|
|
|
809
813
|
export type ProjectMembersArgs = {
|
|
814
|
+
input?: InputMaybe<ProjectMembersInput>
|
|
810
815
|
memberType?: InputMaybe<MemberType>
|
|
811
816
|
}
|
|
812
817
|
|
|
@@ -816,6 +821,17 @@ export type ProjectIdentityRelation = {
|
|
|
816
821
|
readonly memberships: ReadonlyArray<Membership>
|
|
817
822
|
}
|
|
818
823
|
|
|
824
|
+
export type ProjectMembersFilter = {
|
|
825
|
+
readonly email?: InputMaybe<Scalars['String']>
|
|
826
|
+
readonly memberType?: InputMaybe<MemberType>
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
export type ProjectMembersInput = {
|
|
830
|
+
readonly filter?: InputMaybe<ProjectMembersFilter>
|
|
831
|
+
readonly limit?: InputMaybe<Scalars['Int']>
|
|
832
|
+
readonly offset?: InputMaybe<Scalars['Int']>
|
|
833
|
+
}
|
|
834
|
+
|
|
819
835
|
export type ProjectSecret = {
|
|
820
836
|
readonly key: Scalars['String']
|
|
821
837
|
readonly value: Scalars['String']
|
|
@@ -1274,6 +1290,8 @@ export type ResolversTypes = {
|
|
|
1274
1290
|
PrepareOtpResult: ResolverTypeWrapper<PrepareOtpResult>
|
|
1275
1291
|
Project: ResolverTypeWrapper<Project>
|
|
1276
1292
|
ProjectIdentityRelation: ResolverTypeWrapper<ProjectIdentityRelation>
|
|
1293
|
+
ProjectMembersFilter: ProjectMembersFilter
|
|
1294
|
+
ProjectMembersInput: ProjectMembersInput
|
|
1277
1295
|
ProjectSecret: ProjectSecret
|
|
1278
1296
|
Query: ResolverTypeWrapper<{}>
|
|
1279
1297
|
RemoveMailTemplateError: ResolverTypeWrapper<RemoveMailTemplateError>
|
|
@@ -1387,6 +1405,8 @@ export type ResolversParentTypes = {
|
|
|
1387
1405
|
PrepareOtpResult: PrepareOtpResult
|
|
1388
1406
|
Project: Project
|
|
1389
1407
|
ProjectIdentityRelation: ProjectIdentityRelation
|
|
1408
|
+
ProjectMembersFilter: ProjectMembersFilter
|
|
1409
|
+
ProjectMembersInput: ProjectMembersInput
|
|
1390
1410
|
ProjectSecret: ProjectSecret
|
|
1391
1411
|
Query: {}
|
|
1392
1412
|
RemoveMailTemplateError: RemoveMailTemplateError
|
|
@@ -1770,7 +1790,7 @@ export type MutationResolvers<ContextType = any, ParentType extends ResolversPar
|
|
|
1770
1790
|
disableIDP?: Resolver<Maybe<ResolversTypes['DisableIDPResponse']>, ParentType, ContextType, RequireFields<MutationDisableIdpArgs, 'identityProvider'>>
|
|
1771
1791
|
disableOtp?: Resolver<Maybe<ResolversTypes['DisableOtpResponse']>, ParentType, ContextType>
|
|
1772
1792
|
enableIDP?: Resolver<Maybe<ResolversTypes['EnableIDPResponse']>, ParentType, ContextType, RequireFields<MutationEnableIdpArgs, 'identityProvider'>>
|
|
1773
|
-
initSignInIDP?: Resolver<Maybe<ResolversTypes['InitSignInIDPResponse']>, ParentType, ContextType, RequireFields<MutationInitSignInIdpArgs, 'identityProvider'
|
|
1793
|
+
initSignInIDP?: Resolver<Maybe<ResolversTypes['InitSignInIDPResponse']>, ParentType, ContextType, RequireFields<MutationInitSignInIdpArgs, 'identityProvider'>>
|
|
1774
1794
|
invite?: Resolver<Maybe<ResolversTypes['InviteResponse']>, ParentType, ContextType, RequireFields<MutationInviteArgs, 'email' | 'memberships' | 'projectSlug'>>
|
|
1775
1795
|
prepareOtp?: Resolver<Maybe<ResolversTypes['PrepareOtpResponse']>, ParentType, ContextType, Partial<MutationPrepareOtpArgs>>
|
|
1776
1796
|
removeMailTemplate?: Resolver<Maybe<ResolversTypes['RemoveMailTemplateResponse']>, ParentType, ContextType, RequireFields<MutationRemoveMailTemplateArgs, 'templateIdentifier'>>
|
|
@@ -1779,7 +1799,7 @@ export type MutationResolvers<ContextType = any, ParentType extends ResolversPar
|
|
|
1779
1799
|
resetPassword?: Resolver<Maybe<ResolversTypes['ResetPasswordResponse']>, ParentType, ContextType, RequireFields<MutationResetPasswordArgs, 'password' | 'token'>>
|
|
1780
1800
|
setProjectSecret?: Resolver<Maybe<ResolversTypes['SetProjectSecretResponse']>, ParentType, ContextType, RequireFields<MutationSetProjectSecretArgs, 'key' | 'projectSlug' | 'value'>>
|
|
1781
1801
|
signIn?: Resolver<Maybe<ResolversTypes['SignInResponse']>, ParentType, ContextType, RequireFields<MutationSignInArgs, 'email' | 'password'>>
|
|
1782
|
-
signInIDP?: Resolver<Maybe<ResolversTypes['SignInIDPResponse']>, ParentType, ContextType, RequireFields<MutationSignInIdpArgs, 'identityProvider'
|
|
1802
|
+
signInIDP?: Resolver<Maybe<ResolversTypes['SignInIDPResponse']>, ParentType, ContextType, RequireFields<MutationSignInIdpArgs, 'identityProvider'>>
|
|
1783
1803
|
signOut?: Resolver<Maybe<ResolversTypes['SignOutResponse']>, ParentType, ContextType, Partial<MutationSignOutArgs>>
|
|
1784
1804
|
signUp?: Resolver<Maybe<ResolversTypes['SignUpResponse']>, ParentType, ContextType, RequireFields<MutationSignUpArgs, 'email'>>
|
|
1785
1805
|
unmanagedInvite?: Resolver<Maybe<ResolversTypes['InviteResponse']>, ParentType, ContextType, RequireFields<MutationUnmanagedInviteArgs, 'email' | 'memberships' | 'projectSlug'>>
|