@things-factory/auth-base 8.0.5 → 9.0.0-beta.12
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/config/config.development.js +45 -0
- package/config/config.production.js +45 -0
- package/dist-client/bootstrap.d.ts +1 -1
- package/dist-client/bootstrap.js +4 -4
- package/dist-client/bootstrap.js.map +1 -1
- package/dist-client/directive/privileged.d.ts +1 -1
- package/dist-client/directive/privileged.js +1 -1
- package/dist-client/directive/privileged.js.map +1 -1
- package/dist-client/index.d.ts +4 -3
- package/dist-client/index.js +4 -3
- package/dist-client/index.js.map +1 -1
- package/dist-client/profiled.js +1 -1
- package/dist-client/profiled.js.map +1 -1
- package/dist-client/reducers/auth.js +1 -1
- package/dist-client/reducers/auth.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/verify-webauthn.d.ts +13 -0
- package/dist-client/verify-webauthn.js +72 -0
- package/dist-client/verify-webauthn.js.map +1 -0
- package/dist-server/constants/error-code.d.ts +2 -0
- package/dist-server/constants/error-code.js +3 -1
- package/dist-server/constants/error-code.js.map +1 -1
- package/dist-server/controllers/auth.d.ts +5 -5
- package/dist-server/controllers/auth.js +5 -5
- package/dist-server/controllers/auth.js.map +1 -1
- package/dist-server/controllers/change-pwd.js +21 -21
- package/dist-server/controllers/change-pwd.js.map +1 -1
- package/dist-server/controllers/checkin.js +4 -4
- package/dist-server/controllers/checkin.js.map +1 -1
- package/dist-server/controllers/delete-user.js +22 -21
- package/dist-server/controllers/delete-user.js.map +1 -1
- package/dist-server/controllers/invitation.d.ts +2 -1
- package/dist-server/controllers/invitation.js +46 -21
- package/dist-server/controllers/invitation.js.map +1 -1
- package/dist-server/controllers/profile.d.ts +9 -8
- package/dist-server/controllers/profile.js +26 -8
- package/dist-server/controllers/profile.js.map +1 -1
- package/dist-server/controllers/reset-password.js +24 -24
- package/dist-server/controllers/reset-password.js.map +1 -1
- package/dist-server/controllers/signin.d.ts +5 -2
- package/dist-server/controllers/signin.js +41 -25
- package/dist-server/controllers/signin.js.map +1 -1
- package/dist-server/controllers/signup.d.ts +1 -1
- package/dist-server/controllers/signup.js +26 -17
- package/dist-server/controllers/signup.js.map +1 -1
- package/dist-server/controllers/unlock-user.js +18 -17
- package/dist-server/controllers/unlock-user.js.map +1 -1
- package/dist-server/controllers/utils/password-rule.js +4 -4
- package/dist-server/controllers/utils/password-rule.js.map +1 -1
- package/dist-server/controllers/utils/save-invitation-token.d.ts +1 -1
- package/dist-server/controllers/utils/save-invitation-token.js +2 -2
- package/dist-server/controllers/utils/save-invitation-token.js.map +1 -1
- package/dist-server/controllers/utils/save-verification-token.d.ts +1 -1
- package/dist-server/controllers/utils/save-verification-token.js +3 -3
- package/dist-server/controllers/utils/save-verification-token.js.map +1 -1
- package/dist-server/controllers/verification.js +24 -23
- package/dist-server/controllers/verification.js.map +1 -1
- package/dist-server/errors/auth-error.js +1 -1
- package/dist-server/errors/auth-error.js.map +1 -1
- package/dist-server/errors/index.d.ts +2 -2
- package/dist-server/errors/index.js +2 -2
- package/dist-server/errors/index.js.map +1 -1
- package/dist-server/errors/user-domain-not-match-error.d.ts +1 -1
- package/dist-server/errors/user-domain-not-match-error.js +8 -8
- package/dist-server/errors/user-domain-not-match-error.js.map +1 -1
- package/dist-server/index.d.ts +16 -16
- package/dist-server/index.js +18 -18
- package/dist-server/index.js.map +1 -1
- package/dist-server/middlewares/authenticate-401-middleware.js +11 -11
- package/dist-server/middlewares/authenticate-401-middleware.js.map +1 -1
- package/dist-server/middlewares/domain-authenticate-middleware.d.ts +1 -1
- package/dist-server/middlewares/domain-authenticate-middleware.js +9 -9
- package/dist-server/middlewares/domain-authenticate-middleware.js.map +1 -1
- package/dist-server/middlewares/graphql-authenticate-middleware.js +4 -4
- package/dist-server/middlewares/graphql-authenticate-middleware.js.map +1 -1
- package/dist-server/middlewares/index.d.ts +5 -5
- package/dist-server/middlewares/index.js +18 -18
- package/dist-server/middlewares/index.js.map +1 -1
- package/dist-server/middlewares/jwt-authenticate-middleware.js +15 -15
- package/dist-server/middlewares/jwt-authenticate-middleware.js.map +1 -1
- package/dist-server/middlewares/signin-middleware.js +7 -6
- package/dist-server/middlewares/signin-middleware.js.map +1 -1
- package/dist-server/middlewares/verify-recaptcha-middleware.d.ts +3 -0
- package/dist-server/middlewares/verify-recaptcha-middleware.js +95 -0
- package/dist-server/middlewares/verify-recaptcha-middleware.js.map +1 -0
- package/dist-server/middlewares/webauthn-middleware.js +16 -13
- package/dist-server/middlewares/webauthn-middleware.js.map +1 -1
- package/dist-server/migrations/1548206416130-SeedUser.js +8 -7
- package/dist-server/migrations/1548206416130-SeedUser.js.map +1 -1
- package/dist-server/migrations/1566805283882-SeedPrivilege.js +2 -2
- package/dist-server/migrations/1566805283882-SeedPrivilege.js.map +1 -1
- package/dist-server/migrations/index.js.map +1 -1
- package/dist-server/router/auth-checkin-router.js +18 -12
- package/dist-server/router/auth-checkin-router.js.map +1 -1
- package/dist-server/router/auth-private-process-router.js +26 -21
- package/dist-server/router/auth-private-process-router.js.map +1 -1
- package/dist-server/router/auth-public-process-router.js +42 -31
- package/dist-server/router/auth-public-process-router.js.map +1 -1
- package/dist-server/router/auth-signin-router.js +16 -16
- package/dist-server/router/auth-signin-router.js.map +1 -1
- package/dist-server/router/auth-signup-router.js +13 -9
- package/dist-server/router/auth-signup-router.js.map +1 -1
- package/dist-server/router/index.d.ts +9 -9
- package/dist-server/router/index.js +9 -9
- package/dist-server/router/index.js.map +1 -1
- package/dist-server/router/oauth2/index.d.ts +2 -2
- package/dist-server/router/oauth2/index.js +2 -2
- package/dist-server/router/oauth2/index.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-authorize-router.js +6 -6
- package/dist-server/router/oauth2/oauth2-authorize-router.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-router.d.ts +1 -1
- package/dist-server/router/oauth2/oauth2-router.js +21 -21
- package/dist-server/router/oauth2/oauth2-router.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-server.js +21 -21
- package/dist-server/router/oauth2/oauth2-server.js.map +1 -1
- package/dist-server/router/site-root-router.js +4 -4
- package/dist-server/router/site-root-router.js.map +1 -1
- package/dist-server/router/webauthn-router.js +58 -8
- package/dist-server/router/webauthn-router.js.map +1 -1
- package/dist-server/routes.js +19 -19
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/app-binding/app-binding-mutation.js +4 -4
- package/dist-server/service/app-binding/app-binding-mutation.js.map +1 -1
- package/dist-server/service/app-binding/app-binding-query.d.ts +4 -4
- package/dist-server/service/app-binding/app-binding-query.js +22 -22
- package/dist-server/service/app-binding/app-binding-query.js.map +1 -1
- package/dist-server/service/app-binding/app-binding-types.d.ts +1 -1
- package/dist-server/service/app-binding/app-binding-types.js +2 -2
- package/dist-server/service/app-binding/app-binding-types.js.map +1 -1
- package/dist-server/service/app-binding/app-binding.d.ts +2 -2
- package/dist-server/service/app-binding/app-binding.js +4 -4
- package/dist-server/service/app-binding/app-binding.js.map +1 -1
- package/dist-server/service/app-binding/index.d.ts +2 -2
- package/dist-server/service/app-binding/index.js +3 -3
- package/dist-server/service/app-binding/index.js.map +1 -1
- package/dist-server/service/appliance/appliance-mutation.d.ts +2 -2
- package/dist-server/service/appliance/appliance-mutation.js +21 -21
- package/dist-server/service/appliance/appliance-mutation.js.map +1 -1
- package/dist-server/service/appliance/appliance-query.d.ts +3 -3
- package/dist-server/service/appliance/appliance-query.js +17 -17
- package/dist-server/service/appliance/appliance-query.js.map +1 -1
- package/dist-server/service/appliance/appliance-types.d.ts +1 -1
- package/dist-server/service/appliance/appliance-types.js +2 -2
- package/dist-server/service/appliance/appliance-types.js.map +1 -1
- package/dist-server/service/appliance/appliance.d.ts +1 -1
- package/dist-server/service/appliance/appliance.js +8 -8
- package/dist-server/service/appliance/appliance.js.map +1 -1
- package/dist-server/service/appliance/index.d.ts +3 -3
- package/dist-server/service/appliance/index.js +5 -5
- package/dist-server/service/appliance/index.js.map +1 -1
- package/dist-server/service/application/application-mutation.d.ts +8 -8
- package/dist-server/service/application/application-mutation.js +20 -20
- package/dist-server/service/application/application-mutation.js.map +1 -1
- package/dist-server/service/application/application-query.d.ts +2 -2
- package/dist-server/service/application/application-query.js +16 -16
- package/dist-server/service/application/application-query.js.map +1 -1
- package/dist-server/service/application/application-types.d.ts +1 -1
- package/dist-server/service/application/application-types.js +4 -4
- package/dist-server/service/application/application-types.js.map +1 -1
- package/dist-server/service/application/application.d.ts +1 -1
- package/dist-server/service/application/application.js +12 -12
- package/dist-server/service/application/application.js.map +1 -1
- package/dist-server/service/application/index.d.ts +3 -3
- package/dist-server/service/application/index.js +5 -5
- package/dist-server/service/application/index.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider-mutation.d.ts +2 -2
- package/dist-server/service/auth-provider/auth-provider-mutation.js +20 -20
- package/dist-server/service/auth-provider/auth-provider-mutation.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider-query.d.ts +3 -3
- package/dist-server/service/auth-provider/auth-provider-query.js +20 -20
- package/dist-server/service/auth-provider/auth-provider-query.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider-type.d.ts +1 -1
- package/dist-server/service/auth-provider/auth-provider-type.js +2 -2
- package/dist-server/service/auth-provider/auth-provider-type.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider.d.ts +3 -3
- package/dist-server/service/auth-provider/auth-provider.js +12 -12
- package/dist-server/service/auth-provider/auth-provider.js.map +1 -1
- package/dist-server/service/auth-provider/index.d.ts +3 -3
- package/dist-server/service/auth-provider/index.js +5 -5
- package/dist-server/service/auth-provider/index.js.map +1 -1
- package/dist-server/service/domain-generator/domain-generator-mutation.d.ts +1 -1
- package/dist-server/service/domain-generator/domain-generator-mutation.js +11 -11
- package/dist-server/service/domain-generator/domain-generator-mutation.js.map +1 -1
- package/dist-server/service/domain-generator/domain-generator-types.d.ts +1 -1
- package/dist-server/service/domain-generator/domain-generator-types.js +3 -3
- package/dist-server/service/domain-generator/domain-generator-types.js.map +1 -1
- package/dist-server/service/domain-generator/index.d.ts +1 -1
- package/dist-server/service/domain-generator/index.js +2 -2
- package/dist-server/service/domain-generator/index.js.map +1 -1
- package/dist-server/service/granted-role/granted-role-mutation.d.ts +3 -3
- package/dist-server/service/granted-role/granted-role-mutation.js +17 -17
- package/dist-server/service/granted-role/granted-role-mutation.js.map +1 -1
- package/dist-server/service/granted-role/granted-role-query.d.ts +2 -2
- package/dist-server/service/granted-role/granted-role-query.js +13 -13
- package/dist-server/service/granted-role/granted-role-query.js.map +1 -1
- package/dist-server/service/granted-role/granted-role.d.ts +1 -1
- package/dist-server/service/granted-role/granted-role.js +3 -3
- package/dist-server/service/granted-role/granted-role.js.map +1 -1
- package/dist-server/service/granted-role/index.d.ts +3 -3
- package/dist-server/service/granted-role/index.js +5 -5
- package/dist-server/service/granted-role/index.js.map +1 -1
- package/dist-server/service/index.d.ts +25 -25
- package/dist-server/service/index.js +70 -70
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/invitation/index.d.ts +3 -3
- package/dist-server/service/invitation/index.js +5 -5
- package/dist-server/service/invitation/index.js.map +1 -1
- package/dist-server/service/invitation/invitation-mutation.d.ts +4 -3
- package/dist-server/service/invitation/invitation-mutation.js +26 -14
- package/dist-server/service/invitation/invitation-mutation.js.map +1 -1
- package/dist-server/service/invitation/invitation-query.d.ts +1 -1
- package/dist-server/service/invitation/invitation-query.js +7 -7
- package/dist-server/service/invitation/invitation-query.js.map +1 -1
- package/dist-server/service/invitation/invitation-types.d.ts +1 -1
- package/dist-server/service/invitation/invitation-types.js +2 -2
- package/dist-server/service/invitation/invitation-types.js.map +1 -1
- package/dist-server/service/invitation/invitation.d.ts +1 -1
- package/dist-server/service/invitation/invitation.js +5 -5
- package/dist-server/service/invitation/invitation.js.map +1 -1
- package/dist-server/service/login-history/index.d.ts +2 -2
- package/dist-server/service/login-history/index.js +4 -4
- package/dist-server/service/login-history/index.js.map +1 -1
- package/dist-server/service/login-history/login-history-query.d.ts +3 -3
- package/dist-server/service/login-history/login-history-query.js +11 -11
- package/dist-server/service/login-history/login-history-query.js.map +1 -1
- package/dist-server/service/login-history/login-history-type.d.ts +1 -1
- package/dist-server/service/login-history/login-history-type.js +2 -2
- package/dist-server/service/login-history/login-history-type.js.map +1 -1
- package/dist-server/service/login-history/login-history.d.ts +1 -1
- package/dist-server/service/login-history/login-history.js +4 -4
- package/dist-server/service/login-history/login-history.js.map +1 -1
- package/dist-server/service/partner/index.d.ts +3 -3
- package/dist-server/service/partner/index.js +5 -5
- package/dist-server/service/partner/index.js.map +1 -1
- package/dist-server/service/partner/partner-mutation.js +8 -8
- package/dist-server/service/partner/partner-mutation.js.map +1 -1
- package/dist-server/service/partner/partner-query.d.ts +3 -3
- package/dist-server/service/partner/partner-query.js +17 -17
- package/dist-server/service/partner/partner-query.js.map +1 -1
- package/dist-server/service/partner/partner-types.d.ts +1 -1
- package/dist-server/service/partner/partner-types.js +2 -2
- package/dist-server/service/partner/partner-types.js.map +1 -1
- package/dist-server/service/partner/partner.d.ts +1 -1
- package/dist-server/service/partner/partner.js +5 -5
- package/dist-server/service/partner/partner.js.map +1 -1
- package/dist-server/service/password-history/index.d.ts +1 -1
- package/dist-server/service/password-history/index.js +2 -2
- package/dist-server/service/password-history/index.js.map +1 -1
- package/dist-server/service/privilege/index.d.ts +3 -3
- package/dist-server/service/privilege/index.js +5 -5
- package/dist-server/service/privilege/index.js.map +1 -1
- package/dist-server/service/privilege/privilege-directive.js +2 -2
- package/dist-server/service/privilege/privilege-directive.js.map +1 -1
- package/dist-server/service/privilege/privilege-mutation.d.ts +2 -2
- package/dist-server/service/privilege/privilege-mutation.js +15 -15
- package/dist-server/service/privilege/privilege-mutation.js.map +1 -1
- package/dist-server/service/privilege/privilege-query.d.ts +4 -4
- package/dist-server/service/privilege/privilege-query.js +20 -20
- package/dist-server/service/privilege/privilege-query.js.map +1 -1
- package/dist-server/service/privilege/privilege-types.d.ts +1 -1
- package/dist-server/service/privilege/privilege-types.js +2 -2
- package/dist-server/service/privilege/privilege-types.js.map +1 -1
- package/dist-server/service/privilege/privilege.d.ts +2 -2
- package/dist-server/service/privilege/privilege.js +10 -10
- package/dist-server/service/privilege/privilege.js.map +1 -1
- package/dist-server/service/role/index.d.ts +3 -3
- package/dist-server/service/role/index.js +5 -5
- package/dist-server/service/role/index.js.map +1 -1
- package/dist-server/service/role/role-mutation.d.ts +2 -2
- package/dist-server/service/role/role-mutation.js +19 -19
- package/dist-server/service/role/role-mutation.js.map +1 -1
- package/dist-server/service/role/role-query.d.ts +4 -4
- package/dist-server/service/role/role-query.js +29 -29
- package/dist-server/service/role/role-query.js.map +1 -1
- package/dist-server/service/role/role-types.d.ts +1 -1
- package/dist-server/service/role/role-types.js +2 -2
- package/dist-server/service/role/role-types.js.map +1 -1
- package/dist-server/service/role/role.d.ts +2 -2
- package/dist-server/service/role/role.js +12 -12
- package/dist-server/service/role/role.js.map +1 -1
- package/dist-server/service/user/domain-query.d.ts +1 -1
- package/dist-server/service/user/domain-query.js +3 -3
- package/dist-server/service/user/domain-query.js.map +1 -1
- package/dist-server/service/user/index.d.ts +4 -4
- package/dist-server/service/user/index.js +6 -6
- package/dist-server/service/user/index.js.map +1 -1
- package/dist-server/service/user/user-mutation.d.ts +13 -12
- package/dist-server/service/user/user-mutation.js +141 -83
- package/dist-server/service/user/user-mutation.js.map +1 -1
- package/dist-server/service/user/user-query.d.ts +3 -3
- package/dist-server/service/user/user-query.js +21 -21
- package/dist-server/service/user/user-query.js.map +1 -1
- package/dist-server/service/user/user-types.d.ts +2 -1
- package/dist-server/service/user/user-types.js +6 -2
- package/dist-server/service/user/user-types.js.map +1 -1
- package/dist-server/service/user/user.d.ts +4 -3
- package/dist-server/service/user/user.js +80 -54
- package/dist-server/service/user/user.js.map +1 -1
- package/dist-server/service/users-auth-providers/index.d.ts +1 -1
- package/dist-server/service/users-auth-providers/index.js +2 -2
- package/dist-server/service/users-auth-providers/index.js.map +1 -1
- package/dist-server/service/users-auth-providers/users-auth-providers.d.ts +2 -2
- package/dist-server/service/users-auth-providers/users-auth-providers.js +8 -8
- package/dist-server/service/users-auth-providers/users-auth-providers.js.map +1 -1
- package/dist-server/service/verification-token/index.d.ts +1 -1
- package/dist-server/service/verification-token/index.js +2 -2
- package/dist-server/service/verification-token/index.js.map +1 -1
- package/dist-server/service/web-auth-credential/index.d.ts +1 -1
- package/dist-server/service/web-auth-credential/index.js +2 -2
- package/dist-server/service/web-auth-credential/index.js.map +1 -1
- package/dist-server/service/web-auth-credential/web-auth-credential.d.ts +1 -1
- package/dist-server/service/web-auth-credential/web-auth-credential.js +10 -10
- package/dist-server/service/web-auth-credential/web-auth-credential.js.map +1 -1
- package/dist-server/templates/account-unlock-email.d.ts +2 -1
- package/dist-server/templates/account-unlock-email.js +1 -1
- package/dist-server/templates/account-unlock-email.js.map +1 -1
- package/dist-server/templates/invitation-email.d.ts +2 -1
- package/dist-server/templates/invitation-email.js +1 -1
- package/dist-server/templates/invitation-email.js.map +1 -1
- package/dist-server/templates/verification-email.d.ts +2 -1
- package/dist-server/templates/verification-email.js +1 -1
- package/dist-server/templates/verification-email.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/types.d.ts +1 -1
- package/dist-server/types.js.map +1 -1
- package/dist-server/utils/access-token-cookie.js +2 -2
- package/dist-server/utils/access-token-cookie.js.map +1 -1
- package/dist-server/utils/check-permission.d.ts +2 -2
- package/dist-server/utils/check-permission.js +3 -3
- package/dist-server/utils/check-permission.js.map +1 -1
- package/dist-server/utils/check-user-belongs-domain.d.ts +1 -1
- package/dist-server/utils/check-user-belongs-domain.js +2 -2
- package/dist-server/utils/check-user-belongs-domain.js.map +1 -1
- package/dist-server/utils/check-user-has-role.d.ts +1 -1
- package/dist-server/utils/check-user-has-role.js +2 -2
- package/dist-server/utils/check-user-has-role.js.map +1 -1
- package/dist-server/utils/get-domain-users.d.ts +1 -1
- package/dist-server/utils/get-domain-users.js +2 -2
- package/dist-server/utils/get-domain-users.js.map +1 -1
- package/dist-server/utils/get-user-domains.d.ts +1 -1
- package/dist-server/utils/get-user-domains.js +4 -4
- package/dist-server/utils/get-user-domains.js.map +1 -1
- package/helps/config/recaptcha.ja.md +49 -0
- package/helps/config/recaptcha.ko.md +49 -0
- package/helps/config/recaptcha.md +49 -0
- package/helps/config/recaptcha.ms.md +49 -0
- package/helps/config/recaptcha.zh.md +49 -0
- package/package.json +10 -9
- package/translations/en.json +5 -1
- package/translations/ja.json +5 -1
- package/translations/ko.json +6 -3
- package/translations/ms.json +5 -1
- package/translations/zh.json +5 -1
- package/client/actions/auth.ts +0 -24
- package/client/auth.ts +0 -272
- package/client/bootstrap.ts +0 -47
- package/client/directive/privileged.ts +0 -28
- package/client/index.ts +0 -3
- package/client/profiled.ts +0 -83
- package/client/reducers/auth.ts +0 -31
- package/server/constants/error-code.ts +0 -20
- package/server/constants/error-message.ts +0 -0
- package/server/constants/max-age.ts +0 -1
- package/server/controllers/auth.ts +0 -5
- package/server/controllers/change-pwd.ts +0 -99
- package/server/controllers/checkin.ts +0 -21
- package/server/controllers/delete-user.ts +0 -68
- package/server/controllers/invitation.ts +0 -132
- package/server/controllers/profile.ts +0 -28
- package/server/controllers/reset-password.ts +0 -126
- package/server/controllers/signin.ts +0 -79
- package/server/controllers/signup.ts +0 -60
- package/server/controllers/unlock-user.ts +0 -61
- package/server/controllers/utils/make-invitation-token.ts +0 -5
- package/server/controllers/utils/make-verification-token.ts +0 -4
- package/server/controllers/utils/password-rule.ts +0 -120
- package/server/controllers/utils/save-invitation-token.ts +0 -10
- package/server/controllers/utils/save-verification-token.ts +0 -12
- package/server/controllers/verification.ts +0 -83
- package/server/errors/auth-error.ts +0 -24
- package/server/errors/index.ts +0 -2
- package/server/errors/user-domain-not-match-error.ts +0 -29
- package/server/index.ts +0 -37
- package/server/middlewares/authenticate-401-middleware.ts +0 -114
- package/server/middlewares/domain-authenticate-middleware.ts +0 -78
- package/server/middlewares/graphql-authenticate-middleware.ts +0 -13
- package/server/middlewares/index.ts +0 -67
- package/server/middlewares/jwt-authenticate-middleware.ts +0 -84
- package/server/middlewares/signin-middleware.ts +0 -55
- package/server/middlewares/webauthn-middleware.ts +0 -127
- package/server/migrations/1548206416130-SeedUser.ts +0 -59
- package/server/migrations/1566805283882-SeedPrivilege.ts +0 -28
- package/server/migrations/index.ts +0 -9
- package/server/router/auth-checkin-router.ts +0 -107
- package/server/router/auth-private-process-router.ts +0 -107
- package/server/router/auth-public-process-router.ts +0 -302
- package/server/router/auth-signin-router.ts +0 -65
- package/server/router/auth-signup-router.ts +0 -95
- package/server/router/index.ts +0 -9
- package/server/router/oauth2/index.ts +0 -2
- package/server/router/oauth2/oauth2-authorize-router.ts +0 -81
- package/server/router/oauth2/oauth2-router.ts +0 -165
- package/server/router/oauth2/oauth2-server.ts +0 -262
- package/server/router/oauth2/passport-oauth2-client-password.ts +0 -87
- package/server/router/oauth2/passport-refresh-token.ts +0 -87
- package/server/router/path-base-domain-router.ts +0 -8
- package/server/router/site-root-router.ts +0 -48
- package/server/router/webauthn-router.ts +0 -87
- package/server/routes.ts +0 -80
- package/server/service/app-binding/app-binding-mutation.ts +0 -22
- package/server/service/app-binding/app-binding-query.ts +0 -92
- package/server/service/app-binding/app-binding-types.ts +0 -11
- package/server/service/app-binding/app-binding.ts +0 -17
- package/server/service/app-binding/index.ts +0 -4
- package/server/service/appliance/appliance-mutation.ts +0 -113
- package/server/service/appliance/appliance-query.ts +0 -76
- package/server/service/appliance/appliance-types.ts +0 -56
- package/server/service/appliance/appliance.ts +0 -133
- package/server/service/appliance/index.ts +0 -6
- package/server/service/application/application-mutation.ts +0 -104
- package/server/service/application/application-query.ts +0 -98
- package/server/service/application/application-types.ts +0 -76
- package/server/service/application/application.ts +0 -216
- package/server/service/application/index.ts +0 -6
- package/server/service/auth-provider/auth-provider-mutation.ts +0 -159
- package/server/service/auth-provider/auth-provider-parameter-spec.ts +0 -24
- package/server/service/auth-provider/auth-provider-query.ts +0 -88
- package/server/service/auth-provider/auth-provider-type.ts +0 -67
- package/server/service/auth-provider/auth-provider.ts +0 -155
- package/server/service/auth-provider/index.ts +0 -7
- package/server/service/domain-generator/domain-generator-mutation.ts +0 -117
- package/server/service/domain-generator/domain-generator-types.ts +0 -46
- package/server/service/domain-generator/index.ts +0 -3
- package/server/service/granted-role/granted-role-mutation.ts +0 -156
- package/server/service/granted-role/granted-role-query.ts +0 -60
- package/server/service/granted-role/granted-role.ts +0 -27
- package/server/service/granted-role/index.ts +0 -6
- package/server/service/index.ts +0 -90
- package/server/service/invitation/index.ts +0 -6
- package/server/service/invitation/invitation-mutation.ts +0 -63
- package/server/service/invitation/invitation-query.ts +0 -33
- package/server/service/invitation/invitation-types.ts +0 -11
- package/server/service/invitation/invitation.ts +0 -63
- package/server/service/login-history/index.ts +0 -5
- package/server/service/login-history/login-history-query.ts +0 -51
- package/server/service/login-history/login-history-type.ts +0 -12
- package/server/service/login-history/login-history.ts +0 -45
- package/server/service/partner/index.ts +0 -6
- package/server/service/partner/partner-mutation.ts +0 -61
- package/server/service/partner/partner-query.ts +0 -102
- package/server/service/partner/partner-types.ts +0 -11
- package/server/service/partner/partner.ts +0 -57
- package/server/service/password-history/index.ts +0 -3
- package/server/service/password-history/password-history.ts +0 -16
- package/server/service/privilege/index.ts +0 -6
- package/server/service/privilege/privilege-directive.ts +0 -77
- package/server/service/privilege/privilege-mutation.ts +0 -92
- package/server/service/privilege/privilege-query.ts +0 -94
- package/server/service/privilege/privilege-types.ts +0 -60
- package/server/service/privilege/privilege.ts +0 -102
- package/server/service/role/index.ts +0 -6
- package/server/service/role/role-mutation.ts +0 -109
- package/server/service/role/role-query.ts +0 -155
- package/server/service/role/role-types.ts +0 -81
- package/server/service/role/role.ts +0 -72
- package/server/service/user/domain-query.ts +0 -24
- package/server/service/user/index.ts +0 -7
- package/server/service/user/user-mutation.ts +0 -413
- package/server/service/user/user-query.ts +0 -145
- package/server/service/user/user-types.ts +0 -97
- package/server/service/user/user.ts +0 -354
- package/server/service/users-auth-providers/index.ts +0 -5
- package/server/service/users-auth-providers/users-auth-providers.ts +0 -71
- package/server/service/verification-token/index.ts +0 -3
- package/server/service/verification-token/verification-token.ts +0 -60
- package/server/service/web-auth-credential/index.ts +0 -3
- package/server/service/web-auth-credential/web-auth-credential.ts +0 -67
- package/server/templates/account-unlock-email.ts +0 -65
- package/server/templates/invitation-email.ts +0 -66
- package/server/templates/reset-password-email.ts +0 -65
- package/server/templates/verification-email.ts +0 -66
- package/server/types.ts +0 -21
- package/server/utils/accepts.ts +0 -11
- package/server/utils/access-token-cookie.ts +0 -61
- package/server/utils/check-permission.ts +0 -52
- package/server/utils/check-user-belongs-domain.ts +0 -19
- package/server/utils/check-user-has-role.ts +0 -29
- package/server/utils/encrypt-state.ts +0 -22
- package/server/utils/get-aes-256-key.ts +0 -13
- package/server/utils/get-domain-from-hostname.ts +0 -7
- package/server/utils/get-domain-users.ts +0 -38
- package/server/utils/get-secret.ts +0 -13
- package/server/utils/get-user-domains.ts +0 -112
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"appliance-mutation.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAEtE,iDAAqD;AAErD,
|
1
|
+
{"version":3,"file":"appliance-mutation.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAEtE,iDAAqD;AAErD,6CAAkD;AAClD,iDAA0C;AAC1C,6DAAmE;AAEnE,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAGzB,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAGtB,AAAN,KAAK,CAAC,eAAe,CACD,SAAuB,EAClC,OAAwB;QAE/B,OAAO,MAAM,IAAA,qBAAa,EAAC,wBAAS,CAAC,CAAC,IAAI,iBACxC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAC5B,OAAO,EAAE,OAAO,CAAC,KA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IAAA,kBAAG,GAAE,CAAA;;;;gEAyC1D;AAIK;IAFL,IAAA,wBAAS,EAAC,+EAA+E,CAAC;IAC1F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,wBAAS,CAAC;IAE5B,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;qDADe,mCAAc;;wDAoBpC;4BApGU,iBAAiB;IAD7B,IAAA,uBAAQ,EAAC,wBAAS,CAAC;GACP,iBAAiB,CAqG7B","sourcesContent":["import { Directive, Arg, Ctx, Mutation, Resolver } from 'type-graphql'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { User, UserStatus } from '../user/user.js'\nimport { Appliance } from './appliance.js'\nimport { AppliancePatch, NewAppliance } from './appliance-types.js'\n\nconst crypto = require('crypto')\n\n@Resolver(Appliance)\nexport class ApplianceMutation {\n @Directive('@privilege(category: \"user\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Appliance, { description: 'To create new appliance' })\n async createAppliance(\n @Arg('appliance') appliance: NewAppliance,\n @Ctx() context: ResolverContext\n ): Promise<Appliance> {\n return await getRepository(Appliance).save({\n domain: context.state.domain,\n creator: context.state.user,\n updater: context.state.user,\n ...appliance\n })\n }\n\n @Directive('@privilege(category: \"user\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete appliance' })\n async deleteAppliance(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n const { domain } = context.state\n // TODO 이 사용자가 이 도메인에 속한 사용자인지 확인해야함.\n // TODO 다른 도메인에도 포함되어있다면, domains-users 관게와 해당 도메인 관련 정보만 삭제해야 함.\n await getRepository(User).delete({\n reference: id,\n userType: 'appliance'\n })\n\n await getRepository(Appliance).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@privilege(category: \"security\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Appliance)\n async generateApplianceSecret(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Appliance> {\n const { domain, user } = context.state\n\n const appliance: Appliance = await getRepository(Appliance).findOneBy({ domain: { id: domain.id }, id })\n\n const appuserEmail = `${crypto.randomUUID()}@${domain?.subdomain}`\n let appuser: User = await getRepository(User).findOne({\n where: {\n reference: id,\n userType: 'appliance'\n },\n relations: ['domains']\n })\n\n if (!appuser) {\n /* newly create appuser */\n appuser = await getRepository(User).save({\n email: appuserEmail,\n name: appliance.name,\n userType: 'appliance',\n reference: id,\n status: UserStatus.ACTIVATED,\n domains: [domain],\n updater: user,\n creator: user\n })\n }\n\n if (!appuser.domains.find(d => d.id === domain.id)) {\n context.throw(401, 'appliance is not allowed for this domain')\n }\n\n appuser.password = Appliance.generateAccessToken(domain, appuser, appliance)\n\n await getRepository(User).save(appuser)\n\n return await getRepository(Appliance).save({\n ...appliance,\n accessToken: appuser.password,\n updater: user\n })\n }\n\n @Directive('@privilege(category: \"user\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Appliance)\n async updateAppliance(\n @Arg('id') id: string,\n @Arg('patch') patch: AppliancePatch,\n @Ctx() context: ResolverContext\n ): Promise<Appliance> {\n const { domain } = context.state\n\n const applianceRepository = getRepository(Appliance)\n const userRepository = getRepository(User)\n const appliance = await applianceRepository.findOne({ where: { domain: { id: domain.id }, id } })\n const user = await userRepository.findOne({ where: { reference: id, userType: 'appliance' } })\n\n userRepository.save({\n ...user,\n name: patch?.name || user.name\n })\n\n return await applianceRepository.save({\n ...appliance,\n ...patch,\n updater: context.state.user\n })\n }\n}\n"]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Domain, ListParam } from '@things-factory/shell';
|
2
|
-
import { Appliance } from '../appliance/appliance';
|
3
|
-
import { User } from '../user/user';
|
4
|
-
import { ApplianceList } from './appliance-types';
|
2
|
+
import { Appliance } from '../appliance/appliance.js';
|
3
|
+
import { User } from '../user/user.js';
|
4
|
+
import { ApplianceList } from './appliance-types.js';
|
5
5
|
export declare class ApplianceQuery {
|
6
6
|
appliance(id: string, context: ResolverContext): Promise<Appliance>;
|
7
7
|
appliances(params: ListParam, context: ResolverContext): Promise<ApplianceList>;
|
@@ -4,20 +4,20 @@ exports.ApplianceQuery = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
6
6
|
const shell_1 = require("@things-factory/shell");
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
7
|
+
const appliance_js_1 = require("../appliance/appliance.js");
|
8
|
+
const user_js_1 = require("../user/user.js");
|
9
|
+
const appliance_types_js_1 = require("./appliance-types.js");
|
10
10
|
let ApplianceQuery = class ApplianceQuery {
|
11
11
|
async appliance(id, context) {
|
12
12
|
const { domain } = context.state;
|
13
|
-
return await (0, shell_1.getRepository)(
|
13
|
+
return await (0, shell_1.getRepository)(appliance_js_1.Appliance).findOneBy({ domain: { id: domain.id }, id });
|
14
14
|
}
|
15
15
|
async appliances(params, context) {
|
16
16
|
const { domain } = context.state;
|
17
17
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
18
18
|
domain,
|
19
19
|
params,
|
20
|
-
repository: (0, shell_1.getRepository)(
|
20
|
+
repository: (0, shell_1.getRepository)(appliance_js_1.Appliance),
|
21
21
|
alias: 'appliance',
|
22
22
|
searchables: ['name', 'description']
|
23
23
|
});
|
@@ -29,7 +29,7 @@ let ApplianceQuery = class ApplianceQuery {
|
|
29
29
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
30
30
|
domain,
|
31
31
|
params,
|
32
|
-
repository: (0, shell_1.getRepository)(
|
32
|
+
repository: (0, shell_1.getRepository)(appliance_js_1.Appliance),
|
33
33
|
alias: 'appliance',
|
34
34
|
searchables: ['name', 'description']
|
35
35
|
});
|
@@ -43,16 +43,16 @@ let ApplianceQuery = class ApplianceQuery {
|
|
43
43
|
return context.state.domain;
|
44
44
|
}
|
45
45
|
async updater(appliance) {
|
46
|
-
return await (0, shell_1.getRepository)(
|
46
|
+
return await (0, shell_1.getRepository)(user_js_1.User).findOneBy({ id: appliance.updaterId });
|
47
47
|
}
|
48
48
|
async creator(appliance) {
|
49
|
-
return await (0, shell_1.getRepository)(
|
49
|
+
return await (0, shell_1.getRepository)(user_js_1.User).findOneBy({ id: appliance.creatorId });
|
50
50
|
}
|
51
51
|
};
|
52
52
|
exports.ApplianceQuery = ApplianceQuery;
|
53
53
|
tslib_1.__decorate([
|
54
54
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
|
55
|
-
(0, type_graphql_1.Query)(returns =>
|
55
|
+
(0, type_graphql_1.Query)(returns => appliance_js_1.Appliance, { description: ' To fetch appliance' }),
|
56
56
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
57
57
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
58
58
|
tslib_1.__metadata("design:type", Function),
|
@@ -61,7 +61,7 @@ tslib_1.__decorate([
|
|
61
61
|
], ApplianceQuery.prototype, "appliance", null);
|
62
62
|
tslib_1.__decorate([
|
63
63
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
|
64
|
-
(0, type_graphql_1.Query)(returns =>
|
64
|
+
(0, type_graphql_1.Query)(returns => appliance_types_js_1.ApplianceList, { description: 'To fetch multiple appliance' }),
|
65
65
|
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
66
66
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
67
67
|
tslib_1.__metadata("design:type", Function),
|
@@ -70,7 +70,7 @@ tslib_1.__decorate([
|
|
70
70
|
], ApplianceQuery.prototype, "appliances", null);
|
71
71
|
tslib_1.__decorate([
|
72
72
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
|
73
|
-
(0, type_graphql_1.Query)(returns =>
|
73
|
+
(0, type_graphql_1.Query)(returns => appliance_types_js_1.ApplianceList, { description: 'To fetch multiple appliance' }),
|
74
74
|
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
75
75
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
76
76
|
tslib_1.__metadata("design:type", Function),
|
@@ -82,7 +82,7 @@ tslib_1.__decorate([
|
|
82
82
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
83
83
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
84
84
|
tslib_1.__metadata("design:type", Function),
|
85
|
-
tslib_1.__metadata("design:paramtypes", [
|
85
|
+
tslib_1.__metadata("design:paramtypes", [appliance_js_1.Appliance, Object]),
|
86
86
|
tslib_1.__metadata("design:returntype", Promise)
|
87
87
|
], ApplianceQuery.prototype, "accessToken", null);
|
88
88
|
tslib_1.__decorate([
|
@@ -93,20 +93,20 @@ tslib_1.__decorate([
|
|
93
93
|
tslib_1.__metadata("design:returntype", Promise)
|
94
94
|
], ApplianceQuery.prototype, "domain", null);
|
95
95
|
tslib_1.__decorate([
|
96
|
-
(0, type_graphql_1.FieldResolver)(type =>
|
96
|
+
(0, type_graphql_1.FieldResolver)(type => user_js_1.User),
|
97
97
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
98
98
|
tslib_1.__metadata("design:type", Function),
|
99
|
-
tslib_1.__metadata("design:paramtypes", [
|
99
|
+
tslib_1.__metadata("design:paramtypes", [appliance_js_1.Appliance]),
|
100
100
|
tslib_1.__metadata("design:returntype", Promise)
|
101
101
|
], ApplianceQuery.prototype, "updater", null);
|
102
102
|
tslib_1.__decorate([
|
103
|
-
(0, type_graphql_1.FieldResolver)(type =>
|
103
|
+
(0, type_graphql_1.FieldResolver)(type => user_js_1.User),
|
104
104
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
105
105
|
tslib_1.__metadata("design:type", Function),
|
106
|
-
tslib_1.__metadata("design:paramtypes", [
|
106
|
+
tslib_1.__metadata("design:paramtypes", [appliance_js_1.Appliance]),
|
107
107
|
tslib_1.__metadata("design:returntype", Promise)
|
108
108
|
], ApplianceQuery.prototype, "creator", null);
|
109
109
|
exports.ApplianceQuery = ApplianceQuery = tslib_1.__decorate([
|
110
|
-
(0, type_graphql_1.Resolver)(
|
110
|
+
(0, type_graphql_1.Resolver)(appliance_js_1.Appliance)
|
111
111
|
], ApplianceQuery);
|
112
112
|
//# sourceMappingURL=appliance-query.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"appliance-query.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,iDAAuG;AAEvG,
|
1
|
+
{"version":3,"file":"appliance-query.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,iDAAuG;AAEvG,4DAAqD;AACrD,6CAAsC;AACtC,6DAAoD;AAG7C,IAAM,cAAc,GAApB,MAAM,cAAc;IAGnB,AAAN,KAAK,CAAC,SAAS,CAAY,EAAU,EAAS,OAAwB;QACpE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,OAAO,MAAM,IAAA,qBAAa,EAAC,wBAAS,CAAC,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IACpF,CAAC;IAIK,AAAN,KAAK,CAAC,UAAU,CACW,MAAiB,EACnC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,MAAM;YACN,UAAU,EAAE,IAAA,qBAAa,EAAC,wBAAS,CAAC;YACpC,KA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AAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,wBAAS;;6CAEzC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,wBAAS;;6CAEzC;yBAjEU,cAAc;IAD1B,IAAA,uBAAQ,EAAC,wBAAS,CAAC;GACP,cAAc,CAkE1B","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { getQueryBuilderFromListParams, Domain, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Appliance } from '../appliance/appliance.js'\nimport { User } from '../user/user.js'\nimport { ApplianceList } from './appliance-types.js'\n\n@Resolver(Appliance)\nexport class ApplianceQuery {\n @Directive('@privilege(category: \"user\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => Appliance, { description: ' To fetch appliance' })\n async appliance(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Appliance> {\n const { domain } = context.state\n return await getRepository(Appliance).findOneBy({ domain: { id: domain.id }, id })\n }\n\n @Directive('@privilege(category: \"user\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ApplianceList, { description: 'To fetch multiple appliance' })\n async appliances(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ApplianceList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: getRepository(Appliance),\n alias: 'appliance',\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"user\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ApplianceList, { description: 'To fetch multiple appliance' })\n async edges(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<ApplianceList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: getRepository(Appliance),\n alias: 'appliance',\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => String)\n async accessToken(@Root() appliance: Appliance, @Ctx() context: ResolverContext) {\n return appliance.accessToken\n }\n\n @FieldResolver(type => Domain)\n async domain(@Ctx() context: ResolverContext) {\n return context.state.domain\n }\n\n @FieldResolver(type => User)\n async updater(@Root() appliance: Appliance): Promise<User> {\n return await getRepository(User).findOneBy({ id: appliance.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() appliance: Appliance): Promise<User> {\n return await getRepository(User).findOneBy({ id: appliance.creatorId })\n }\n}\n"]}
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NewAppliance = exports.AppliancePatch = exports.ApplianceList = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
6
|
-
const
|
6
|
+
const appliance_js_1 = require("./appliance.js");
|
7
7
|
let ApplianceList = class ApplianceList {
|
8
8
|
};
|
9
9
|
exports.ApplianceList = ApplianceList;
|
10
10
|
tslib_1.__decorate([
|
11
|
-
(0, type_graphql_1.Field)(type => [
|
11
|
+
(0, type_graphql_1.Field)(type => [appliance_js_1.Appliance], { nullable: true }),
|
12
12
|
tslib_1.__metadata("design:type", Array)
|
13
13
|
], ApplianceList.prototype, "items", void 0);
|
14
14
|
tslib_1.__decorate([
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"appliance-types.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AACpE,
|
1
|
+
{"version":3,"file":"appliance-types.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AACpE,iDAA0C;AAGnC,IAAM,aAAa,GAAnB,MAAM,aAA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K;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACV;uBAjBL,YAAY;IADxB,IAAA,wBAAS,GAAE;GACC,YAAY,CAkBxB","sourcesContent":["import { ObjectType, InputType, Field, ID, Int } from 'type-graphql'\nimport { Appliance } from './appliance.js'\n\n@ObjectType()\nexport class ApplianceList {\n @Field(type => [Appliance], { nullable: true })\n items?: Appliance[]\n\n @Field(type => Int, { nullable: true })\n total?: number\n}\n\n@InputType()\nexport class AppliancePatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field({ nullable: true })\n serialNo?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n brand?: string\n\n @Field({ nullable: true })\n model?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n netmask?: string\n}\n\n@InputType()\nexport class NewAppliance {\n @Field()\n serialNo: string\n\n @Field()\n name: string\n\n @Field()\n brand: string\n\n @Field()\n model: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n netmask?: string\n}\n"]}
|
@@ -4,10 +4,10 @@ exports.Appliance = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const typeorm_1 = require("typeorm");
|
6
6
|
const type_graphql_1 = require("type-graphql");
|
7
|
-
const user_1 = require("../user/user");
|
8
7
|
const shell_1 = require("@things-factory/shell");
|
9
|
-
const get_secret_1 = require("../../utils/get-secret");
|
10
8
|
const env_1 = require("@things-factory/env");
|
9
|
+
const user_js_1 = require("../user/user.js");
|
10
|
+
const get_secret_js_1 = require("../../utils/get-secret.js");
|
11
11
|
const jsonwebtoken_1 = tslib_1.__importDefault(require("jsonwebtoken"));
|
12
12
|
const ORMCONFIG = env_1.config.get('ormconfig', {});
|
13
13
|
const DATABASE_TYPE = ORMCONFIG.type;
|
@@ -20,12 +20,12 @@ let Appliance = class Appliance {
|
|
20
20
|
appliance: {
|
21
21
|
id: appliance.id
|
22
22
|
},
|
23
|
-
status:
|
23
|
+
status: user_js_1.UserStatus.ACTIVATED,
|
24
24
|
domain: {
|
25
25
|
subdomain: domain.subdomain
|
26
26
|
}
|
27
27
|
};
|
28
|
-
return jsonwebtoken_1.default.sign(credential,
|
28
|
+
return jsonwebtoken_1.default.sign(credential, get_secret_js_1.SECRET, {
|
29
29
|
expiresIn,
|
30
30
|
issuer: 'hatiolab.com',
|
31
31
|
subject
|
@@ -105,18 +105,18 @@ tslib_1.__decorate([
|
|
105
105
|
tslib_1.__metadata("design:type", String)
|
106
106
|
], Appliance.prototype, "accessToken", void 0);
|
107
107
|
tslib_1.__decorate([
|
108
|
-
(0, typeorm_1.ManyToOne)(type =>
|
108
|
+
(0, typeorm_1.ManyToOne)(type => user_js_1.User, { nullable: true }),
|
109
109
|
(0, type_graphql_1.Field)({ nullable: true }),
|
110
|
-
tslib_1.__metadata("design:type",
|
110
|
+
tslib_1.__metadata("design:type", user_js_1.User)
|
111
111
|
], Appliance.prototype, "creator", void 0);
|
112
112
|
tslib_1.__decorate([
|
113
113
|
(0, typeorm_1.RelationId)((appliance) => appliance.creator),
|
114
114
|
tslib_1.__metadata("design:type", String)
|
115
115
|
], Appliance.prototype, "creatorId", void 0);
|
116
116
|
tslib_1.__decorate([
|
117
|
-
(0, typeorm_1.ManyToOne)(type =>
|
117
|
+
(0, typeorm_1.ManyToOne)(type => user_js_1.User, { nullable: true }),
|
118
118
|
(0, type_graphql_1.Field)({ nullable: true }),
|
119
|
-
tslib_1.__metadata("design:type",
|
119
|
+
tslib_1.__metadata("design:type", user_js_1.User)
|
120
120
|
], Appliance.prototype, "updater", void 0);
|
121
121
|
tslib_1.__decorate([
|
122
122
|
(0, typeorm_1.RelationId)((appliance) => appliance.updater),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"appliance.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance.ts"],"names":[],"mappings":";;;;AAAA,qCASgB;AAChB,+CAA+D;AAC/D,
|
1
|
+
{"version":3,"file":"appliance.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance.ts"],"names":[],"mappings":";;;;AAAA,qCASgB;AAChB,+CAA+D;AAC/D,iDAA8C;AAC9C,6CAA4C;AAE5C,6CAAkD;AAClD,6DAAkD;AAClD,wEAA8B;AAE9B,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAO7B,IAAM,SAAS,GAAf,MAAM,SAAS;IAgFpB,8BAA8B;IAC9B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS;QACrD,IAAI,UAAU,GAAG;YACf,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,WAAW;YACrB,SAAS,EAAE;gBACT,EAAE,EAAE,SAAS,CAAC,EAAE;aACjB;YACD,MAAM,EAAE,oBAAU,CAAC,SAAS;YAC5B,MAAM,EAAE;gBACN,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B;SACF,CAAA;QAED,OAAO,sBAAG,CAAC,IAAI,CAAC,UAAU,EAAE,sBAAM,EAAE;YAClC,SAAS;YACT,MAAM,EAAE,cAAc;YACtB,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS;QAChD,uDAAuD;QACvD,IAAI,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAA;QACzD,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;IACtE,CAAC;CACF,CAAA;AA1GY,8BAAS;AAGX;IAFR,IAAA,gCAAsB,EAAC,MAA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AE;QACrF,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,yBAAU,GAAE;GACA,SAAS,CA0GrB","sourcesContent":["import {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\nimport { Directive, Field, ID, ObjectType } from 'type-graphql'\nimport { Domain } from '@things-factory/shell'\nimport { config } from '@things-factory/env'\n\nimport { User, UserStatus } from '../user/user.js'\nimport { SECRET } from '../../utils/get-secret.js'\nimport jwt from 'jsonwebtoken'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\n@Entity()\n@Index('ix_appliance_0', (appliance: Appliance) => [appliance.domain, appliance.name], {\n unique: true\n})\n@ObjectType()\nexport class Appliance {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain?: Domain\n\n @RelationId((appliance: Appliance) => appliance.domain)\n domainId: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n serialNo: string\n\n @Column()\n @Field()\n name: string\n\n @Column()\n @Field({ nullable: true })\n brand: string\n\n @Column()\n @Field({ nullable: true })\n model: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n netmask: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description: string\n\n @Column({\n nullable: true,\n type:\n DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'longtext'\n : DATABASE_TYPE == 'oracle'\n ? 'clob'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined\n })\n @Field({ nullable: true })\n @Directive('@privilege(category: \"security\", privilege: \"query\", domainOwnerGranted: true)')\n accessToken: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n creator: User\n\n @RelationId((appliance: Appliance) => appliance.creator)\n creatorId: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n updater: User\n\n @RelationId((appliance: Appliance) => appliance.updater)\n updaterId: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n\n /* signing for jsonwebtoken */\n static sign(subject, expiresIn, domain, user, appliance) {\n var credential = {\n id: user.id,\n userType: 'appliance',\n appliance: {\n id: appliance.id\n },\n status: UserStatus.ACTIVATED,\n domain: {\n subdomain: domain.subdomain\n }\n }\n\n return jwt.sign(credential, SECRET, {\n expiresIn,\n issuer: 'hatiolab.com',\n subject\n })\n }\n\n static generateAccessToken(domain, user, appliance) {\n /* how to set expiresIn https://github.com/vercel/ms */\n let expiresIn = config.get('applianceJwtExpiresIn', '1y')\n return this.sign('access-token', expiresIn, domain, user, appliance)\n }\n}\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Appliance } from './appliance';
|
2
|
-
import { ApplianceQuery } from './appliance-query';
|
3
|
-
import { ApplianceMutation } from './appliance-mutation';
|
1
|
+
import { Appliance } from './appliance.js';
|
2
|
+
import { ApplianceQuery } from './appliance-query.js';
|
3
|
+
import { ApplianceMutation } from './appliance-mutation.js';
|
4
4
|
export declare const entities: (typeof Appliance)[];
|
5
5
|
export declare const resolvers: (typeof ApplianceQuery | typeof ApplianceMutation)[];
|
@@ -1,9 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.resolvers = exports.entities = void 0;
|
4
|
-
const
|
5
|
-
const
|
6
|
-
const
|
7
|
-
exports.entities = [
|
8
|
-
exports.resolvers = [
|
4
|
+
const appliance_js_1 = require("./appliance.js");
|
5
|
+
const appliance_query_js_1 = require("./appliance-query.js");
|
6
|
+
const appliance_mutation_js_1 = require("./appliance-mutation.js");
|
7
|
+
exports.entities = [appliance_js_1.Appliance];
|
8
|
+
exports.resolvers = [appliance_query_js_1.ApplianceQuery, appliance_mutation_js_1.ApplianceMutation];
|
9
9
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/appliance/index.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/appliance/index.ts"],"names":[],"mappings":";;;AAAA,iDAA0C;AAC1C,6DAAqD;AACrD,mEAA2D;AAE9C,QAAA,QAAQ,GAAG,CAAC,wBAAS,CAAC,CAAA;AACtB,QAAA,SAAS,GAAG,CAAC,mCAAc,EAAE,yCAAiB,CAAC,CAAA","sourcesContent":["import { Appliance } from './appliance.js'\nimport { ApplianceQuery } from './appliance-query.js'\nimport { ApplianceMutation } from './appliance-mutation.js'\n\nexport const entities = [Appliance]\nexport const resolvers = [ApplianceQuery, ApplianceMutation]\n"]}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { User } from '../user/user';
|
2
|
-
import { Application } from './application';
|
3
|
-
import { ApplicationPatch, NewApplication } from './application-types';
|
1
|
+
import { User } from '../user/user.js';
|
2
|
+
import { Application } from './application.js';
|
3
|
+
import { ApplicationPatch, NewApplication } from './application-types.js';
|
4
4
|
export declare class ApplicationMutation {
|
5
5
|
createApplication(application: NewApplication, context: ResolverContext): Promise<{
|
6
6
|
domain: import("@things-factory/shell").Domain;
|
@@ -15,7 +15,7 @@ export declare class ApplicationMutation {
|
|
15
15
|
icon?: string;
|
16
16
|
redirectUrl?: string;
|
17
17
|
webhook?: string;
|
18
|
-
type?: import("./application").ApplicationType;
|
18
|
+
type?: import("./application.js").ApplicationType;
|
19
19
|
} & Application>;
|
20
20
|
deleteApplication(id: string, context: ResolverContext): Promise<boolean>;
|
21
21
|
generateApplicationSecret(id: string, context: ResolverContext): Promise<{
|
@@ -32,8 +32,8 @@ export declare class ApplicationMutation {
|
|
32
32
|
redirectUrl?: string;
|
33
33
|
webhook?: string;
|
34
34
|
appKey?: string;
|
35
|
-
status?: import("./application").ApplicationStatus;
|
36
|
-
type?: import("./application").ApplicationType;
|
35
|
+
status?: import("./application.js").ApplicationStatus;
|
36
|
+
type?: import("./application.js").ApplicationType;
|
37
37
|
createdAt?: Date;
|
38
38
|
updatedAt?: Date;
|
39
39
|
creator?: User;
|
@@ -53,13 +53,13 @@ export declare class ApplicationMutation {
|
|
53
53
|
icon?: string;
|
54
54
|
redirectUrl?: string;
|
55
55
|
webhook?: string;
|
56
|
-
type?: import("./application").ApplicationType;
|
56
|
+
type?: import("./application.js").ApplicationType;
|
57
57
|
id?: string;
|
58
58
|
domain?: import("@things-factory/shell").Domain;
|
59
59
|
domainId?: string;
|
60
60
|
appKey?: string;
|
61
61
|
appSecret?: string;
|
62
|
-
status?: import("./application").ApplicationStatus;
|
62
|
+
status?: import("./application.js").ApplicationStatus;
|
63
63
|
createdAt?: Date;
|
64
64
|
updatedAt?: Date;
|
65
65
|
creator?: User;
|
@@ -4,17 +4,17 @@ exports.ApplicationMutation = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
6
6
|
const shell_1 = require("@things-factory/shell");
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
7
|
+
const user_js_1 = require("../user/user.js");
|
8
|
+
const application_js_1 = require("./application.js");
|
9
|
+
const application_types_js_1 = require("./application-types.js");
|
10
10
|
let ApplicationMutation = class ApplicationMutation {
|
11
11
|
async createApplication(application, context) {
|
12
12
|
const { domain } = context.state;
|
13
|
-
return await (0, shell_1.getRepository)(
|
13
|
+
return await (0, shell_1.getRepository)(application_js_1.Application).save(Object.assign(Object.assign({}, application), { domain, appKey: application_js_1.Application.generateAppKey(), appSecret: application_js_1.Application.generateAppSecret(), creator: context.state.user, updater: context.state.user }));
|
14
14
|
}
|
15
15
|
async deleteApplication(id, context) {
|
16
16
|
const { domain } = context.state;
|
17
|
-
await (0, shell_1.getRepository)(
|
17
|
+
await (0, shell_1.getRepository)(application_js_1.Application).delete({
|
18
18
|
domain: { id: domain.id },
|
19
19
|
id
|
20
20
|
});
|
@@ -22,34 +22,34 @@ let ApplicationMutation = class ApplicationMutation {
|
|
22
22
|
}
|
23
23
|
async generateApplicationSecret(id, context) {
|
24
24
|
const { domain } = context.state;
|
25
|
-
const repository = (0, shell_1.getRepository)(
|
25
|
+
const repository = (0, shell_1.getRepository)(application_js_1.Application);
|
26
26
|
const application = await repository.findOneBy({ domain: { id: domain.id }, id });
|
27
|
-
return await repository.save(Object.assign(Object.assign({}, application), { appSecret:
|
27
|
+
return await repository.save(Object.assign(Object.assign({}, application), { appSecret: application_js_1.Application.generateAppSecret(), updater: context.state.user }));
|
28
28
|
}
|
29
29
|
async renewApplicationAccessToken(id, context, scope) {
|
30
30
|
const { domain } = context.state;
|
31
|
-
var appuser = await (0, shell_1.getRepository)(
|
31
|
+
var appuser = await (0, shell_1.getRepository)(user_js_1.User).findOneBy({
|
32
32
|
id,
|
33
33
|
userType: 'application'
|
34
34
|
});
|
35
35
|
if (!appuser) {
|
36
36
|
throw new Error('application is not bound');
|
37
37
|
}
|
38
|
-
const repository = (0, shell_1.getRepository)(
|
38
|
+
const repository = (0, shell_1.getRepository)(application_js_1.Application);
|
39
39
|
const application = await repository.findOneBy({ id: appuser.reference });
|
40
40
|
if (!application) {
|
41
41
|
throw new Error('application not found');
|
42
42
|
}
|
43
|
-
var accessToken =
|
44
|
-
var refreshToken =
|
45
|
-
await (0, shell_1.getRepository)(
|
43
|
+
var accessToken = application_js_1.Application.generateAccessToken(domain, appuser, application.appSecret, scope || '');
|
44
|
+
var refreshToken = application_js_1.Application.generateRefreshToken(domain, appuser, application.appSecret, scope || '');
|
45
|
+
await (0, shell_1.getRepository)(user_js_1.User).save(Object.assign(Object.assign({}, appuser), { password: refreshToken }));
|
46
46
|
return {
|
47
47
|
accessToken,
|
48
48
|
refreshToken
|
49
49
|
};
|
50
50
|
}
|
51
51
|
async updateApplication(id, patch, context) {
|
52
|
-
const repository = (0, shell_1.getRepository)(
|
52
|
+
const repository = (0, shell_1.getRepository)(application_js_1.Application);
|
53
53
|
const application = await repository.findOneBy({ id });
|
54
54
|
return await repository.save(Object.assign(Object.assign(Object.assign({}, application), patch), { updater: context.state.user }));
|
55
55
|
}
|
@@ -57,11 +57,11 @@ let ApplicationMutation = class ApplicationMutation {
|
|
57
57
|
exports.ApplicationMutation = ApplicationMutation;
|
58
58
|
tslib_1.__decorate([
|
59
59
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)'),
|
60
|
-
(0, type_graphql_1.Mutation)(returns =>
|
60
|
+
(0, type_graphql_1.Mutation)(returns => application_js_1.Application, { description: 'To create new application' }),
|
61
61
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('application')),
|
62
62
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
63
63
|
tslib_1.__metadata("design:type", Function),
|
64
|
-
tslib_1.__metadata("design:paramtypes", [
|
64
|
+
tslib_1.__metadata("design:paramtypes", [application_types_js_1.NewApplication, Object]),
|
65
65
|
tslib_1.__metadata("design:returntype", Promise)
|
66
66
|
], ApplicationMutation.prototype, "createApplication", null);
|
67
67
|
tslib_1.__decorate([
|
@@ -75,7 +75,7 @@ tslib_1.__decorate([
|
|
75
75
|
], ApplicationMutation.prototype, "deleteApplication", null);
|
76
76
|
tslib_1.__decorate([
|
77
77
|
(0, type_graphql_1.Directive)('@privilege(category: "security", privilege: "mutation", domainOwnerGranted: true)'),
|
78
|
-
(0, type_graphql_1.Mutation)(returns =>
|
78
|
+
(0, type_graphql_1.Mutation)(returns => application_js_1.Application),
|
79
79
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
80
80
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
81
81
|
tslib_1.__metadata("design:type", Function),
|
@@ -84,7 +84,7 @@ tslib_1.__decorate([
|
|
84
84
|
], ApplicationMutation.prototype, "generateApplicationSecret", null);
|
85
85
|
tslib_1.__decorate([
|
86
86
|
(0, type_graphql_1.Directive)('@privilege(category: "security", privilege: "mutation", domainOwnerGranted: true)'),
|
87
|
-
(0, type_graphql_1.Mutation)(returns =>
|
87
|
+
(0, type_graphql_1.Mutation)(returns => application_types_js_1.AccessToken),
|
88
88
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
89
89
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
90
90
|
tslib_1.__param(2, (0, type_graphql_1.Arg)('scope')),
|
@@ -94,15 +94,15 @@ tslib_1.__decorate([
|
|
94
94
|
], ApplicationMutation.prototype, "renewApplicationAccessToken", null);
|
95
95
|
tslib_1.__decorate([
|
96
96
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)'),
|
97
|
-
(0, type_graphql_1.Mutation)(returns =>
|
97
|
+
(0, type_graphql_1.Mutation)(returns => application_js_1.Application),
|
98
98
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
99
99
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
100
100
|
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
101
101
|
tslib_1.__metadata("design:type", Function),
|
102
|
-
tslib_1.__metadata("design:paramtypes", [String,
|
102
|
+
tslib_1.__metadata("design:paramtypes", [String, application_types_js_1.ApplicationPatch, Object]),
|
103
103
|
tslib_1.__metadata("design:returntype", Promise)
|
104
104
|
], ApplicationMutation.prototype, "updateApplication", null);
|
105
105
|
exports.ApplicationMutation = ApplicationMutation = tslib_1.__decorate([
|
106
|
-
(0, type_graphql_1.Resolver)(
|
106
|
+
(0, type_graphql_1.Resolver)(application_js_1.Application)
|
107
107
|
], ApplicationMutation);
|
108
108
|
//# sourceMappingURL=application-mutation.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"application-mutation.js","sourceRoot":"","sources":["../../../server/service/application/application-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAEtE,iDAAqD;AAErD,
|
1
|
+
{"version":3,"file":"application-mutation.js","sourceRoot":"","sources":["../../../server/service/application/application-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAEtE,iDAAqD;AAErD,6CAAsC;AACtC,qDAA8C;AAC9C,iEAAsF;AAG/E,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAGxB,AAAN,KAAK,CAAC,iBAAiB,CAAqB,WAA2B,EAAS,OAAwB;QACtG,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,OAAO,MAAM,IAAA,qBAAa,EAAC,4BAAW,CAAC,CAAC,IAAI,iCACvC,WAAW,KACd,MAAM,EACN,MAAM,EAAE,4BAAW,CAAC,cAAc,EAAE,EACpC,SAAS,EAAE,4BAAW,CAAC,iBAAiB,EAAE,EAC1C,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,EAC3B,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC3B,CAAA;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,iBAAiB,CAAY,EAAU,EAAS,OAAwB;QAC5E,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,IAAA,qBAAa,EAAC,4BAAW,CAAC,CAAC,MAAM,CAAC;YACtC,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE;YACzB,EAAE;SACH,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC;IAIK,AAAN,KAAK,CAAC,yBAAyB,CAAY,EAAU,EAAS,OAAwB;QACpF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,4BAAW,CAAC,CAAA;QAC7C,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAA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AW,CAAC;IAE9B,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,mBAAA,IAAA,kBAAG,GAAE,CAAA;IACL,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;;;;sEA+Bd;AAIK;IAFL,IAAA,wBAAS,EAAC,+EAA+E,CAAC;IAC1F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAW,CAAC;IAE9B,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;qDADe,uCAAgB;;4DAWtC;8BA7FU,mBAAmB;IAD/B,IAAA,uBAAQ,EAAC,4BAAW,CAAC;GACT,mBAAmB,CA8F/B","sourcesContent":["import { Directive, Arg, Ctx, Mutation, Resolver } from 'type-graphql'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { User } from '../user/user.js'\nimport { Application } from './application.js'\nimport { AccessToken, ApplicationPatch, NewApplication } from './application-types.js'\n\n@Resolver(Application)\nexport class ApplicationMutation {\n @Directive('@privilege(category: \"user\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Application, { description: 'To create new application' })\n async createApplication(@Arg('application') application: NewApplication, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n return await getRepository(Application).save({\n ...application,\n domain,\n appKey: Application.generateAppKey(),\n appSecret: Application.generateAppSecret(),\n creator: context.state.user,\n updater: context.state.user\n })\n }\n\n @Directive('@privilege(category: \"user\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete application' })\n async deleteApplication(@Arg('id') id: string, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n await getRepository(Application).delete({\n domain: { id: domain.id },\n id\n })\n return true\n }\n\n @Directive('@privilege(category: \"security\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Application)\n async generateApplicationSecret(@Arg('id') id: string, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n const repository = getRepository(Application)\n const application = await repository.findOneBy({ domain: { id: domain.id }, id })\n\n return await repository.save({\n ...application,\n appSecret: Application.generateAppSecret(),\n updater: context.state.user\n })\n }\n\n @Directive('@privilege(category: \"security\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => AccessToken)\n async renewApplicationAccessToken(\n @Arg('id') id: string,\n @Ctx() context: ResolverContext,\n @Arg('scope') scope?: string\n ) {\n const { domain } = context.state\n\n var appuser: User = await getRepository(User).findOneBy({\n id,\n userType: 'application'\n })\n\n if (!appuser) {\n throw new Error('application is not bound')\n }\n\n const repository = getRepository(Application)\n const application = await repository.findOneBy({ id: appuser.reference })\n if (!application) {\n throw new Error('application not found')\n }\n\n var accessToken = Application.generateAccessToken(domain, appuser, application.appSecret, scope || '')\n var refreshToken = Application.generateRefreshToken(domain, appuser, application.appSecret, scope || '')\n\n await getRepository(User).save({\n ...(appuser as any),\n password: refreshToken\n })\n\n return {\n accessToken,\n refreshToken\n }\n }\n\n @Directive('@privilege(category: \"user\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Application)\n async updateApplication(\n @Arg('id') id: string,\n @Arg('patch') patch: ApplicationPatch,\n @Ctx() context: ResolverContext\n ) {\n const repository = getRepository(Application)\n const application = await repository.findOneBy({ id })\n\n return await repository.save({\n ...application,\n ...patch,\n updater: context.state.user\n })\n }\n}\n"]}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Domain, ListParam } from '@things-factory/shell';
|
2
|
-
import { User } from '../user/user';
|
3
|
-
import { Application } from './application';
|
2
|
+
import { User } from '../user/user.js';
|
3
|
+
import { Application } from './application.js';
|
4
4
|
export declare class ApplicationQuery {
|
5
5
|
application(id: string, context: ResolverContext): Promise<Application>;
|
6
6
|
applications(params: ListParam, context: ResolverContext): Promise<{
|