@friggframework/core 2.0.0--canary.396.6862738.0 → 2.0.0--canary.397.c07f148.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.
Files changed (69) hide show
  1. package/README.md +931 -50
  2. package/core/create-handler.js +1 -0
  3. package/credential/credential-repository.js +48 -1
  4. package/credential/use-cases/update-authentication-status.js +15 -0
  5. package/handlers/backend-utils.js +34 -31
  6. package/handlers/routers/auth.js +1 -15
  7. package/index.js +1 -5
  8. package/integrations/integration-base.js +133 -40
  9. package/integrations/integration-repository.js +39 -3
  10. package/integrations/integration-router.js +109 -85
  11. package/integrations/tests/doubles/dummy-integration-class.js +90 -0
  12. package/integrations/tests/doubles/test-integration-repository.js +89 -0
  13. package/integrations/tests/use-cases/create-integration.test.js +124 -0
  14. package/integrations/tests/use-cases/delete-integration-for-user.test.js +143 -0
  15. package/integrations/tests/use-cases/get-integration-for-user.test.js +143 -0
  16. package/integrations/tests/use-cases/get-integration-instance.test.js +169 -0
  17. package/integrations/tests/use-cases/get-integrations-for-user.test.js +169 -0
  18. package/integrations/tests/use-cases/get-possible-integrations.test.js +188 -0
  19. package/integrations/tests/use-cases/update-integration-messages.test.js +142 -0
  20. package/integrations/tests/use-cases/update-integration-status.test.js +103 -0
  21. package/integrations/tests/use-cases/update-integration.test.js +134 -0
  22. package/integrations/use-cases/create-integration.js +25 -12
  23. package/integrations/use-cases/delete-integration-for-user.js +21 -2
  24. package/integrations/use-cases/get-integration-for-user.js +28 -13
  25. package/integrations/use-cases/get-integration-instance-by-definition.js +67 -0
  26. package/integrations/use-cases/get-integration-instance.js +20 -11
  27. package/integrations/use-cases/get-integrations-for-user.js +22 -10
  28. package/integrations/use-cases/get-possible-integrations.js +27 -0
  29. package/integrations/use-cases/update-integration-messages.js +31 -0
  30. package/integrations/use-cases/update-integration-status.js +28 -0
  31. package/integrations/use-cases/update-integration.js +23 -13
  32. package/integrations/utils/map-integration-dto.js +0 -1
  33. package/{module-plugin → modules}/entity.js +1 -0
  34. package/{module-plugin → modules}/index.js +0 -4
  35. package/{module-plugin/module-service.js → modules/module-factory.js} +9 -5
  36. package/modules/module-repository.js +107 -0
  37. package/modules/module.js +218 -0
  38. package/modules/tests/doubles/test-module-factory.js +16 -0
  39. package/modules/tests/doubles/test-module-repository.js +19 -0
  40. package/{module-plugin → modules}/use-cases/get-entities-for-user.js +1 -1
  41. package/modules/use-cases/get-entity-options-by-id.js +58 -0
  42. package/modules/use-cases/get-entity-options-by-type.js +34 -0
  43. package/modules/use-cases/get-module-instance-from-type.js +31 -0
  44. package/modules/use-cases/get-module.js +56 -0
  45. package/modules/use-cases/process-authorization-callback.js +108 -0
  46. package/modules/use-cases/refresh-entity-options.js +58 -0
  47. package/modules/use-cases/test-module-auth.js +54 -0
  48. package/{module-plugin → modules}/utils/map-module-dto.js +1 -1
  49. package/package.json +5 -5
  50. package/syncs/sync.js +0 -1
  51. package/types/module-plugin/index.d.ts +0 -35
  52. package/types/syncs/index.d.ts +0 -2
  53. package/integrations/integration.js +0 -233
  54. package/integrations/test/integration-base.test.js +0 -144
  55. package/module-plugin/manager.js +0 -169
  56. package/module-plugin/module-factory.js +0 -42
  57. package/module-plugin/module-repository.js +0 -70
  58. package/module-plugin/module.js +0 -329
  59. /package/{module-plugin → modules}/ModuleConstants.js +0 -0
  60. /package/{module-plugin → modules}/credential.js +0 -0
  61. /package/{module-plugin → modules}/requester/api-key.js +0 -0
  62. /package/{module-plugin → modules}/requester/basic.js +0 -0
  63. /package/{module-plugin → modules}/requester/oauth-2.js +0 -0
  64. /package/{module-plugin → modules}/requester/requester.js +0 -0
  65. /package/{module-plugin → modules}/requester/requester.test.js +0 -0
  66. /package/{module-plugin → modules}/test/auther.test.js +0 -0
  67. /package/{module-plugin → modules}/test/mock-api/api.js +0 -0
  68. /package/{module-plugin → modules}/test/mock-api/definition.js +0 -0
  69. /package/{module-plugin → modules}/test/mock-api/mocks/hubspot.js +0 -0
@@ -1,169 +0,0 @@
1
- const { Delegate } = require('../core');
2
- const { Credential } = require('./credential');
3
- const { Entity } = require('./entity');
4
- const { get } = require('../assertions');
5
-
6
- class ModuleManager extends Delegate {
7
- static Entity = Entity;
8
- static Credential = Credential;
9
-
10
- constructor(params) {
11
- super(params);
12
- this.userId = get(params, 'userId', null); // Making this non-required
13
- }
14
-
15
- static getName() {
16
- throw new Error('Module name is not defined');
17
- }
18
-
19
- static async getInstance(params) {
20
- throw new Error(
21
- 'getInstance is not implemented. It is required for ModuleManager. '
22
- );
23
- }
24
-
25
- static async getEntitiesForUserId(userId) {
26
- // Only return non-internal fields. Leverages "select" and "options" to non-excepted fields and a pure object.
27
- const list = await this.Entity.find(
28
- { user: userId },
29
- '-dateCreated -dateUpdated -user -credentials -credential -__t -__v',
30
- { lean: true }
31
- );
32
- return list.map((entity) => ({
33
- id: entity._id,
34
- type: this.getName(),
35
- ...entity,
36
- }));
37
- }
38
-
39
- async getEntityId() {
40
- const list = await Entity.find({ user: this.userId });
41
- if (list.length > 1) {
42
- throw new Error(
43
- 'There should not be more than one entity associated with a user for this specific class type'
44
- );
45
- }
46
- if (list.length == 0) {
47
- return null;
48
- }
49
- return list[0].id;
50
- }
51
-
52
- async validateAuthorizationRequirements() {
53
- const requirements = await this.getAuthorizationRequirements();
54
- let valid = true;
55
- if (['oauth1', 'oauth2'].includes(requirements.type) && !requirements.url) {
56
- valid = false;
57
- }
58
- return valid;
59
- }
60
-
61
- async getAuthorizationRequirements(params) {
62
- // this function must return a dictionary with the following format
63
- // node only url key is required. Data would be used for Base Authentication
64
- // let returnData = {
65
- // url: "callback url for the data or teh redirect url for login",
66
- // type: one of the types defined in modules/Constants.js
67
- // data: ["required", "fields", "we", "may", "need"]
68
- // }
69
- throw new Error(
70
- 'Authorization requirements method getAuthorizationRequirements() is not defined in the class'
71
- );
72
- }
73
-
74
- async testAuth(params) {
75
- // this function must invoke a method on the API using authentication
76
- // if it fails, an exception should be thrown
77
- throw new Error(
78
- 'Authentication test method testAuth() is not defined in the class'
79
- );
80
- }
81
-
82
- async processAuthorizationCallback(params) {
83
- // this function takes in a dictionary of callback information along with
84
- // a unique user id to associate with the entity in the form of
85
- // {
86
- // userId: "some id",
87
- // data: {}
88
- // }
89
-
90
- throw new Error(
91
- 'Authorization requirements method processAuthorizationCallback() is not defined in the class'
92
- );
93
- }
94
-
95
- //----------------------------------------------------------------------------------------------------
96
- // optional
97
-
98
- async getEntityOptions() {
99
- // May not be needed if the callback already creates the entity, such as in situations
100
- // like HubSpot where the account is determined in the authorization flow.
101
- // This should only be used in situations such as FreshBooks where the user needs to make
102
- // an account decision on the front end.
103
- throw new Error(
104
- 'Entity requirement method getEntityOptions() is not defined in the class'
105
- );
106
- }
107
-
108
- async findOrCreateEntity(params) {
109
- // May not be needed if the callback already creates the entity, such as in situations
110
- // like HubSpot where the account is determined in the authorization flow.
111
- // This should only be used in situations such as FreshBooks where the user needs to make
112
- // an account decision on the front end.
113
- throw new Error(
114
- 'Entity requirement method findOrCreateEntity() is not defined in the class'
115
- );
116
- }
117
-
118
- async getAllSyncObjects(SyncClass) {
119
- // takes in a Sync class and will return all objects associated with the SyncClass in an array
120
- // in the form of
121
- // [
122
- // {...object1},{...object2}...
123
- // ]
124
-
125
- throw new Error(
126
- 'The method "getAllSyncObjects()" is not defined in the class'
127
- );
128
- }
129
-
130
- async batchCreateSyncObjects(syncObjects, syncManager) {
131
- // takes in an array of Sync objects that has two pieces of data that
132
- // are important to the updating module:
133
- // 1. obj.data -> The data mapped to the obj.keys data
134
- // 2. obj.syncId -> the id of the newly created sync object in our database. You will need to update
135
- // the sync object in the database with the your id associated with this data. You
136
- // can do this by calling the SyncManager function updateSyncObject.
137
- // [
138
- // syncObject1,syncObject2, ...
139
- // ]
140
-
141
- throw new Error(
142
- 'The method "batchUpdateSyncObjects()" is not defined in the class'
143
- );
144
- }
145
-
146
- async batchUpdateSyncObjects(syncObjects, syncManager) {
147
- // takes in an array of Sync objects that has two pieces of data that
148
- // are important to the updating module:
149
- // 1. obj.data -> The data mapped to the obj.keys data
150
- // 2. obj.moduleObjectIds[this.constructor.getName()] -> Indexed from the point of view of the module manager
151
- // it will return a json object holding all of the keys
152
- // required update this datapoint. an example would be:
153
- // {companyId:12, email:"test@test.com"}
154
- // [
155
- // syncObject1,syncObject2, ...
156
- // ]
157
-
158
- throw new Error(
159
- 'The method "batchUpdateSyncObjects()" is not defined in the class'
160
- );
161
- }
162
-
163
- async markCredentialsInvalid() {
164
- this.credential.auth_is_valid = false;
165
- return await this.credential.save();
166
- }
167
- }
168
-
169
- module.exports = { ModuleManager };
@@ -1,42 +0,0 @@
1
- const { ModuleRepository } = require('./module-repository');
2
- const { ModuleService } = require('./module-service');
3
- const { Module } = require('./module');
4
-
5
- class ModuleFactory {
6
- constructor(...params) {
7
- this.moduleDefinitions = params;
8
- this.moduleTypes = this.moduleDefinitions.map((def) => def.moduleName);
9
- this.moduleRepository = new ModuleRepository();
10
- this.moduleService = new ModuleService({
11
- moduleRepository: this.moduleRepository,
12
- moduleDefinitions: this.moduleDefinitions,
13
- });
14
- }
15
-
16
- checkIsValidType(entityType) {
17
- return this.moduleTypes.includes(entityType);
18
- }
19
-
20
- getModuleDefinitionFromTypeName(typeName) {
21
- return;
22
- }
23
-
24
- async getModuleInstanceFromEntityId(entityId, userId) {
25
- return this.moduleService.getModuleInstance(entityId, userId);
26
- }
27
-
28
- async getInstanceFromTypeName(typeName, userId) {
29
- const moduleDefinition = this.moduleDefinitions.find(
30
- (def) => def.getName() === typeName
31
- );
32
- if (!moduleDefinition) {
33
- throw new Error(`Module definition not found for type: ${typeName}`);
34
- }
35
- return new Module({
36
- userId,
37
- definition: moduleDefinition,
38
- });
39
- }
40
- }
41
-
42
- module.exports = { ModuleFactory };
@@ -1,70 +0,0 @@
1
- const { Entity } = require('./entity');
2
-
3
- class ModuleRepository {
4
- async findEntityById(entityId) {
5
- const entity = await Entity.findById(entityId, undefined, { lean: true }).populate('credential');
6
- if (!entity) {
7
- throw new Error(`Entity ${entityId} not found`);
8
- }
9
-
10
- return {
11
- id: entity._id,
12
- accountId: entity.accountId,
13
- credential: entity.credential,
14
- userId: entity.user.toString(),
15
- name: entity.name,
16
- externalId: entity.externalId,
17
- type: entity.__t,
18
- moduleName: entity.moduleName,
19
- };
20
- }
21
-
22
- async findEntitiesByIds(entitiesIds) {
23
- const entitiesRecords = await Entity.find({ _id: { $in: entitiesIds } }, '', { lean: true }).populate('credential');
24
-
25
- // todo: this is a workaround needed while we create an integration with the same entity twice
26
- if (entitiesRecords.length !== entitiesIds.length && entitiesIds[0] !== entitiesIds[1]) {
27
- throw new Error(`Some entities not found`);
28
- }
29
-
30
- return entitiesRecords.map(e => ({
31
- id: e._id,
32
- accountId: e.accountId,
33
- credential: e.credential,
34
- userId: e.user.toString(),
35
- name: e.name,
36
- externalId: e.externalId,
37
- type: e.__t,
38
- moduleName: e.moduleName,
39
- }));
40
- }
41
-
42
- async findEntitiesByUserId(userId) {
43
- return Entity.find(
44
- { user: userId },
45
- '-dateCreated -dateUpdated -user -credentials -credential -__t -__v',
46
- { lean: true }
47
- );
48
- }
49
-
50
- async findEntitiesByIds(entityIds) {
51
- const entities = await Entity.find(
52
- { _id: { $in: entityIds } },
53
- '',
54
- { lean: true }
55
- );
56
-
57
- return entities.map(e => ({
58
- id: e._id.toString(),
59
- accountId: e.accountId,
60
- credentialId: e.credential.toString(),
61
- userId: e.user.toString(),
62
- name: e.name,
63
- externalId: e.externalId,
64
- type: e.__t,
65
- moduleName: e.moduleName,
66
- }));
67
- }
68
- }
69
-
70
- module.exports = { ModuleRepository };
@@ -1,329 +0,0 @@
1
- const { Delegate } = require('../core');
2
- const { get } = require('../assertions');
3
- const _ = require('lodash');
4
- const { flushDebugLog } = require('../logs');
5
- const { Credential } = require('./credential');
6
- const { Entity } = require('./entity');
7
- const { mongoose } = require('../database/mongoose');
8
- const { ModuleConstants } = require('./ModuleConstants');
9
-
10
- class Module extends Delegate {
11
-
12
- /**
13
- *
14
- * @param {Object} params
15
- * @param {Object} params.definition The definition of the Api Module
16
- * @param {string} params.userId The user id
17
- * @param {Object} params.entity The entity record from the database
18
- */
19
- constructor({ definition, userId = null, entity: entityObj = null }) {
20
- super({ definition, userId, entity: entityObj });
21
-
22
- this.validateDefinition(definition);
23
-
24
- this.userId = userId;
25
- this.entity = entityObj;
26
- this.credential = entityObj?.credential;
27
- this.definition = definition;
28
- this.getEntityOptions = this.definition.getEntityOptions;
29
- this.refreshEntityOptions = this.definition.refreshEntityOptions;
30
- this.name = this.definition.moduleName;
31
- this.modelName = this.definition.modelName;
32
- this.apiClass = this.definition.API;
33
-
34
-
35
- Object.assign(this, this.definition.requiredAuthMethods);
36
-
37
- this.CredentialModel = this.getCredentialModel();
38
- this.EntityModel = this.getEntityModel();
39
-
40
-
41
- const apiParams = {
42
- ...this.definition.env,
43
- delegate: this,
44
- ...this.apiParamsFromCredential(this.credential),
45
- ...this.apiParamsFromEntity(this.entity),
46
- };
47
- this.api = new this.apiClass(apiParams);
48
- }
49
-
50
- static getEntityModelFromDefinition(definition) {
51
- const partialModule = new this({ definition });
52
- return partialModule.getEntityModel();
53
- }
54
-
55
- getName() {
56
- return this.name;
57
- }
58
-
59
- apiParamsFromCredential(credential) {
60
- return _.pick(credential, ...this.apiPropertiesToPersist?.credential);
61
- }
62
-
63
- apiParamsFromEntity(entity) {
64
- return _.pick(entity, ...this.apiPropertiesToPersist?.entity);
65
- }
66
-
67
- getEntityModel() {
68
- if (!this.EntityModel) {
69
- const prefix = this.modelName ?? _.upperFirst(this.getName());
70
- const arrayToDefaultObject = (array, defaultValue) =>
71
- _.mapValues(_.keyBy(array), () => defaultValue);
72
- const schema = new mongoose.Schema(
73
- arrayToDefaultObject(this.apiPropertiesToPersist.entity, {
74
- type: mongoose.Schema.Types.Mixed,
75
- trim: true,
76
- })
77
- );
78
- const name = `${prefix}Entity`;
79
- this.EntityModel =
80
- Entity.discriminators?.[name] ||
81
- Entity.discriminator(name, schema);
82
- }
83
- return this.EntityModel;
84
- }
85
-
86
- getCredentialModel() {
87
- if (!this.CredentialModel) {
88
- const arrayToDefaultObject = (array, defaultValue) =>
89
- _.mapValues(_.keyBy(array), () => defaultValue);
90
- const schema = new mongoose.Schema(
91
- arrayToDefaultObject(this.apiPropertiesToPersist.credential, {
92
- type: mongoose.Schema.Types.Mixed,
93
- trim: true,
94
- lhEncrypt: true,
95
- })
96
- );
97
- const prefix = this.modelName ?? _.upperFirst(this.getName());
98
- const name = `${prefix}Credential`;
99
- this.CredentialModel =
100
- Credential.discriminators?.[name] ||
101
- Credential.discriminator(name, schema);
102
- }
103
- return this.CredentialModel;
104
- }
105
-
106
- // todo: remove this method from all places
107
- // async getEntitiesForUserId(userId) {
108
- // // Only return non-internal fields. Leverages "select" and "options" to non-excepted fields and a pure object.
109
- // const list = await this.EntityModel.find(
110
- // { user: userId },
111
- // '-dateCreated -dateUpdated -user -credentials -credential -__t -__v',
112
- // { lean: true }
113
- // );
114
- // console.log('getEntitiesForUserId list', list, userId);
115
- // return list.map((entity) => ({
116
- // id: entity._id,
117
- // type: this.getName(),
118
- // ...entity,
119
- // }));
120
- // }
121
-
122
- async validateAuthorizationRequirements() {
123
- const requirements = await this.getAuthorizationRequirements();
124
- let valid = true;
125
- if (
126
- ['oauth1', 'oauth2'].includes(requirements.type) &&
127
- !requirements.url
128
- ) {
129
- valid = false;
130
- }
131
- return valid;
132
- }
133
-
134
- async getAuthorizationRequirements(params) {
135
- return this.api.getAuthorizationRequirements();
136
- }
137
-
138
- async testAuth() {
139
- let validAuth = false;
140
- try {
141
- if (await this.testAuthRequest(this.api)) validAuth = true;
142
- } catch (e) {
143
- flushDebugLog(e);
144
- }
145
- return validAuth;
146
- }
147
-
148
- async processAuthorizationCallback(params) {
149
- let tokenResponse;
150
- if (this.apiClass.requesterType === ModuleConstants.authType.oauth2) {
151
- tokenResponse = await this.getToken(this.api, params);
152
- } else {
153
- tokenResponse = await this.setAuthParams(this.api, params);
154
- await this.onTokenUpdate();
155
- }
156
- const authRes = await this.testAuth();
157
- if (!authRes) {
158
- throw new Error('Authorization failed');
159
- }
160
- const entityDetails = await this.getEntityDetails(
161
- this.api,
162
- params,
163
- tokenResponse,
164
- this.userId
165
- );
166
- Object.assign(
167
- entityDetails.details,
168
- this.apiParamsFromEntity(this.api)
169
- );
170
- await this.findOrCreateEntity(entityDetails);
171
- return {
172
- credential_id: this.credential.id,
173
- entity_id: this.entity.id,
174
- type: this.getName(),
175
- };
176
- }
177
-
178
- async onTokenUpdate() {
179
- const credentialDetails = await this.getCredentialDetails(
180
- this.api,
181
- this.userId
182
- );
183
- Object.assign(
184
- credentialDetails.details,
185
- this.apiParamsFromCredential(this.api)
186
- );
187
- credentialDetails.details.auth_is_valid = true;
188
- await this.updateOrCreateCredential(credentialDetails);
189
- }
190
-
191
- async receiveNotification(notifier, delegateString, object = null) {
192
- if (delegateString === this.api.DLGT_TOKEN_UPDATE) {
193
- await this.onTokenUpdate();
194
- } else if (delegateString === this.api.DLGT_TOKEN_DEAUTHORIZED) {
195
- await this.deauthorize();
196
- } else if (delegateString === this.api.DLGT_INVALID_AUTH) {
197
- await this.markCredentialsInvalid();
198
- }
199
- }
200
-
201
- async findOrCreateEntity(entityDetails) {
202
- const identifiers = get(entityDetails, 'identifiers');
203
- const details = get(entityDetails, 'details');
204
- const search = await this.EntityModel.find(identifiers);
205
- if (search.length > 1) {
206
- throw new Error(
207
- 'Multiple entities found with the same identifiers: ' +
208
- JSON.stringify(identifiers)
209
- );
210
- } else if (search.length === 0) {
211
- this.entity = await this.EntityModel.create({
212
- credential: this.credential.id,
213
- ...details,
214
- ...identifiers,
215
- });
216
- } else if (search.length === 1) {
217
- this.entity = search[0];
218
- }
219
- if (this.entity.credential === undefined) {
220
- this.entity.credential = this.credential.id;
221
- await this.entity.save();
222
- }
223
- }
224
-
225
- async updateOrCreateCredential(credentialDetails) {
226
- const identifiers = get(credentialDetails, 'identifiers');
227
- const details = get(credentialDetails, 'details');
228
-
229
- if (!this.credential) {
230
- const credentialSearch = await this.CredentialModel.find(
231
- identifiers
232
- );
233
- if (credentialSearch.length > 1) {
234
- throw new Error(
235
- `Multiple credentials found with same identifiers: ${identifiers}`
236
- );
237
- } else if (credentialSearch.length === 1) {
238
- // found exactly one credential with these identifiers
239
- this.credential = credentialSearch[0];
240
- } else {
241
- // found no credential with these identifiers (match none for insert)
242
- this.credential = { $exists: false };
243
- }
244
- }
245
- // update credential or create if none was found
246
- this.credential = await this.CredentialModel.findOneAndUpdate(
247
- { _id: this.credential },
248
- { $set: { ...identifiers, ...details } },
249
- { useFindAndModify: true, new: true, upsert: true }
250
- );
251
- }
252
-
253
- async markCredentialsInvalid() {
254
- if (this.credential) {
255
- this.credential.auth_is_valid = false;
256
- await this.credential.save();
257
- }
258
- }
259
-
260
- async deauthorize() {
261
- this.api = new this.apiClass();
262
- if (this.entity?.credential) {
263
- await this.CredentialModel.deleteOne({
264
- _id: this.entity.credential,
265
- });
266
- this.entity.credential = undefined;
267
- await this.entity.save();
268
- }
269
- }
270
-
271
- // todo: check if all these props are still up to date
272
- validateDefinition(definition) {
273
- if (!definition) {
274
- throw new Error('Module definition is required');
275
- }
276
- if (!definition.moduleName) {
277
- throw new Error('Module definition requires moduleName');
278
- }
279
- if (!definition.API) {
280
- throw new Error('Module definition requires API class');
281
- }
282
- if (!definition.requiredAuthMethods) {
283
- throw new Error('Module definition requires requiredAuthMethods');
284
- } else {
285
- if (
286
- definition.API.requesterType ===
287
- ModuleConstants.authType.oauth2 &&
288
- !definition.requiredAuthMethods.getToken
289
- ) {
290
- throw new Error(
291
- 'Module definition requires requiredAuthMethods.getToken'
292
- );
293
- }
294
- if (!definition.requiredAuthMethods.getEntityDetails) {
295
- throw new Error(
296
- 'Module definition requires requiredAuthMethods.getEntityDetails'
297
- );
298
- }
299
- if (!definition.requiredAuthMethods.getCredentialDetails) {
300
- throw new Error(
301
- 'Module definition requires requiredAuthMethods.getCredentialDetails'
302
- );
303
- }
304
- if (!definition.requiredAuthMethods.apiPropertiesToPersist) {
305
- throw new Error(
306
- 'Module definition requires requiredAuthMethods.apiPropertiesToPersist'
307
- );
308
- } else if (definition.Credential) {
309
- for (const prop of definition.requiredAuthMethods
310
- .apiPropertiesToPersist?.credential) {
311
- if (
312
- !definition.Credential.schema.paths.hasOwnProperty(prop)
313
- ) {
314
- throw new Error(
315
- `Module definition requires Credential schema to have property ${prop}`
316
- );
317
- }
318
- }
319
- }
320
- if (!definition.requiredAuthMethods.testAuthRequest) {
321
- throw new Error(
322
- 'Module definition requires requiredAuthMethods.testAuth'
323
- );
324
- }
325
- }
326
- }
327
- }
328
-
329
- module.exports = { Module };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes