@friggframework/core 2.0.0--canary.397.155fecd.0 → 2.0.0--canary.398.c9e5d61.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/README.md +50 -933
- package/core/create-handler.js +0 -1
- package/database/models/WebsocketConnection.js +5 -0
- package/handlers/app-handler-helpers.js +3 -0
- package/handlers/backend-utils.js +34 -35
- package/handlers/routers/auth.js +14 -3
- package/handlers/routers/integration-defined-routers.js +5 -8
- package/handlers/routers/middleware/loadUser.js +15 -0
- package/handlers/routers/middleware/requireLoggedInUser.js +12 -0
- package/handlers/routers/user.js +5 -25
- package/handlers/workers/integration-defined-workers.js +3 -6
- package/index.js +14 -1
- package/integrations/create-frigg-backend.js +31 -0
- package/integrations/index.js +5 -0
- package/integrations/integration-base.js +44 -42
- package/integrations/integration-factory.js +251 -0
- package/integrations/integration-router.js +173 -291
- package/integrations/integration-user.js +144 -0
- package/integrations/options.js +1 -1
- package/integrations/test/integration-base.test.js +144 -0
- package/module-plugin/auther.js +393 -0
- package/module-plugin/entity-manager.js +70 -0
- package/{modules → module-plugin}/index.js +6 -0
- package/module-plugin/module-factory.js +61 -0
- package/{modules → module-plugin}/test/mock-api/api.js +3 -8
- package/{modules → module-plugin}/test/mock-api/definition.js +8 -12
- package/package.json +5 -5
- package/types/integrations/index.d.ts +6 -2
- package/types/module-plugin/index.d.ts +21 -4
- package/credential/credential-repository.js +0 -42
- package/credential/use-cases/get-credential-for-user.js +0 -21
- package/credential/use-cases/update-authentication-status.js +0 -15
- package/handlers/app-definition-loader.js +0 -38
- package/integrations/integration-repository.js +0 -67
- package/integrations/integration.js +0 -233
- package/integrations/tests/doubles/dummy-integration-class.js +0 -90
- package/integrations/tests/doubles/test-integration-repository.js +0 -89
- package/integrations/tests/use-cases/create-integration.test.js +0 -124
- package/integrations/tests/use-cases/delete-integration-for-user.test.js +0 -143
- package/integrations/tests/use-cases/get-integration-for-user.test.js +0 -143
- package/integrations/tests/use-cases/get-integration-instance.test.js +0 -169
- package/integrations/tests/use-cases/get-integrations-for-user.test.js +0 -169
- package/integrations/tests/use-cases/get-possible-integrations.test.js +0 -188
- package/integrations/tests/use-cases/update-integration-messages.test.js +0 -142
- package/integrations/tests/use-cases/update-integration-status.test.js +0 -103
- package/integrations/tests/use-cases/update-integration.test.js +0 -134
- package/integrations/use-cases/create-integration.js +0 -72
- package/integrations/use-cases/delete-integration-for-user.js +0 -73
- package/integrations/use-cases/get-integration-for-user.js +0 -79
- package/integrations/use-cases/get-integration-instance.js +0 -84
- package/integrations/use-cases/get-integrations-for-user.js +0 -77
- package/integrations/use-cases/get-possible-integrations.js +0 -27
- package/integrations/use-cases/index.js +0 -11
- package/integrations/use-cases/update-integration-messages.js +0 -31
- package/integrations/use-cases/update-integration-status.js +0 -28
- package/integrations/use-cases/update-integration.js +0 -92
- package/integrations/utils/map-integration-dto.js +0 -36
- package/modules/module-factory.js +0 -54
- package/modules/module-repository.js +0 -72
- package/modules/module.js +0 -251
- package/modules/tests/doubles/test-module-factory.js +0 -16
- package/modules/tests/doubles/test-module-repository.js +0 -19
- package/modules/use-cases/get-entities-for-user.js +0 -32
- package/modules/use-cases/get-entity-options-by-id.js +0 -58
- package/modules/use-cases/get-entity-options-by-type.js +0 -34
- package/modules/use-cases/get-module-instance-from-type.js +0 -31
- package/modules/use-cases/get-module.js +0 -56
- package/modules/use-cases/refresh-entity-options.js +0 -58
- package/modules/use-cases/test-module-auth.js +0 -54
- package/modules/utils/map-module-dto.js +0 -18
- package/user/tests/doubles/test-user-repository.js +0 -72
- package/user/tests/use-cases/create-individual-user.test.js +0 -24
- package/user/tests/use-cases/create-organization-user.test.js +0 -28
- package/user/tests/use-cases/create-token-for-user-id.test.js +0 -19
- package/user/tests/use-cases/get-user-from-bearer-token.test.js +0 -64
- package/user/tests/use-cases/login-user.test.js +0 -140
- package/user/use-cases/create-individual-user.js +0 -61
- package/user/use-cases/create-organization-user.js +0 -47
- package/user/use-cases/create-token-for-user-id.js +0 -30
- package/user/use-cases/get-user-from-bearer-token.js +0 -77
- package/user/use-cases/login-user.js +0 -122
- package/user/user-repository.js +0 -62
- package/user/user.js +0 -77
- /package/{modules → module-plugin}/ModuleConstants.js +0 -0
- /package/{modules → module-plugin}/credential.js +0 -0
- /package/{modules → module-plugin}/entity.js +0 -0
- /package/{modules → module-plugin}/manager.js +0 -0
- /package/{modules → module-plugin}/requester/api-key.js +0 -0
- /package/{modules → module-plugin}/requester/basic.js +0 -0
- /package/{modules → module-plugin}/requester/oauth-2.js +0 -0
- /package/{modules → module-plugin}/requester/requester.js +0 -0
- /package/{modules → module-plugin}/requester/requester.test.js +0 -0
- /package/{modules → module-plugin}/test/auther.test.js +0 -0
- /package/{modules → module-plugin}/test/mock-api/mocks/hubspot.js +0 -0
package/user/user-repository.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
const { Token } = require('../database/models/Token');
|
|
2
|
-
const { IndividualUser } = require('../database/models/IndividualUser');
|
|
3
|
-
const { OrganizationUser } = require('../database/models/OrganizationUser');
|
|
4
|
-
|
|
5
|
-
class UserRepository {
|
|
6
|
-
/**
|
|
7
|
-
* @param {Object} userConfig - The user config in the app definition.
|
|
8
|
-
*/
|
|
9
|
-
constructor({ userConfig }) {
|
|
10
|
-
this.IndividualUser = IndividualUser;
|
|
11
|
-
this.OrganizationUser = OrganizationUser;
|
|
12
|
-
this.Token = Token;
|
|
13
|
-
this.userConfig = userConfig;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async getSessionToken(token) {
|
|
17
|
-
const jsonToken =
|
|
18
|
-
this.Token.getJSONTokenFromBase64BufferToken(token);
|
|
19
|
-
const sessionToken =
|
|
20
|
-
await this.Token.validateAndGetTokenFromJSONToken(jsonToken);
|
|
21
|
-
return sessionToken;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async findOrganizationUserById(userId) {
|
|
25
|
-
return this.OrganizationUser.findById(userId);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async findIndividualUserById(userId) {
|
|
29
|
-
return this.IndividualUser.findById(userId);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async createToken(userId, rawToken, minutes = 120) {
|
|
33
|
-
const createdToken = await this.Token.createTokenWithExpire(
|
|
34
|
-
userId,
|
|
35
|
-
rawToken,
|
|
36
|
-
minutes
|
|
37
|
-
);
|
|
38
|
-
return this.Token.createBase64BufferToken(createdToken, rawToken);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async createIndividualUser(params) {
|
|
42
|
-
return this.IndividualUser.create(params);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async createOrganizationUser(params) {
|
|
46
|
-
return this.OrganizationUser.create(params);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async findIndividualUserByUsername(username) {
|
|
50
|
-
return this.IndividualUser.findOne({ username });
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async findIndividualUserByAppUserId(appUserId) {
|
|
54
|
-
return this.IndividualUser.getUserByAppUserId(appUserId);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async findOrganizationUserByAppOrgId(appOrgId) {
|
|
58
|
-
return this.OrganizationUser.getUserByAppOrgId(appOrgId);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
module.exports = { UserRepository };
|
package/user/user.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
const bcrypt = require('bcryptjs');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a user in the system. The User class is a domain entity,
|
|
5
|
-
* @class User
|
|
6
|
-
*/
|
|
7
|
-
class User {
|
|
8
|
-
/**
|
|
9
|
-
* Creates a new User instance.
|
|
10
|
-
* @param {import('../database/models/IndividualUser').IndividualUser} [individualUser=null] - The individual user for the user.
|
|
11
|
-
* @param {import('../database/models/OrganizationUser').OrganizationUser} [organizationUser=null] - The organization user for the user.
|
|
12
|
-
* @param {boolean} [usePassword=false] - Whether the user has a password.
|
|
13
|
-
* @param {string} [primary='individual'] - The primary user type.
|
|
14
|
-
* @param {boolean} [individualUserRequired=true] - Whether the user is required to have an individual user.
|
|
15
|
-
* @param {boolean} [organizationUserRequired=false] - Whether the user is required to have an organization user.
|
|
16
|
-
*/
|
|
17
|
-
constructor(individualUser = null, organizationUser = null, usePassword = false, primary = 'individual', individualUserRequired = true, organizationUserRequired = false) {
|
|
18
|
-
this.individualUser = individualUser;
|
|
19
|
-
this.organizationUser = organizationUser;
|
|
20
|
-
this.usePassword = usePassword;
|
|
21
|
-
|
|
22
|
-
this.config = {
|
|
23
|
-
primary,
|
|
24
|
-
individualUserRequired,
|
|
25
|
-
organizationUserRequired,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
getPrimaryUser() {
|
|
30
|
-
if (this.config.primary === 'organization') {
|
|
31
|
-
return this.organizationUser;
|
|
32
|
-
}
|
|
33
|
-
return this.individualUser;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
getId() {
|
|
37
|
-
return this.getPrimaryUser()?.id;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
isPasswordRequired() {
|
|
41
|
-
return this.usePassword;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
isPasswordValid(password) {
|
|
45
|
-
if (!this.isPasswordRequired()) {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return bcrypt.compareSync(password, this.getPrimaryUser().hashword);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
setIndividualUser(individualUser) {
|
|
53
|
-
this.individualUser = individualUser;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
setOrganizationUser(organizationUser) {
|
|
57
|
-
this.organizationUser = organizationUser;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
isOrganizationUserRequired() {
|
|
61
|
-
return this.config.organizationUserRequired;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
isIndividualUserRequired() {
|
|
65
|
-
return this.config.individualUserRequired;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
getIndividualUser() {
|
|
69
|
-
return this.individualUser;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
getOrganizationUser() {
|
|
73
|
-
return this.organizationUser;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
module.exports = { User };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|