@things-factory/auth-base 9.0.0-beta.5 → 9.0.0-beta.50
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 +46 -0
- package/config/config.production.js +45 -0
- package/dist-client/auth.js +0 -3
- package/dist-client/auth.js.map +1 -1
- 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 -4
- package/dist-client/index.js +4 -4
- 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-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 +19 -19
- 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 +9 -9
- package/dist-server/controllers/delete-user.js.map +1 -1
- package/dist-server/controllers/invitation.js +19 -19
- package/dist-server/controllers/invitation.js.map +1 -1
- package/dist-server/controllers/profile.d.ts +5 -5
- package/dist-server/controllers/profile.js +10 -10
- 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 +1 -1
- package/dist-server/controllers/signin.js +24 -24
- package/dist-server/controllers/signin.js.map +1 -1
- package/dist-server/controllers/signup.d.ts +1 -1
- package/dist-server/controllers/signup.js +13 -13
- package/dist-server/controllers/signup.js.map +1 -1
- package/dist-server/controllers/unlock-user.js +17 -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 +23 -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/bypass-signin-middleware.d.ts +1 -0
- package/dist-server/middlewares/bypass-signin-middleware.js +20 -0
- package/dist-server/middlewares/bypass-signin-middleware.js.map +1 -0
- package/dist-server/middlewares/domain-authenticate-middleware.d.ts +1 -1
- package/dist-server/middlewares/domain-authenticate-middleware.js +9 -13
- 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 +24 -19
- 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 +2 -2
- 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 +7 -7
- package/dist-server/middlewares/webauthn-middleware.js.map +1 -1
- package/dist-server/migrations/1548206416130-SeedUser.js +6 -6
- 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 -17
- package/dist-server/router/auth-checkin-router.js.map +1 -1
- package/dist-server/router/auth-private-process-router.js +27 -19
- package/dist-server/router/auth-private-process-router.js.map +1 -1
- package/dist-server/router/auth-public-process-router.js +24 -24
- package/dist-server/router/auth-public-process-router.js.map +1 -1
- package/dist-server/router/auth-signin-router.js +6 -6
- package/dist-server/router/auth-signin-router.js.map +1 -1
- package/dist-server/router/auth-signup-router.js +11 -8
- 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 +9 -9
- package/dist-server/router/webauthn-router.js.map +1 -1
- package/dist-server/routes.js +77 -51
- 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 +32 -45
- 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 +3 -1
- package/dist-server/service/appliance/appliance.js +51 -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/domain-link/domain-link-mutation.d.ts +9 -0
- package/dist-server/service/domain-link/domain-link-mutation.js +116 -0
- package/dist-server/service/domain-link/domain-link-mutation.js.map +1 -0
- package/dist-server/service/domain-link/domain-link-query.d.ts +11 -0
- package/dist-server/service/domain-link/domain-link-query.js +75 -0
- package/dist-server/service/domain-link/domain-link-query.js.map +1 -0
- package/dist-server/service/domain-link/domain-link-types.d.ts +18 -0
- package/dist-server/service/domain-link/domain-link-types.js +66 -0
- package/dist-server/service/domain-link/domain-link-types.js.map +1 -0
- package/dist-server/service/domain-link/domain-link.d.ts +28 -0
- package/dist-server/service/domain-link/domain-link.js +105 -0
- package/dist-server/service/domain-link/domain-link.js.map +1 -0
- package/dist-server/service/domain-link/index.d.ts +6 -0
- package/dist-server/service/domain-link/index.js +10 -0
- package/dist-server/service/domain-link/index.js.map +1 -0
- 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 +27 -25
- package/dist-server/service/index.js +75 -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 +2 -2
- package/dist-server/service/invitation/invitation-mutation.js +10 -10
- 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 +9 -5
- package/dist-server/service/role/role-query.js +38 -31
- 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 +3 -3
- package/dist-server/service/user/user-mutation.js +42 -42
- package/dist-server/service/user/user-mutation.js.map +1 -1
- package/dist-server/service/user/user-query.d.ts +4 -3
- package/dist-server/service/user/user-query.js +31 -21
- package/dist-server/service/user/user-query.js.map +1 -1
- package/dist-server/service/user/user-types.d.ts +1 -1
- package/dist-server/service/user/user-types.js +2 -2
- package/dist-server/service/user/user-types.js.map +1 -1
- package/dist-server/service/user/user.d.ts +3 -3
- package/dist-server/service/user/user.js +40 -40
- 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/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 -11
- 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/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 +2 -3
- package/dist-server/utils/get-user-domains.js +30 -26
- 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 +7 -6
- package/dist-server/utils/get-domain-from-hostname.d.ts +0 -1
- package/dist-server/utils/get-domain-from-hostname.js +0 -9
- package/dist-server/utils/get-domain-from-hostname.js.map +0 -1
@@ -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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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<{
|
@@ -6,14 +6,14 @@ const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const url_1 = require("url");
|
7
7
|
const env_1 = require("@things-factory/env");
|
8
8
|
const shell_1 = require("@things-factory/shell");
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
9
|
+
const role_js_1 = require("../role/role.js");
|
10
|
+
const user_js_1 = require("../user/user.js");
|
11
|
+
const application_js_1 = require("./application.js");
|
12
|
+
const application_types_js_1 = require("./application-types.js");
|
13
13
|
const protocol = env_1.config.get('protocol');
|
14
14
|
let ApplicationQuery = class ApplicationQuery {
|
15
15
|
async application(id, context) {
|
16
|
-
const repository = (0, shell_1.getRepository)(
|
16
|
+
const repository = (0, shell_1.getRepository)(application_js_1.Application);
|
17
17
|
return await repository.findOneBy({ id });
|
18
18
|
}
|
19
19
|
async applications(params, context) {
|
@@ -21,7 +21,7 @@ let ApplicationQuery = class ApplicationQuery {
|
|
21
21
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
22
22
|
domain,
|
23
23
|
params,
|
24
|
-
repository: (0, shell_1.getRepository)(
|
24
|
+
repository: (0, shell_1.getRepository)(application_js_1.Application),
|
25
25
|
alias: 'application',
|
26
26
|
searchables: ['name', 'description']
|
27
27
|
});
|
@@ -30,7 +30,7 @@ let ApplicationQuery = class ApplicationQuery {
|
|
30
30
|
}
|
31
31
|
async availableScopes(context) {
|
32
32
|
const { domain } = context.state;
|
33
|
-
const roles = await (0, shell_1.getRepository)(
|
33
|
+
const roles = await (0, shell_1.getRepository)(role_js_1.Role).findBy({ domain: { id: domain.id } });
|
34
34
|
return roles.map((role) => role.name).join(' ');
|
35
35
|
}
|
36
36
|
async accessTokenUrl(context) {
|
@@ -43,16 +43,16 @@ let ApplicationQuery = class ApplicationQuery {
|
|
43
43
|
return context.state.domain;
|
44
44
|
}
|
45
45
|
async updater(application) {
|
46
|
-
return await (0, shell_1.getRepository)(
|
46
|
+
return await (0, shell_1.getRepository)(user_js_1.User).findOneBy({ id: application.updaterId });
|
47
47
|
}
|
48
48
|
async creator(application) {
|
49
|
-
return await (0, shell_1.getRepository)(
|
49
|
+
return await (0, shell_1.getRepository)(user_js_1.User).findOneBy({ id: application.creatorId });
|
50
50
|
}
|
51
51
|
};
|
52
52
|
exports.ApplicationQuery = ApplicationQuery;
|
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 => application_js_1.Application, { description: 'To fetch application' }),
|
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
|
], ApplicationQuery.prototype, "application", 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 => application_types_js_1.ApplicationList, { description: 'To fetch multiple application' }),
|
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),
|
@@ -97,21 +97,21 @@ tslib_1.__decorate([
|
|
97
97
|
tslib_1.__metadata("design:returntype", Promise)
|
98
98
|
], ApplicationQuery.prototype, "domain", null);
|
99
99
|
tslib_1.__decorate([
|
100
|
-
(0, type_graphql_1.FieldResolver)(type =>
|
100
|
+
(0, type_graphql_1.FieldResolver)(type => user_js_1.User),
|
101
101
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
102
102
|
tslib_1.__metadata("design:type", Function),
|
103
|
-
tslib_1.__metadata("design:paramtypes", [
|
103
|
+
tslib_1.__metadata("design:paramtypes", [application_js_1.Application]),
|
104
104
|
tslib_1.__metadata("design:returntype", Promise)
|
105
105
|
], ApplicationQuery.prototype, "updater", null);
|
106
106
|
tslib_1.__decorate([
|
107
|
-
(0, type_graphql_1.FieldResolver)(type =>
|
107
|
+
(0, type_graphql_1.FieldResolver)(type => user_js_1.User),
|
108
108
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
109
109
|
tslib_1.__metadata("design:type", Function),
|
110
|
-
tslib_1.__metadata("design:paramtypes", [
|
110
|
+
tslib_1.__metadata("design:paramtypes", [application_js_1.Application]),
|
111
111
|
tslib_1.__metadata("design:returntype", Promise)
|
112
112
|
], ApplicationQuery.prototype, "creator", null);
|
113
113
|
exports.ApplicationQuery = ApplicationQuery = tslib_1.__decorate([
|
114
|
-
(0, type_graphql_1.Resolver)(
|
114
|
+
(0, type_graphql_1.Resolver)(application_js_1.Application)
|
115
115
|
], ApplicationQuery);
|
116
116
|
function buildAuthURL(pathname, context) {
|
117
117
|
const originalProtocol = context.headers['x-forwarded-proto'];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"application-query.js","sourceRoot":"","sources":["../../../server/service/application/application-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;
|
1
|
+
{"version":3,"file":"application-query.js","sourceRoot":"","sources":["../../../server/service/application/application-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,6BAAyB;AAEzB,6CAA4C;AAC5C,iDAAuG;AAEvG,6CAAsC;AACtC,6CAAsC;AACtC,qDAA8C;AAC9C,iEAAwD;AAExD,MAAM,QAAQ,GAAW,YAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;AAGxC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAGrB,AAAN,KAAK,CAAC,WAAW,CAAY,EAAU,EAAS,OAAwB;QACtE,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,4BAAW,CAAC,CAAA;QAE7C,OAAO,MAAM,UAAU,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IAC3C,CAAC;IAIK,AAAN,KAAK,CAAC,YAAY,CAA0B,MAAiB,EAAS,OAAwB;QAC5F,MAAM,EAAE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URL } from 'url'\n\nimport { config } from '@things-factory/env'\nimport { getQueryBuilderFromListParams, Domain, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Role } from '../role/role.js'\nimport { User } from '../user/user.js'\nimport { Application } from './application.js'\nimport { ApplicationList } from './application-types.js'\n\nconst protocol: string = config.get('protocol')\n\n@Resolver(Application)\nexport class ApplicationQuery {\n @Directive('@privilege(category: \"user\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => Application, { description: 'To fetch application' })\n async application(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Application> {\n const repository = getRepository(Application)\n\n return await repository.findOneBy({ id })\n }\n\n @Directive('@privilege(category: \"user\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ApplicationList, { description: 'To fetch multiple application' })\n async applications(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: getRepository(Application),\n alias: 'application',\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 availableScopes(@Ctx() context: ResolverContext): Promise<string> {\n const { domain } = context.state\n const roles = await getRepository(Role).findBy({ domain: { id: domain.id } })\n\n return roles.map((role: Role) => role.name).join(' ')\n }\n\n @FieldResolver(type => String)\n async accessTokenUrl(@Ctx() context: ResolverContext): Promise<string> {\n return buildAuthURL('/oauth/access-token', context)\n }\n\n @FieldResolver(type => String)\n async authUrl(@Ctx() context: ResolverContext): Promise<string> {\n return buildAuthURL('/oauth/authorize', context)\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() application: Application): Promise<User> {\n return await getRepository(User).findOneBy({ id: application.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() application: Application): Promise<User> {\n return await getRepository(User).findOneBy({ id: application.creatorId })\n }\n}\n\nfunction buildAuthURL(pathname: string, context: ResolverContext): string {\n const originalProtocol = context.headers['x-forwarded-proto']\n const originalHost = context.headers['x-forwarded-host']\n const originalPort = context.headers['x-forwarded-port']\n\n if (originalProtocol && originalHost) {\n var url: URL = new URL(`${originalProtocol}://${originalHost}`)\n if (originalPort) {\n url.port = originalPort\n }\n } else {\n var url: URL = new URL(context.request.origin)\n }\n\n if (protocol) {\n url.protocol = protocol\n }\n\n url.pathname = pathname\n\n return url.href\n}\n"]}
|
@@ -4,7 +4,7 @@ exports.NewApplication = exports.ApplicationPatch = exports.ApplicationList = ex
|
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
6
6
|
const graphql_scalars_1 = require("graphql-scalars");
|
7
|
-
const
|
7
|
+
const application_js_1 = require("./application.js");
|
8
8
|
let AccessToken = class AccessToken {
|
9
9
|
};
|
10
10
|
exports.AccessToken = AccessToken;
|
@@ -23,7 +23,7 @@ let ApplicationList = class ApplicationList {
|
|
23
23
|
};
|
24
24
|
exports.ApplicationList = ApplicationList;
|
25
25
|
tslib_1.__decorate([
|
26
|
-
(0, type_graphql_1.Field)(type => [
|
26
|
+
(0, type_graphql_1.Field)(type => [application_js_1.Application], { nullable: true }),
|
27
27
|
tslib_1.__metadata("design:type", Array)
|
28
28
|
], ApplicationList.prototype, "items", void 0);
|
29
29
|
tslib_1.__decorate([
|
@@ -65,7 +65,7 @@ tslib_1.__decorate([
|
|
65
65
|
tslib_1.__metadata("design:type", String)
|
66
66
|
], ApplicationPatch.prototype, "webhook", void 0);
|
67
67
|
tslib_1.__decorate([
|
68
|
-
(0, type_graphql_1.Field)(type =>
|
68
|
+
(0, type_graphql_1.Field)(type => application_js_1.ApplicationType, { nullable: true }),
|
69
69
|
tslib_1.__metadata("design:type", String)
|
70
70
|
], ApplicationPatch.prototype, "type", void 0);
|
71
71
|
exports.ApplicationPatch = ApplicationPatch = tslib_1.__decorate([
|
@@ -103,7 +103,7 @@ tslib_1.__decorate([
|
|
103
103
|
tslib_1.__metadata("design:type", String)
|
104
104
|
], NewApplication.prototype, "webhook", void 0);
|
105
105
|
tslib_1.__decorate([
|
106
|
-
(0, type_graphql_1.Field)(type =>
|
106
|
+
(0, type_graphql_1.Field)(type => application_js_1.ApplicationType, { nullable: true }),
|
107
107
|
tslib_1.__metadata("design:type", String)
|
108
108
|
], NewApplication.prototype, "type", void 0);
|
109
109
|
exports.NewApplication = NewApplication = tslib_1.__decorate([
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"application-types.js","sourceRoot":"","sources":["../../../server/service/application/application-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAChE,qDAAqD;AAErD
|
1
|
+
{"version":3,"file":"application-types.js","sourceRoot":"","sources":["../../../server/service/application/application-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAChE,qDAAqD;AAErD,qDAA+D;AAGxD,IAAM,WAAW,GAAjB,MAAM,WAAW;CAMvB,CAAA;AANY,kCAAW;AAEtB;IADC,IAAA,oBAAK,GAAE;;+CACU;AAGlB;IADC,IAAA,oBAAK,GAAE;;iDACY;sBALT,WAAW;IADvB,IAAA,yBAAU,GAAE;GACA,WAAW,CAMvB;AAGM,IAAM,eAAe,GAArB,MAAM,eAAe;CAM3B,CAAA;AANY,0CAAe;AAE1B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,4BAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CAC5B;AAGrB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACzB;0BALH,eAAe;IAD3B,IAAA,yBAAU,GAAE;GACA,eAAe,CAM3B;AAGM,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAwB5B,CAAA;AAxBY,4CAAgB;AAE3B;IADC,IAAA,oBAAK,EAAC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DACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACV;AAGhB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gCAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CAC7B;yBAvBX,cAAc;IAD1B,IAAA,wBAAS,GAAE;GACC,cAAc,CAwB1B","sourcesContent":["import { Field, InputType, Int, ObjectType } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\n\nimport { Application, ApplicationType } from './application.js'\n\n@ObjectType()\nexport class AccessToken {\n @Field()\n accesToken: string\n\n @Field()\n refreshToken: string\n}\n\n@ObjectType()\nexport class ApplicationList {\n @Field(type => [Application], { nullable: true })\n items?: Application[]\n\n @Field(type => Int, { nullable: true })\n total?: number\n}\n\n@InputType()\nexport class ApplicationPatch {\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field(type => GraphQLEmailAddress, { nullable: true })\n email?: string\n\n @Field({ nullable: true })\n url?: string\n\n @Field({ nullable: true })\n icon?: string\n\n @Field({ nullable: true })\n redirectUrl?: string\n\n @Field({ nullable: true })\n webhook?: string\n\n @Field(type => ApplicationType, { nullable: true })\n type?: ApplicationType\n}\n\n@InputType()\nexport class NewApplication {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field(type => GraphQLEmailAddress, { nullable: true })\n email?: string\n\n @Field({ nullable: true })\n url?: string\n\n @Field({ nullable: true })\n icon?: string\n\n @Field({ nullable: true })\n redirectUrl?: string\n\n @Field({ nullable: true })\n webhook?: string\n\n @Field(type => ApplicationType, { nullable: true })\n type?: ApplicationType\n}\n"]}
|
@@ -9,8 +9,8 @@ const graphql_scalars_1 = require("graphql-scalars");
|
|
9
9
|
const typeorm_1 = require("typeorm");
|
10
10
|
const env_1 = require("@things-factory/env");
|
11
11
|
const shell_1 = require("@things-factory/shell");
|
12
|
-
const
|
13
|
-
const
|
12
|
+
const get_secret_js_1 = require("../../utils/get-secret.js");
|
13
|
+
const user_js_1 = require("../user/user.js");
|
14
14
|
const ORMCONFIG = env_1.config.get('ormconfig', {});
|
15
15
|
const DATABASE_TYPE = ORMCONFIG.type;
|
16
16
|
var ApplicationStatus;
|
@@ -51,13 +51,13 @@ let Application = class Application {
|
|
51
51
|
application: {
|
52
52
|
appKey
|
53
53
|
},
|
54
|
-
status:
|
54
|
+
status: user_js_1.UserStatus.ACTIVATED,
|
55
55
|
domain: {
|
56
56
|
subdomain: domain.subdomain
|
57
57
|
},
|
58
58
|
scope
|
59
59
|
};
|
60
|
-
return jsonwebtoken_1.default.sign(application,
|
60
|
+
return jsonwebtoken_1.default.sign(application, get_secret_js_1.SECRET, {
|
61
61
|
expiresIn,
|
62
62
|
issuer: 'hatiolab.com',
|
63
63
|
subject
|
@@ -80,13 +80,13 @@ let Application = class Application {
|
|
80
80
|
scopes,
|
81
81
|
state
|
82
82
|
};
|
83
|
-
return jsonwebtoken_1.default.sign(credential,
|
83
|
+
return jsonwebtoken_1.default.sign(credential, get_secret_js_1.SECRET, {
|
84
84
|
expiresIn: '1m'
|
85
85
|
});
|
86
86
|
}
|
87
87
|
/* auth-code signing for jsonwebtoken */
|
88
88
|
static verifyAuthCode(authcode) {
|
89
|
-
return jsonwebtoken_1.default.verify(authcode,
|
89
|
+
return jsonwebtoken_1.default.verify(authcode, get_secret_js_1.SECRET);
|
90
90
|
}
|
91
91
|
};
|
92
92
|
exports.Application = Application;
|
@@ -194,18 +194,18 @@ tslib_1.__decorate([
|
|
194
194
|
tslib_1.__metadata("design:type", Date)
|
195
195
|
], Application.prototype, "updatedAt", void 0);
|
196
196
|
tslib_1.__decorate([
|
197
|
-
(0, typeorm_1.ManyToOne)(type =>
|
198
|
-
(0, type_graphql_1.Field)(type =>
|
199
|
-
tslib_1.__metadata("design:type",
|
197
|
+
(0, typeorm_1.ManyToOne)(type => user_js_1.User, { nullable: true }),
|
198
|
+
(0, type_graphql_1.Field)(type => user_js_1.User, { nullable: true }),
|
199
|
+
tslib_1.__metadata("design:type", user_js_1.User)
|
200
200
|
], Application.prototype, "creator", void 0);
|
201
201
|
tslib_1.__decorate([
|
202
202
|
(0, typeorm_1.RelationId)((application) => application.creator),
|
203
203
|
tslib_1.__metadata("design:type", String)
|
204
204
|
], Application.prototype, "creatorId", void 0);
|
205
205
|
tslib_1.__decorate([
|
206
|
-
(0, typeorm_1.ManyToOne)(type =>
|
207
|
-
(0, type_graphql_1.Field)(type =>
|
208
|
-
tslib_1.__metadata("design:type",
|
206
|
+
(0, typeorm_1.ManyToOne)(type => user_js_1.User, { nullable: true }),
|
207
|
+
(0, type_graphql_1.Field)(type => user_js_1.User, { nullable: true }),
|
208
|
+
tslib_1.__metadata("design:type", user_js_1.User)
|
209
209
|
], Application.prototype, "updater", void 0);
|
210
210
|
tslib_1.__decorate([
|
211
211
|
(0, typeorm_1.RelationId)((application) => application.updater),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../server/service/application/application.ts"],"names":[],"mappings":";;;;AAAA,4DAA2B;AAC3B,wEAA8B;AAC9B,+CAAiF;AACjF,qDAAqD;AACrD,qCASgB;AAEhB,6CAA4C;AAC5C,iDAA8C;AAE9C,uDAA+C;AAC/C,uCAA+C;AAE/C,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,oCAAe,CAAA;IACf,4CAAuB,CAAA;AACzB,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B;AAED,IAAA,+BAAgB,EAAC,iBAAiB,EAAE;IAClC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,oCAAoC;CAClD,CAAC,CAAA;AAEF,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8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AAC,OAAO,CAAC;;8CAC5C;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,WAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,WAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,WAAI;4CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;;8CAC5C;sBAvGP,WAAW;IAHvB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,kBAAkB,EAAE,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC/F,IAAA,yBAAU,GAAE;GACA,WAAW,CAqKvB","sourcesContent":["import crypto from 'crypto'\nimport jwt from 'jsonwebtoken'\nimport { Directive, Field, ID, ObjectType, registerEnumType } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { SECRET } from '../../utils/get-secret'\nimport { User, UserStatus } from '../user/user'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nexport enum ApplicationStatus {\n DRAFT = 'DRAFT',\n ACTIVATED = 'ACTIVATED'\n}\n\nregisterEnumType(ApplicationStatus, {\n name: 'ApplicationStatus',\n description: 'state enumeration of a application'\n})\n\nexport enum ApplicationType {\n SELLERCRAFT = 'SELLERCRAFT',\n XILNEX = 'XILNEX',\n MMS = 'MMS',\n XERO = 'XERO',\n OTHERS = 'OTHERS',\n SFTP = 'SFTP'\n}\n\nregisterEnumType(ApplicationType, {\n name: 'ApplicationType',\n description: 'state enumeration of a application'\n})\n@Entity()\n@Index('ix_application_0', (application: Application) => [application.appKey], { unique: true })\n@ObjectType()\nexport class Application {\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((application: Application) => application.domain)\n domainId?: string\n\n @Column()\n @Field()\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n description?: string\n\n @Column()\n @Field(type => GraphQLEmailAddress)\n email?: string\n\n @Column()\n @Field()\n url?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n icon?: string\n\n @Column()\n @Field()\n redirectUrl?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n webhook?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n appKey?: 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 appSecret?: string\n\n @Column({ default: ApplicationStatus.DRAFT })\n @Field()\n status?: ApplicationStatus\n\n @Column({\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n enum:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? ApplicationType\n : undefined,\n length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32,\n default: ApplicationType.OTHERS\n })\n @Field()\n type?: ApplicationType\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((application: Application) => application.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((application: Application) => application.updater)\n updaterId?: string\n\n /* generateAppSecret */\n static generateAppSecret() {\n return crypto.randomBytes(16).toString('hex')\n }\n\n static generateAppKey() {\n return crypto.randomBytes(16).toString('hex')\n }\n\n /* signing for jsonwebtoken */\n static sign(subject, expiresIn, domain, user, appKey, scope) {\n var application = {\n id: user.id,\n userType: 'application',\n application: {\n appKey\n },\n status: UserStatus.ACTIVATED,\n domain: {\n subdomain: domain.subdomain\n },\n scope\n }\n\n return jwt.sign(application, SECRET, {\n expiresIn,\n issuer: 'hatiolab.com',\n subject\n })\n }\n\n static generateAccessToken(domain, user, appKey, scope) {\n /* how to set expiresIn https://github.com/vercel/ms */\n return this.sign('access-token', '30d', domain, user, appKey, scope)\n }\n\n static generateRefreshToken(domain, user, appKey, scope) {\n /* how to set expiresIn https://github.com/vercel/ms */\n return this.sign('refresh-token', '1y', domain, user, appKey, scope)\n }\n\n /* auth-code signing for jsonwebtoken */\n static generateAuthCode(email, appKey, subdomain, scopes, state) {\n var credential = {\n email,\n appKey,\n subdomain,\n scopes,\n state\n }\n\n return jwt.sign(credential, SECRET, {\n expiresIn: '1m'\n })\n }\n\n /* auth-code signing for jsonwebtoken */\n static verifyAuthCode(authcode) {\n return jwt.verify(authcode, SECRET)\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../server/service/application/application.ts"],"names":[],"mappings":";;;;AAAA,4DAA2B;AAC3B,wEAA8B;AAC9B,+CAAiF;AACjF,qDAAqD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,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACd,IAAI;8CAAA;AAIhB;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACd,IAAI;8CAAA;AAIhB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,cAAI;4CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;;8CAC5C;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,cAAI;4CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;;8CAC5C;sBAvGP,WAAW;IAHvB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,kBAAkB,EAAE,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC/F,IAAA,yBAAU,GAAE;GACA,WAAW,CAqKvB","sourcesContent":["import crypto from 'crypto'\nimport jwt from 'jsonwebtoken'\nimport { Directive, Field, ID, ObjectType, registerEnumType } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { SECRET } from '../../utils/get-secret.js'\nimport { User, UserStatus } from '../user/user.js'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nexport enum ApplicationStatus {\n DRAFT = 'DRAFT',\n ACTIVATED = 'ACTIVATED'\n}\n\nregisterEnumType(ApplicationStatus, {\n name: 'ApplicationStatus',\n description: 'state enumeration of a application'\n})\n\nexport enum ApplicationType {\n SELLERCRAFT = 'SELLERCRAFT',\n XILNEX = 'XILNEX',\n MMS = 'MMS',\n XERO = 'XERO',\n OTHERS = 'OTHERS',\n SFTP = 'SFTP'\n}\n\nregisterEnumType(ApplicationType, {\n name: 'ApplicationType',\n description: 'state enumeration of a application'\n})\n@Entity()\n@Index('ix_application_0', (application: Application) => [application.appKey], { unique: true })\n@ObjectType()\nexport class Application {\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((application: Application) => application.domain)\n domainId?: string\n\n @Column()\n @Field()\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n description?: string\n\n @Column()\n @Field(type => GraphQLEmailAddress)\n email?: string\n\n @Column()\n @Field()\n url?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n icon?: string\n\n @Column()\n @Field()\n redirectUrl?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n webhook?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n appKey?: 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 appSecret?: string\n\n @Column({ default: ApplicationStatus.DRAFT })\n @Field()\n status?: ApplicationStatus\n\n @Column({\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n enum:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? ApplicationType\n : undefined,\n length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32,\n default: ApplicationType.OTHERS\n })\n @Field()\n type?: ApplicationType\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((application: Application) => application.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((application: Application) => application.updater)\n updaterId?: string\n\n /* generateAppSecret */\n static generateAppSecret() {\n return crypto.randomBytes(16).toString('hex')\n }\n\n static generateAppKey() {\n return crypto.randomBytes(16).toString('hex')\n }\n\n /* signing for jsonwebtoken */\n static sign(subject, expiresIn, domain, user, appKey, scope) {\n var application = {\n id: user.id,\n userType: 'application',\n application: {\n appKey\n },\n status: UserStatus.ACTIVATED,\n domain: {\n subdomain: domain.subdomain\n },\n scope\n }\n\n return jwt.sign(application, SECRET, {\n expiresIn,\n issuer: 'hatiolab.com',\n subject\n })\n }\n\n static generateAccessToken(domain, user, appKey, scope) {\n /* how to set expiresIn https://github.com/vercel/ms */\n return this.sign('access-token', '30d', domain, user, appKey, scope)\n }\n\n static generateRefreshToken(domain, user, appKey, scope) {\n /* how to set expiresIn https://github.com/vercel/ms */\n return this.sign('refresh-token', '1y', domain, user, appKey, scope)\n }\n\n /* auth-code signing for jsonwebtoken */\n static generateAuthCode(email, appKey, subdomain, scopes, state) {\n var credential = {\n email,\n appKey,\n subdomain,\n scopes,\n state\n }\n\n return jwt.sign(credential, SECRET, {\n expiresIn: '1m'\n })\n }\n\n /* auth-code signing for jsonwebtoken */\n static verifyAuthCode(authcode) {\n return jwt.verify(authcode, SECRET)\n }\n}\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Application } from './application';
|
2
|
-
import { ApplicationQuery } from './application-query';
|
3
|
-
import { ApplicationMutation } from './application-mutation';
|
1
|
+
import { Application } from './application.js';
|
2
|
+
import { ApplicationQuery } from './application-query.js';
|
3
|
+
import { ApplicationMutation } from './application-mutation.js';
|
4
4
|
export declare const entities: (typeof Application)[];
|
5
5
|
export declare const resolvers: (typeof ApplicationQuery | typeof ApplicationMutation)[];
|
@@ -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 application_js_1 = require("./application.js");
|
5
|
+
const application_query_js_1 = require("./application-query.js");
|
6
|
+
const application_mutation_js_1 = require("./application-mutation.js");
|
7
|
+
exports.entities = [application_js_1.Application];
|
8
|
+
exports.resolvers = [application_query_js_1.ApplicationQuery, application_mutation_js_1.ApplicationMutation];
|
9
9
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/application/index.ts"],"names":[],"mappings":";;;AAAA
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/application/index.ts"],"names":[],"mappings":";;;AAAA,qDAA8C;AAC9C,iEAAyD;AACzD,uEAA+D;AAElD,QAAA,QAAQ,GAAG,CAAC,4BAAW,CAAC,CAAA;AACxB,QAAA,SAAS,GAAG,CAAC,uCAAgB,EAAE,6CAAmB,CAAC,CAAA","sourcesContent":["import { Application } from './application.js'\nimport { ApplicationQuery } from './application-query.js'\nimport { ApplicationMutation } from './application-mutation.js'\n\nexport const entities = [Application]\nexport const resolvers = [ApplicationQuery, ApplicationMutation]\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { AuthProvider } from './auth-provider';
|
2
|
-
import { NewAuthProvider, AuthProviderPatch } from './auth-provider-type';
|
1
|
+
import { AuthProvider } from './auth-provider.js';
|
2
|
+
import { NewAuthProvider, AuthProviderPatch } from './auth-provider-type.js';
|
3
3
|
export declare class AuthProviderMutation {
|
4
4
|
createAuthProvider(authProvider: NewAuthProvider, context: ResolverContext): Promise<AuthProvider>;
|
5
5
|
updateAuthProvider(id: string, patch: AuthProviderPatch, context: ResolverContext): Promise<AuthProvider>;
|