@things-factory/auth-base 9.0.0-beta.8 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/config.development.js +1 -0
- package/dist-client/auth.js +2 -7
- package/dist-client/auth.js.map +1 -1
- package/dist-client/reducers/auth.js +9 -2
- package/dist-client/reducers/auth.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/change-pwd.js +5 -2
- package/dist-server/controllers/change-pwd.js.map +1 -1
- package/dist-server/controllers/checkin.js +1 -1
- package/dist-server/controllers/checkin.js.map +1 -1
- package/dist-server/controllers/delete-user.js +2 -2
- package/dist-server/controllers/delete-user.js.map +1 -1
- package/dist-server/controllers/profile.js +4 -1
- package/dist-server/controllers/profile.js.map +1 -1
- package/dist-server/controllers/reset-password.js +5 -2
- package/dist-server/controllers/reset-password.js.map +1 -1
- package/dist-server/controllers/signin.js +2 -2
- package/dist-server/controllers/signin.js.map +1 -1
- package/dist-server/controllers/signup.js +8 -1
- package/dist-server/controllers/signup.js.map +1 -1
- package/dist-server/errors/auth-error.js +3 -1
- package/dist-server/errors/auth-error.js.map +1 -1
- package/dist-server/middlewares/authenticate-401-middleware.js +22 -9
- 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.js +1 -5
- package/dist-server/middlewares/domain-authenticate-middleware.js.map +1 -1
- package/dist-server/middlewares/index.js +6 -1
- package/dist-server/middlewares/index.js.map +1 -1
- package/dist-server/middlewares/jwt-authenticate-middleware.js +1 -1
- package/dist-server/middlewares/jwt-authenticate-middleware.js.map +1 -1
- package/dist-server/migrations/1548206416130-SeedUser.js +11 -3
- package/dist-server/migrations/1548206416130-SeedUser.js.map +1 -1
- package/dist-server/router/auth-checkin-router.js +11 -13
- package/dist-server/router/auth-checkin-router.js.map +1 -1
- package/dist-server/router/auth-private-process-router.js +10 -4
- package/dist-server/router/auth-private-process-router.js.map +1 -1
- package/dist-server/router/auth-signup-router.js +5 -2
- package/dist-server/router/auth-signup-router.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-authorize-router.js +5 -2
- package/dist-server/router/oauth2/oauth2-authorize-router.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-router.js +1 -2
- package/dist-server/router/oauth2/oauth2-router.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-server.js +21 -3
- package/dist-server/router/oauth2/oauth2-server.js.map +1 -1
- package/dist-server/router/site-root-router.js +1 -1
- package/dist-server/router/site-root-router.js.map +1 -1
- package/dist-server/router/webauthn-router.js +1 -1
- package/dist-server/router/webauthn-router.js.map +1 -1
- package/dist-server/routes.js +74 -48
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/app-binding/app-binding-types.js +3 -3
- package/dist-server/service/app-binding/app-binding-types.js.map +1 -1
- package/dist-server/service/app-binding/app-binding.js +6 -4
- package/dist-server/service/app-binding/app-binding.js.map +1 -1
- package/dist-server/service/appliance/appliance-mutation.js +37 -34
- package/dist-server/service/appliance/appliance-mutation.js.map +1 -1
- package/dist-server/service/appliance/appliance-types.js +18 -18
- package/dist-server/service/appliance/appliance-types.js.map +1 -1
- package/dist-server/service/appliance/appliance.d.ts +2 -0
- package/dist-server/service/appliance/appliance.js +61 -14
- package/dist-server/service/appliance/appliance.js.map +1 -1
- package/dist-server/service/application/application-mutation.js +22 -4
- package/dist-server/service/application/application-mutation.js.map +1 -1
- package/dist-server/service/application/application-types.js +24 -24
- package/dist-server/service/application/application-types.js.map +1 -1
- package/dist-server/service/application/application.d.ts +6 -6
- package/dist-server/service/application/application.js +22 -22
- package/dist-server/service/application/application.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider-mutation.js +29 -7
- package/dist-server/service/auth-provider/auth-provider-mutation.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider-parameter-spec.js +12 -7
- package/dist-server/service/auth-provider/auth-provider-parameter-spec.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider-type.js +24 -21
- package/dist-server/service/auth-provider/auth-provider-type.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider.js +35 -25
- package/dist-server/service/auth-provider/auth-provider.js.map +1 -1
- package/dist-server/service/domain-generator/domain-generator-mutation.js +1 -2
- package/dist-server/service/domain-generator/domain-generator-mutation.js.map +1 -1
- package/dist-server/service/domain-generator/domain-generator-types.js +17 -14
- package/dist-server/service/domain-generator/domain-generator-types.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 +133 -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.js +7 -7
- package/dist-server/service/granted-role/granted-role-mutation.js.map +1 -1
- package/dist-server/service/granted-role/granted-role.js +4 -4
- package/dist-server/service/granted-role/granted-role.js.map +1 -1
- package/dist-server/service/index.d.ts +3 -1
- package/dist-server/service/index.js +7 -2
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/invitation/invitation-mutation.js +6 -2
- package/dist-server/service/invitation/invitation-mutation.js.map +1 -1
- package/dist-server/service/invitation/invitation-types.js +3 -3
- package/dist-server/service/invitation/invitation-types.js.map +1 -1
- package/dist-server/service/invitation/invitation.js +10 -10
- package/dist-server/service/invitation/invitation.js.map +1 -1
- package/dist-server/service/login-history/login-history-type.js +3 -3
- package/dist-server/service/login-history/login-history-type.js.map +1 -1
- package/dist-server/service/login-history/login-history.js +6 -6
- package/dist-server/service/login-history/login-history.js.map +1 -1
- package/dist-server/service/partner/partner-types.js +3 -3
- package/dist-server/service/partner/partner-types.js.map +1 -1
- package/dist-server/service/partner/partner.js +8 -8
- package/dist-server/service/partner/partner.js.map +1 -1
- package/dist-server/service/password-history/password-history.js +3 -3
- package/dist-server/service/password-history/password-history.js.map +1 -1
- package/dist-server/service/privilege/privilege-directive.js +1 -2
- package/dist-server/service/privilege/privilege-directive.js.map +1 -1
- package/dist-server/service/privilege/privilege-mutation.js +11 -2
- package/dist-server/service/privilege/privilege-mutation.js.map +1 -1
- package/dist-server/service/privilege/privilege.js +20 -20
- package/dist-server/service/privilege/privilege.js.map +1 -1
- package/dist-server/service/role/role-mutation.js +12 -2
- package/dist-server/service/role/role-mutation.js.map +1 -1
- package/dist-server/service/role/role-query.d.ts +7 -3
- package/dist-server/service/role/role-query.js +18 -10
- package/dist-server/service/role/role-query.js.map +1 -1
- package/dist-server/service/role/role-types.d.ts +4 -0
- package/dist-server/service/role/role-types.js +41 -27
- package/dist-server/service/role/role-types.js.map +1 -1
- package/dist-server/service/role/role.js +11 -11
- package/dist-server/service/role/role.js.map +1 -1
- package/dist-server/service/user/user-mutation.js +89 -41
- package/dist-server/service/user/user-mutation.js.map +1 -1
- package/dist-server/service/user/user-query.d.ts +1 -0
- package/dist-server/service/user/user-query.js +25 -9
- package/dist-server/service/user/user-query.js.map +1 -1
- package/dist-server/service/user/user-types.js +33 -32
- package/dist-server/service/user/user-types.js.map +1 -1
- package/dist-server/service/user/user.d.ts +5 -5
- package/dist-server/service/user/user.js +25 -22
- package/dist-server/service/user/user.js.map +1 -1
- package/dist-server/service/users-auth-providers/users-auth-providers.js +11 -8
- package/dist-server/service/users-auth-providers/users-auth-providers.js.map +1 -1
- package/dist-server/service/verification-token/verification-token.d.ts +3 -3
- package/dist-server/service/verification-token/verification-token.js +8 -8
- package/dist-server/service/verification-token/verification-token.js.map +1 -1
- package/dist-server/service/web-auth-credential/web-auth-credential.js +11 -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/utils/access-token-cookie.js +1 -11
- package/dist-server/utils/access-token-cookie.js.map +1 -1
- package/dist-server/utils/check-user-belongs-domain.js +1 -2
- package/dist-server/utils/check-user-belongs-domain.js.map +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 +0 -1
- package/dist-server/utils/get-user-domains.js +28 -22
- package/dist-server/utils/get-user-domains.js.map +1 -1
- package/package.json +6 -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
@@ -1 +1 @@
|
|
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,
|
1
|
+
{"version":3,"file":"application-mutation.js","sourceRoot":"","sources":["../../../server/service/application/application-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAEtE,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AC,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"]}
|
@@ -9,104 +9,104 @@ let AccessToken = class AccessToken {
|
|
9
9
|
};
|
10
10
|
exports.AccessToken = AccessToken;
|
11
11
|
tslib_1.__decorate([
|
12
|
-
(0, type_graphql_1.Field)(),
|
12
|
+
(0, type_graphql_1.Field)({ description: 'The access token for API authentication.' }),
|
13
13
|
tslib_1.__metadata("design:type", String)
|
14
14
|
], AccessToken.prototype, "accesToken", void 0);
|
15
15
|
tslib_1.__decorate([
|
16
|
-
(0, type_graphql_1.Field)(),
|
16
|
+
(0, type_graphql_1.Field)({ description: 'The refresh token to obtain a new access token.' }),
|
17
17
|
tslib_1.__metadata("design:type", String)
|
18
18
|
], AccessToken.prototype, "refreshToken", void 0);
|
19
19
|
exports.AccessToken = AccessToken = tslib_1.__decorate([
|
20
|
-
(0, type_graphql_1.ObjectType)()
|
20
|
+
(0, type_graphql_1.ObjectType)({ description: 'Represents a pair of access and refresh tokens.' })
|
21
21
|
], AccessToken);
|
22
22
|
let ApplicationList = class ApplicationList {
|
23
23
|
};
|
24
24
|
exports.ApplicationList = ApplicationList;
|
25
25
|
tslib_1.__decorate([
|
26
|
-
(0, type_graphql_1.Field)(type => [application_js_1.Application], { nullable: true }),
|
26
|
+
(0, type_graphql_1.Field)(type => [application_js_1.Application], { nullable: true, description: 'The list of application items.' }),
|
27
27
|
tslib_1.__metadata("design:type", Array)
|
28
28
|
], ApplicationList.prototype, "items", void 0);
|
29
29
|
tslib_1.__decorate([
|
30
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
|
30
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'The total number of applications.' }),
|
31
31
|
tslib_1.__metadata("design:type", Number)
|
32
32
|
], ApplicationList.prototype, "total", void 0);
|
33
33
|
exports.ApplicationList = ApplicationList = tslib_1.__decorate([
|
34
|
-
(0, type_graphql_1.ObjectType)()
|
34
|
+
(0, type_graphql_1.ObjectType)({ description: 'A paginated list of applications.' })
|
35
35
|
], ApplicationList);
|
36
36
|
let ApplicationPatch = class ApplicationPatch {
|
37
37
|
};
|
38
38
|
exports.ApplicationPatch = ApplicationPatch;
|
39
39
|
tslib_1.__decorate([
|
40
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
40
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new name for the application.' }),
|
41
41
|
tslib_1.__metadata("design:type", String)
|
42
42
|
], ApplicationPatch.prototype, "name", void 0);
|
43
43
|
tslib_1.__decorate([
|
44
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
44
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new description for the application.' }),
|
45
45
|
tslib_1.__metadata("design:type", String)
|
46
46
|
], ApplicationPatch.prototype, "description", void 0);
|
47
47
|
tslib_1.__decorate([
|
48
|
-
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLEmailAddress, { nullable: true }),
|
48
|
+
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLEmailAddress, { nullable: true, description: 'The new contact email for the application.' }),
|
49
49
|
tslib_1.__metadata("design:type", String)
|
50
50
|
], ApplicationPatch.prototype, "email", void 0);
|
51
51
|
tslib_1.__decorate([
|
52
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
52
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new URL for the application.' }),
|
53
53
|
tslib_1.__metadata("design:type", String)
|
54
54
|
], ApplicationPatch.prototype, "url", void 0);
|
55
55
|
tslib_1.__decorate([
|
56
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
56
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new icon URL for the application.' }),
|
57
57
|
tslib_1.__metadata("design:type", String)
|
58
58
|
], ApplicationPatch.prototype, "icon", void 0);
|
59
59
|
tslib_1.__decorate([
|
60
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
60
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new redirect URL for the application.' }),
|
61
61
|
tslib_1.__metadata("design:type", String)
|
62
62
|
], ApplicationPatch.prototype, "redirectUrl", void 0);
|
63
63
|
tslib_1.__decorate([
|
64
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
64
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new webhook URL for the application.' }),
|
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 => application_js_1.ApplicationType, { nullable: true }),
|
68
|
+
(0, type_graphql_1.Field)(type => application_js_1.ApplicationType, { nullable: true, description: 'The new type for the application.' }),
|
69
69
|
tslib_1.__metadata("design:type", String)
|
70
70
|
], ApplicationPatch.prototype, "type", void 0);
|
71
71
|
exports.ApplicationPatch = ApplicationPatch = tslib_1.__decorate([
|
72
|
-
(0, type_graphql_1.InputType)()
|
72
|
+
(0, type_graphql_1.InputType)({ description: 'Input for updating (patching) an existing application.' })
|
73
73
|
], ApplicationPatch);
|
74
74
|
let NewApplication = class NewApplication {
|
75
75
|
};
|
76
76
|
exports.NewApplication = NewApplication;
|
77
77
|
tslib_1.__decorate([
|
78
|
-
(0, type_graphql_1.Field)(),
|
78
|
+
(0, type_graphql_1.Field)({ description: 'The name of the new application.' }),
|
79
79
|
tslib_1.__metadata("design:type", String)
|
80
80
|
], NewApplication.prototype, "name", void 0);
|
81
81
|
tslib_1.__decorate([
|
82
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
82
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'A description for the new application.' }),
|
83
83
|
tslib_1.__metadata("design:type", String)
|
84
84
|
], NewApplication.prototype, "description", void 0);
|
85
85
|
tslib_1.__decorate([
|
86
|
-
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLEmailAddress, { nullable: true }),
|
86
|
+
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLEmailAddress, { nullable: true, description: 'The contact email for the new application.' }),
|
87
87
|
tslib_1.__metadata("design:type", String)
|
88
88
|
], NewApplication.prototype, "email", void 0);
|
89
89
|
tslib_1.__decorate([
|
90
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
90
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The URL of the new application.' }),
|
91
91
|
tslib_1.__metadata("design:type", String)
|
92
92
|
], NewApplication.prototype, "url", void 0);
|
93
93
|
tslib_1.__decorate([
|
94
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
94
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'A URL to the icon for the new application.' }),
|
95
95
|
tslib_1.__metadata("design:type", String)
|
96
96
|
], NewApplication.prototype, "icon", void 0);
|
97
97
|
tslib_1.__decorate([
|
98
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
98
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The redirect URL for the new application.' }),
|
99
99
|
tslib_1.__metadata("design:type", String)
|
100
100
|
], NewApplication.prototype, "redirectUrl", void 0);
|
101
101
|
tslib_1.__decorate([
|
102
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
102
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The webhook URL for the new application.' }),
|
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 => application_js_1.ApplicationType, { nullable: true }),
|
106
|
+
(0, type_graphql_1.Field)(type => application_js_1.ApplicationType, { nullable: true, description: 'The type of the new application.' }),
|
107
107
|
tslib_1.__metadata("design:type", String)
|
108
108
|
], NewApplication.prototype, "type", void 0);
|
109
109
|
exports.NewApplication = NewApplication = tslib_1.__decorate([
|
110
|
-
(0, type_graphql_1.InputType)()
|
110
|
+
(0, type_graphql_1.InputType)({ description: 'Input for creating a new application.' })
|
111
111
|
], NewApplication);
|
112
112
|
//# sourceMappingURL=application-types.js.map
|
@@ -1 +1 @@
|
|
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,
|
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;I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CAAC;;mDAChE;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;;+CACnE;AAGhB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gCAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;;4CAC9E;yBAvBX,cAAc;IAD1B,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;GACvD,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({ description: 'Represents a pair of access and refresh tokens.' })\nexport class AccessToken {\n @Field({ description: 'The access token for API authentication.' })\n accesToken: string\n\n @Field({ description: 'The refresh token to obtain a new access token.' })\n refreshToken: string\n}\n\n@ObjectType({ description: 'A paginated list of applications.' })\nexport class ApplicationList {\n @Field(type => [Application], { nullable: true, description: 'The list of application items.' })\n items?: Application[]\n\n @Field(type => Int, { nullable: true, description: 'The total number of applications.' })\n total?: number\n}\n\n@InputType({ description: 'Input for updating (patching) an existing application.' })\nexport class ApplicationPatch {\n @Field({ nullable: true, description: 'The new name for the application.' })\n name?: string\n\n @Field({ nullable: true, description: 'The new description for the application.' })\n description?: string\n\n @Field(type => GraphQLEmailAddress, { nullable: true, description: 'The new contact email for the application.' })\n email?: string\n\n @Field({ nullable: true, description: 'The new URL for the application.' })\n url?: string\n\n @Field({ nullable: true, description: 'The new icon URL for the application.' })\n icon?: string\n\n @Field({ nullable: true, description: 'The new redirect URL for the application.' })\n redirectUrl?: string\n\n @Field({ nullable: true, description: 'The new webhook URL for the application.' })\n webhook?: string\n\n @Field(type => ApplicationType, { nullable: true, description: 'The new type for the application.' })\n type?: ApplicationType\n}\n\n@InputType({ description: 'Input for creating a new application.' })\nexport class NewApplication {\n @Field({ description: 'The name of the new application.' })\n name: string\n\n @Field({ nullable: true, description: 'A description for the new application.' })\n description?: string\n\n @Field(type => GraphQLEmailAddress, { nullable: true, description: 'The contact email for the new application.' })\n email?: string\n\n @Field({ nullable: true, description: 'The URL of the new application.' })\n url?: string\n\n @Field({ nullable: true, description: 'A URL to the icon for the new application.' })\n icon?: string\n\n @Field({ nullable: true, description: 'The redirect URL for the new application.' })\n redirectUrl?: string\n\n @Field({ nullable: true, description: 'The webhook URL for the new application.' })\n webhook?: string\n\n @Field(type => ApplicationType, { nullable: true, description: 'The type of the new application.' })\n type?: ApplicationType\n}\n"]}
|
@@ -2,15 +2,15 @@ import jwt from 'jsonwebtoken';
|
|
2
2
|
import { Domain } from '@things-factory/shell';
|
3
3
|
import { User } from '../user/user.js';
|
4
4
|
export declare enum ApplicationStatus {
|
5
|
-
DRAFT = "DRAFT"
|
5
|
+
DRAFT = "DRAFT",// The application is in a draft state and not yet active.
|
6
6
|
ACTIVATED = "ACTIVATED"
|
7
7
|
}
|
8
8
|
export declare enum ApplicationType {
|
9
|
-
SELLERCRAFT = "SELLERCRAFT"
|
10
|
-
XILNEX = "XILNEX"
|
11
|
-
MMS = "MMS"
|
12
|
-
XERO = "XERO"
|
13
|
-
OTHERS = "OTHERS"
|
9
|
+
SELLERCRAFT = "SELLERCRAFT",// Represents a Sellercraft application.
|
10
|
+
XILNEX = "XILNEX",// Represents a Xilnex application.
|
11
|
+
MMS = "MMS",// Represents a MMS application.
|
12
|
+
XERO = "XERO",// Represents a Xero application.
|
13
|
+
OTHERS = "OTHERS",// Represents other types of applications.
|
14
14
|
SFTP = "SFTP"
|
15
15
|
}
|
16
16
|
export declare class Application {
|
@@ -16,11 +16,11 @@ const DATABASE_TYPE = ORMCONFIG.type;
|
|
16
16
|
var ApplicationStatus;
|
17
17
|
(function (ApplicationStatus) {
|
18
18
|
ApplicationStatus["DRAFT"] = "DRAFT";
|
19
|
-
ApplicationStatus["ACTIVATED"] = "ACTIVATED";
|
19
|
+
ApplicationStatus["ACTIVATED"] = "ACTIVATED"; // The application is active and can be used.
|
20
20
|
})(ApplicationStatus || (exports.ApplicationStatus = ApplicationStatus = {}));
|
21
21
|
(0, type_graphql_1.registerEnumType)(ApplicationStatus, {
|
22
22
|
name: 'ApplicationStatus',
|
23
|
-
description: '
|
23
|
+
description: 'The activation status of an application.'
|
24
24
|
});
|
25
25
|
var ApplicationType;
|
26
26
|
(function (ApplicationType) {
|
@@ -29,11 +29,11 @@ var ApplicationType;
|
|
29
29
|
ApplicationType["MMS"] = "MMS";
|
30
30
|
ApplicationType["XERO"] = "XERO";
|
31
31
|
ApplicationType["OTHERS"] = "OTHERS";
|
32
|
-
ApplicationType["SFTP"] = "SFTP";
|
32
|
+
ApplicationType["SFTP"] = "SFTP"; // Represents an SFTP application.
|
33
33
|
})(ApplicationType || (exports.ApplicationType = ApplicationType = {}));
|
34
34
|
(0, type_graphql_1.registerEnumType)(ApplicationType, {
|
35
35
|
name: 'ApplicationType',
|
36
|
-
description: '
|
36
|
+
description: 'The type of an application.'
|
37
37
|
});
|
38
38
|
let Application = class Application {
|
39
39
|
/* generateAppSecret */
|
@@ -92,12 +92,12 @@ let Application = class Application {
|
|
92
92
|
exports.Application = Application;
|
93
93
|
tslib_1.__decorate([
|
94
94
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
95
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
95
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier for the application.' }),
|
96
96
|
tslib_1.__metadata("design:type", String)
|
97
97
|
], Application.prototype, "id", void 0);
|
98
98
|
tslib_1.__decorate([
|
99
99
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
100
|
-
(0, type_graphql_1.Field)(type => shell_1.Domain),
|
100
|
+
(0, type_graphql_1.Field)(type => shell_1.Domain, { description: 'The domain to which the application belongs.' }),
|
101
101
|
tslib_1.__metadata("design:type", shell_1.Domain)
|
102
102
|
], Application.prototype, "domain", void 0);
|
103
103
|
tslib_1.__decorate([
|
@@ -106,42 +106,42 @@ tslib_1.__decorate([
|
|
106
106
|
], Application.prototype, "domainId", void 0);
|
107
107
|
tslib_1.__decorate([
|
108
108
|
(0, typeorm_1.Column)(),
|
109
|
-
(0, type_graphql_1.Field)(),
|
109
|
+
(0, type_graphql_1.Field)({ description: 'The name of the application.' }),
|
110
110
|
tslib_1.__metadata("design:type", String)
|
111
111
|
], Application.prototype, "name", void 0);
|
112
112
|
tslib_1.__decorate([
|
113
113
|
(0, typeorm_1.Column)({ nullable: true }),
|
114
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
114
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'A description of the application.' }),
|
115
115
|
tslib_1.__metadata("design:type", String)
|
116
116
|
], Application.prototype, "description", void 0);
|
117
117
|
tslib_1.__decorate([
|
118
118
|
(0, typeorm_1.Column)(),
|
119
|
-
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLEmailAddress),
|
119
|
+
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLEmailAddress, { description: 'The contact email for the application.' }),
|
120
120
|
tslib_1.__metadata("design:type", String)
|
121
121
|
], Application.prototype, "email", void 0);
|
122
122
|
tslib_1.__decorate([
|
123
123
|
(0, typeorm_1.Column)(),
|
124
|
-
(0, type_graphql_1.Field)(),
|
124
|
+
(0, type_graphql_1.Field)({ description: 'The URL of the application.' }),
|
125
125
|
tslib_1.__metadata("design:type", String)
|
126
126
|
], Application.prototype, "url", void 0);
|
127
127
|
tslib_1.__decorate([
|
128
128
|
(0, typeorm_1.Column)({ nullable: true }),
|
129
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
129
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'A URL to the icon for the application.' }),
|
130
130
|
tslib_1.__metadata("design:type", String)
|
131
131
|
], Application.prototype, "icon", void 0);
|
132
132
|
tslib_1.__decorate([
|
133
133
|
(0, typeorm_1.Column)(),
|
134
|
-
(0, type_graphql_1.Field)(),
|
134
|
+
(0, type_graphql_1.Field)({ description: 'The redirect URL for OAuth2 flows.' }),
|
135
135
|
tslib_1.__metadata("design:type", String)
|
136
136
|
], Application.prototype, "redirectUrl", void 0);
|
137
137
|
tslib_1.__decorate([
|
138
138
|
(0, typeorm_1.Column)({ nullable: true }),
|
139
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
139
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The webhook URL for the application to receive events.' }),
|
140
140
|
tslib_1.__metadata("design:type", String)
|
141
141
|
], Application.prototype, "webhook", void 0);
|
142
142
|
tslib_1.__decorate([
|
143
143
|
(0, typeorm_1.Column)({ nullable: true }),
|
144
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
144
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The unique key for the application (client ID).' }),
|
145
145
|
tslib_1.__metadata("design:type", String)
|
146
146
|
], Application.prototype, "appKey", void 0);
|
147
147
|
tslib_1.__decorate([
|
@@ -156,13 +156,13 @@ tslib_1.__decorate([
|
|
156
156
|
: 'varchar',
|
157
157
|
length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined
|
158
158
|
}),
|
159
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
159
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The secret key for the application (client secret).' }),
|
160
160
|
(0, type_graphql_1.Directive)('@privilege(category: "security", privilege: "query", domainOwnerGranted: true)'),
|
161
161
|
tslib_1.__metadata("design:type", String)
|
162
162
|
], Application.prototype, "appSecret", void 0);
|
163
163
|
tslib_1.__decorate([
|
164
164
|
(0, typeorm_1.Column)({ default: ApplicationStatus.DRAFT }),
|
165
|
-
(0, type_graphql_1.Field)(),
|
165
|
+
(0, type_graphql_1.Field)({ description: 'The status of the application (e.g., DRAFT, ACTIVATED).' }),
|
166
166
|
tslib_1.__metadata("design:type", String)
|
167
167
|
], Application.prototype, "status", void 0);
|
168
168
|
tslib_1.__decorate([
|
@@ -180,22 +180,22 @@ tslib_1.__decorate([
|
|
180
180
|
length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32,
|
181
181
|
default: ApplicationType.OTHERS
|
182
182
|
}),
|
183
|
-
(0, type_graphql_1.Field)(),
|
183
|
+
(0, type_graphql_1.Field)({ description: 'The type of the application.' }),
|
184
184
|
tslib_1.__metadata("design:type", String)
|
185
185
|
], Application.prototype, "type", void 0);
|
186
186
|
tslib_1.__decorate([
|
187
187
|
(0, typeorm_1.CreateDateColumn)(),
|
188
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
188
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when the application was created.' }),
|
189
189
|
tslib_1.__metadata("design:type", Date)
|
190
190
|
], Application.prototype, "createdAt", void 0);
|
191
191
|
tslib_1.__decorate([
|
192
192
|
(0, typeorm_1.UpdateDateColumn)(),
|
193
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
193
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when the application was last updated.' }),
|
194
194
|
tslib_1.__metadata("design:type", Date)
|
195
195
|
], Application.prototype, "updatedAt", void 0);
|
196
196
|
tslib_1.__decorate([
|
197
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 }),
|
198
|
+
(0, type_graphql_1.Field)(type => user_js_1.User, { nullable: true, description: 'The user who created the application.' }),
|
199
199
|
tslib_1.__metadata("design:type", user_js_1.User)
|
200
200
|
], Application.prototype, "creator", void 0);
|
201
201
|
tslib_1.__decorate([
|
@@ -204,7 +204,7 @@ tslib_1.__decorate([
|
|
204
204
|
], Application.prototype, "creatorId", void 0);
|
205
205
|
tslib_1.__decorate([
|
206
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 }),
|
207
|
+
(0, type_graphql_1.Field)(type => user_js_1.User, { nullable: true, description: 'The user who last updated the application.' }),
|
208
208
|
tslib_1.__metadata("design:type", user_js_1.User)
|
209
209
|
], Application.prototype, "updater", void 0);
|
210
210
|
tslib_1.__decorate([
|
@@ -214,6 +214,6 @@ tslib_1.__decorate([
|
|
214
214
|
exports.Application = Application = tslib_1.__decorate([
|
215
215
|
(0, typeorm_1.Entity)(),
|
216
216
|
(0, typeorm_1.Index)('ix_application_0', (application) => [application.appKey], { unique: true }),
|
217
|
-
(0, type_graphql_1.ObjectType)()
|
217
|
+
(0, type_graphql_1.ObjectType)({ description: 'Represents a third-party application that can be integrated with the system.' })
|
218
218
|
], Application);
|
219
219
|
//# sourceMappingURL=application.js.map
|
@@ -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,6DAAkD;AAClD,6CAAkD;AAElD,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,8CAA2B,CAAA;IAC3B,oCAAiB,CAAA;IACjB,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,oCAAiB,CAAA;IACjB,gCAAa,CAAA;AACf,C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AI,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
|
+
{"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,6DAAkD;AAClD,6CAAkD;AAElD,MAAM,SAAS,GAAG,YAAM,CAAC,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;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,EAAC,EAAE,WAAW,EAAE,8EAA8E,EAAE,CAAC;GAC/F,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', // The application is in a draft state and not yet active.\n ACTIVATED = 'ACTIVATED' // The application is active and can be used.\n}\n\nregisterEnumType(ApplicationStatus, {\n name: 'ApplicationStatus',\n description: 'The activation status of an application.'\n})\n\nexport enum ApplicationType {\n SELLERCRAFT = 'SELLERCRAFT', // Represents a Sellercraft application.\n XILNEX = 'XILNEX', // Represents a Xilnex application.\n MMS = 'MMS', // Represents a MMS application.\n XERO = 'XERO', // Represents a Xero application.\n OTHERS = 'OTHERS', // Represents other types of applications.\n SFTP = 'SFTP' // Represents an SFTP application.\n}\n\nregisterEnumType(ApplicationType, {\n name: 'ApplicationType',\n description: 'The type of an application.'\n})\n@Entity()\n@Index('ix_application_0', (application: Application) => [application.appKey], { unique: true })\n@ObjectType({ description: 'Represents a third-party application that can be integrated with the system.' })\nexport class Application {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for the application.' })\n readonly id?: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { description: 'The domain to which the application belongs.' })\n domain?: Domain\n\n @RelationId((application: Application) => application.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'The name of the application.' })\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'A description of the application.' })\n description?: string\n\n @Column()\n @Field(type => GraphQLEmailAddress, { description: 'The contact email for the application.' })\n email?: string\n\n @Column()\n @Field({ description: 'The URL of the application.' })\n url?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'A URL to the icon for the application.' })\n icon?: string\n\n @Column()\n @Field({ description: 'The redirect URL for OAuth2 flows.' })\n redirectUrl?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The webhook URL for the application to receive events.' })\n webhook?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The unique key for the application (client ID).' })\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, description: 'The secret key for the application (client secret).' })\n @Directive('@privilege(category: \"security\", privilege: \"query\", domainOwnerGranted: true)')\n appSecret?: string\n\n @Column({ default: ApplicationStatus.DRAFT })\n @Field({ description: 'The status of the application (e.g., DRAFT, ACTIVATED).' })\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({ description: 'The type of the application.' })\n type?: ApplicationType\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'The timestamp when the application was created.' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'The timestamp when the application was last updated.' })\n updatedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who created the application.' })\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, description: 'The user who last updated the application.' })\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"]}
|
@@ -9,7 +9,12 @@ const auth_provider_type_js_1 = require("./auth-provider-type.js");
|
|
9
9
|
let AuthProviderMutation = class AuthProviderMutation {
|
10
10
|
async createAuthProvider(authProvider, context) {
|
11
11
|
const { domain, user, tx } = context.state;
|
12
|
-
return await tx.getRepository(auth_provider_js_1.AuthProvider).save(
|
12
|
+
return await tx.getRepository(auth_provider_js_1.AuthProvider).save({
|
13
|
+
...authProvider,
|
14
|
+
domain,
|
15
|
+
creator: user,
|
16
|
+
updater: user
|
17
|
+
});
|
13
18
|
}
|
14
19
|
async updateAuthProvider(id, patch, context) {
|
15
20
|
const { domain, user, tx } = context.state;
|
@@ -17,7 +22,11 @@ let AuthProviderMutation = class AuthProviderMutation {
|
|
17
22
|
const authProvider = await repository.findOne({
|
18
23
|
where: { domain: { id: domain.id }, id }
|
19
24
|
});
|
20
|
-
return await repository.save(
|
25
|
+
return await repository.save({
|
26
|
+
...authProvider,
|
27
|
+
...patch,
|
28
|
+
updater: user
|
29
|
+
});
|
21
30
|
}
|
22
31
|
async updateMultipleAuthProvider(patches, context) {
|
23
32
|
const { domain, user, tx } = context.state;
|
@@ -33,8 +42,13 @@ let AuthProviderMutation = class AuthProviderMutation {
|
|
33
42
|
if (foundAuthProvider) {
|
34
43
|
throw new Error('Duplicated authProvider found');
|
35
44
|
}
|
36
|
-
const result = await tx.getRepository(auth_provider_js_1.AuthProvider).save(
|
37
|
-
|
45
|
+
const result = await tx.getRepository(auth_provider_js_1.AuthProvider).save({
|
46
|
+
domain: domain,
|
47
|
+
creator: user,
|
48
|
+
updater: user,
|
49
|
+
...newRecord
|
50
|
+
});
|
51
|
+
results.push({ ...result, cuFlag: '+' });
|
38
52
|
}
|
39
53
|
}
|
40
54
|
if (_updateRecords.length > 0) {
|
@@ -43,8 +57,12 @@ let AuthProviderMutation = class AuthProviderMutation {
|
|
43
57
|
const authProvider = await tx.getRepository(auth_provider_js_1.AuthProvider).findOne({
|
44
58
|
where: { domain: { id: domain.id }, id: updatedRecord.id }
|
45
59
|
});
|
46
|
-
const result = await tx.getRepository(auth_provider_js_1.AuthProvider).save(
|
47
|
-
|
60
|
+
const result = await tx.getRepository(auth_provider_js_1.AuthProvider).save({
|
61
|
+
...authProvider,
|
62
|
+
...updatedRecord,
|
63
|
+
updater: user
|
64
|
+
});
|
65
|
+
results.push({ ...result, cuFlag: 'M' });
|
48
66
|
}
|
49
67
|
}
|
50
68
|
return results;
|
@@ -63,7 +81,11 @@ let AuthProviderMutation = class AuthProviderMutation {
|
|
63
81
|
}
|
64
82
|
});
|
65
83
|
await Promise.all(authProviders.map(async (authProvider) => {
|
66
|
-
await tx.getRepository(auth_provider_js_1.AuthProvider).save(
|
84
|
+
await tx.getRepository(auth_provider_js_1.AuthProvider).save({
|
85
|
+
...authProvider,
|
86
|
+
deletedAt: new Date(),
|
87
|
+
updater: user
|
88
|
+
});
|
67
89
|
}));
|
68
90
|
return true;
|
69
91
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth-provider-mutation.js","sourceRoot":"","sources":["../../../server/service/auth-provider/auth-provider-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,yDAAiD;AACjD,mEAA4E;AAGrE,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAGzB,AAAN,KAAK,CAAC,kBAAkB,CACD,YAA6B,EAC3C,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,+BAAY,CAAC,CAAC,IAAI,iCAC3C,YAAY,KACf,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAA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AC,OAAO,CAAC,EAAE,CAAC,CAAC,+BAAY,CAAC,CAAC;IAEjC,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,yCAAiB,CAAC,CAAC,CAAA;IAC3C,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;sEAiDP;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8DAMrD;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;IAE1B,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;+DAqBP;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mCAAmC,CAAC;IAC9C,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,qCAAqC,EAAE,CAAC;IACjD,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wEAiB/D;+BAtJU,oBAAoB;IADhC,IAAA,uBAAQ,EAAC,+BAAY,CAAC;GACV,oBAAoB,CAuJhC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { AuthProvider } from './auth-provider.js'\nimport { NewAuthProvider, AuthProviderPatch } from './auth-provider-type.js'\n\n@Resolver(AuthProvider)\nexport class AuthProviderMutation {\n @Directive('@transaction')\n @Mutation(returns => AuthProvider, { description: 'To create new AuthProvider' })\n async createAuthProvider(\n @Arg('authProvider') authProvider: NewAuthProvider,\n @Ctx() context: ResolverContext\n ): Promise<AuthProvider> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(AuthProvider).save({\n ...authProvider,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => AuthProvider, { description: 'To modify AuthProvider information' })\n async updateAuthProvider(\n @Arg('id') id: string,\n @Arg('patch') patch: AuthProviderPatch,\n @Ctx() context: ResolverContext\n ): Promise<AuthProvider> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(AuthProvider)\n const authProvider = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n return await repository.save({\n ...authProvider,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [AuthProvider])\n async updateMultipleAuthProvider(\n @Arg('patches', type => [AuthProviderPatch]) patches: AuthProviderPatch[],\n @Ctx() context: ResolverContext\n ): Promise<AuthProvider[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n let foundAuthProvider = await tx.getRepository(AuthProvider).findOne({\n where: { domain: { id: domain.id }, type: newRecord.type }\n })\n\n if (foundAuthProvider) {\n throw new Error('Duplicated authProvider found')\n }\n\n const result: AuthProvider = await tx.getRepository(AuthProvider).save({\n domain: domain,\n creator: user,\n updater: user,\n ...newRecord\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updatedRecord = _updateRecords[i]\n const authProvider = await tx.getRepository(AuthProvider).findOne({\n where: { domain: { id: domain.id }, id: updatedRecord.id }\n })\n\n const result = await tx.getRepository(AuthProvider).save({\n ...authProvider,\n ...updatedRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete AuthProvider' })\n async deleteAuthProvider(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(AuthProvider).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteAuthProviders(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n const { domain, user, tx } = context.state\n\n const authProviders = await tx.getRepository(AuthProvider).find({\n where: {\n domain: { id: domain.id },\n id: In(ids)\n }\n })\n\n await Promise.all(\n authProviders.map(async (authProvider: AuthProvider) => {\n await tx.getRepository(AuthProvider).save({\n ...authProvider,\n deletedAt: new Date(),\n updater: user\n })\n })\n )\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted:true)')\n @Mutation(returns => Boolean, { description: 'To synchronize auth-providers users' })\n async synchronizeAuthProviderUsers(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(AuthProvider)\n const authProvider = await repository.findOne({\n where: { domain: { id: domain.id }, id },\n relations: ['domain']\n })\n\n const { type } = authProvider\n const { synchronizeUsers } = AuthProvider.getAuthProviderImpl(type) || {}\n\n if (synchronizeUsers) {\n return await synchronizeUsers(authProvider, context)\n } else {\n throw new Error(`No AuthProviderImpl for the type '${type}'`)\n }\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"auth-provider-mutation.js","sourceRoot":"","sources":["../../../server/service/auth-provider/auth-provider-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,yDAAiD;AACjD,mEAA4E;AA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ACzB,IAAA,wBAAS,EAAC,mCAAmC,CAAC;IAC9C,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,qCAAqC,EAAE,CAAC;IACjD,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wEAiB/D;+BAtJU,oBAAoB;IADhC,IAAA,uBAAQ,EAAC,+BAAY,CAAC;GACV,oBAAoB,CAuJhC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { AuthProvider } from './auth-provider.js'\nimport { NewAuthProvider, AuthProviderPatch } from './auth-provider-type.js'\n\n@Resolver(AuthProvider)\nexport class AuthProviderMutation {\n @Directive('@transaction')\n @Mutation(returns => AuthProvider, { description: 'To create new AuthProvider' })\n async createAuthProvider(\n @Arg('authProvider') authProvider: NewAuthProvider,\n @Ctx() context: ResolverContext\n ): Promise<AuthProvider> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(AuthProvider).save({\n ...authProvider,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => AuthProvider, { description: 'To modify AuthProvider information' })\n async updateAuthProvider(\n @Arg('id') id: string,\n @Arg('patch') patch: AuthProviderPatch,\n @Ctx() context: ResolverContext\n ): Promise<AuthProvider> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(AuthProvider)\n const authProvider = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n return await repository.save({\n ...authProvider,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [AuthProvider])\n async updateMultipleAuthProvider(\n @Arg('patches', type => [AuthProviderPatch]) patches: AuthProviderPatch[],\n @Ctx() context: ResolverContext\n ): Promise<AuthProvider[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n let foundAuthProvider = await tx.getRepository(AuthProvider).findOne({\n where: { domain: { id: domain.id }, type: newRecord.type }\n })\n\n if (foundAuthProvider) {\n throw new Error('Duplicated authProvider found')\n }\n\n const result: AuthProvider = await tx.getRepository(AuthProvider).save({\n domain: domain,\n creator: user,\n updater: user,\n ...newRecord\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updatedRecord = _updateRecords[i]\n const authProvider = await tx.getRepository(AuthProvider).findOne({\n where: { domain: { id: domain.id }, id: updatedRecord.id }\n })\n\n const result = await tx.getRepository(AuthProvider).save({\n ...authProvider,\n ...updatedRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete AuthProvider' })\n async deleteAuthProvider(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(AuthProvider).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteAuthProviders(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n const { domain, user, tx } = context.state\n\n const authProviders = await tx.getRepository(AuthProvider).find({\n where: {\n domain: { id: domain.id },\n id: In(ids)\n }\n })\n\n await Promise.all(\n authProviders.map(async (authProvider: AuthProvider) => {\n await tx.getRepository(AuthProvider).save({\n ...authProvider,\n deletedAt: new Date(),\n updater: user\n })\n })\n )\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted:true)')\n @Mutation(returns => Boolean, { description: 'To synchronize auth-providers users' })\n async synchronizeAuthProviderUsers(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(AuthProvider)\n const authProvider = await repository.findOne({\n where: { domain: { id: domain.id }, id },\n relations: ['domain']\n })\n\n const { type } = authProvider\n const { synchronizeUsers } = AuthProvider.getAuthProviderImpl(type) || {}\n\n if (synchronizeUsers) {\n return await synchronizeUsers(authProvider, context)\n } else {\n throw new Error(`No AuthProviderImpl for the type '${type}'`)\n }\n }\n}\n"]}
|
@@ -8,30 +8,35 @@ let AuthProviderParameterSpec = class AuthProviderParameterSpec {
|
|
8
8
|
};
|
9
9
|
exports.AuthProviderParameterSpec = AuthProviderParameterSpec;
|
10
10
|
tslib_1.__decorate([
|
11
|
-
(0, type_graphql_1.Field)(),
|
11
|
+
(0, type_graphql_1.Field)({ description: 'The data type of the parameter (e.g., text, number, boolean).' }),
|
12
12
|
tslib_1.__metadata("design:type", String)
|
13
13
|
], AuthProviderParameterSpec.prototype, "type", void 0);
|
14
14
|
tslib_1.__decorate([
|
15
|
-
(0, type_graphql_1.Field)(),
|
15
|
+
(0, type_graphql_1.Field)({ description: 'The human-readable label for the parameter, shown in UI.' }),
|
16
16
|
tslib_1.__metadata("design:type", String)
|
17
17
|
], AuthProviderParameterSpec.prototype, "label", void 0);
|
18
18
|
tslib_1.__decorate([
|
19
|
-
(0, type_graphql_1.Field)(),
|
19
|
+
(0, type_graphql_1.Field)({ description: 'The name of the parameter, used as the key in the params object.' }),
|
20
20
|
tslib_1.__metadata("design:type", String)
|
21
21
|
], AuthProviderParameterSpec.prototype, "name", void 0);
|
22
22
|
tslib_1.__decorate([
|
23
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
23
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Placeholder text for the input field.' }),
|
24
24
|
tslib_1.__metadata("design:type", String)
|
25
25
|
], AuthProviderParameterSpec.prototype, "placeholder", void 0);
|
26
26
|
tslib_1.__decorate([
|
27
|
-
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, {
|
27
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, {
|
28
|
+
nullable: true,
|
29
|
+
description: 'Additional properties for the parameter (e.g., min, max).'
|
30
|
+
}),
|
28
31
|
tslib_1.__metadata("design:type", Object)
|
29
32
|
], AuthProviderParameterSpec.prototype, "property", void 0);
|
30
33
|
tslib_1.__decorate([
|
31
|
-
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
34
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true, description: 'CSS styles for the input field.' }),
|
32
35
|
tslib_1.__metadata("design:type", Object)
|
33
36
|
], AuthProviderParameterSpec.prototype, "styles", void 0);
|
34
37
|
exports.AuthProviderParameterSpec = AuthProviderParameterSpec = tslib_1.__decorate([
|
35
|
-
(0, type_graphql_1.ObjectType)(
|
38
|
+
(0, type_graphql_1.ObjectType)({
|
39
|
+
description: 'Describes a single configuration parameter for an authentication provider.'
|
40
|
+
})
|
36
41
|
], AuthProviderParameterSpec);
|
37
42
|
//# sourceMappingURL=auth-provider-parameter-spec.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth-provider-parameter-spec.js","sourceRoot":"","sources":["../../../server/service/auth-provider/auth-provider-parameter-spec.ts"],"names":[],"mappings":";;;;AAAA,+CAAgD;AAEhD,iDAAoD;
|
1
|
+
{"version":3,"file":"auth-provider-parameter-spec.js","sourceRoot":"","sources":["../../../server/service/auth-provider/auth-provider-parameter-spec.ts"],"names":[],"mappings":";;;;AAAA,+CAAgD;AAEhD,iDAAoD;AAK7C,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;CAqBrC,CAAA;AArBY,8DAAyB;AAEpC;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,+DAA+D,EAAE,CAAC;;uDAC5E;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,0DAA0D,EAAE,CAAC;;wDACtE;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,kEAAkE,EAAE,CAAC;;uDAC/E;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;;8DAC5D;AAMpB;IAJC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE;QAC3B,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,2DAA2D;KACzE,CAAC;;2DAC+B;AAGjC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,iCAAiC,EAAE,CAAC;;yDACjE;oCApBpB,yBAAyB;IAHrC,IAAA,yBAAU,EAAC;QACV,WAAW,EAAE,4EAA4E;KAC1F,CAAC;GACW,yBAAyB,CAqBrC","sourcesContent":["import { Field, ObjectType } from 'type-graphql'\n\nimport { ScalarObject } from '@things-factory/shell'\n\n@ObjectType({\n description: 'Describes a single configuration parameter for an authentication provider.'\n})\nexport class AuthProviderParameterSpec {\n @Field({ description: 'The data type of the parameter (e.g., text, number, boolean).' })\n type: string\n\n @Field({ description: 'The human-readable label for the parameter, shown in UI.' })\n label: string\n\n @Field({ description: 'The name of the parameter, used as the key in the params object.' })\n name: string\n\n @Field({ nullable: true, description: 'Placeholder text for the input field.' })\n placeholder?: string\n\n @Field(type => ScalarObject, {\n nullable: true,\n description: 'Additional properties for the parameter (e.g., min, max).'\n })\n property?: { [key: string]: any }\n\n @Field(type => ScalarObject, { nullable: true, description: 'CSS styles for the input field.' })\n styles?: { [key: string]: any }\n}\n"]}
|