@friggframework/core 2.0.0--canary.460.ef50528.0 → 2.0.0--canary.460.ad0a60d.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.
@@ -132,13 +132,10 @@ const createQueueWorker = (integrationClass) => {
132
132
  class QueueWorker extends Worker {
133
133
  async _run(params, context) {
134
134
  try {
135
- if (params.event === 'ON_WEBHOOK') {
136
- if (!params.data?.integrationId) {
137
- throw new Error(
138
- 'integrationId is required in data for ON_WEBHOOK event'
139
- );
140
- }
141
-
135
+ if (
136
+ params.event === 'ON_WEBHOOK' &&
137
+ params.data?.integrationId
138
+ ) {
142
139
  integrationInstance = await loadIntegrationForWebhook(
143
140
  params.data.integrationId
144
141
  );
@@ -148,7 +145,10 @@ const createQueueWorker = (integrationClass) => {
148
145
  integrationClass
149
146
  );
150
147
  } else {
151
- // Instantiates a DRY integration class without database records
148
+ // Instantiates a DRY integration class without database records.
149
+ // There will be cases where we need to use helpers that the api modules can export.
150
+ // Like for HubSpot, the answer is to do a reverse lookup for the integration by the entity external ID (HubSpot Portal ID),
151
+ // and then you'll have the integration ID available to hydrate from.
152
152
  integrationInstance = new integrationClass();
153
153
  }
154
154
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.460.ef50528.0",
4
+ "version": "2.0.0--canary.460.ad0a60d.0",
5
5
  "dependencies": {
6
6
  "@hapi/boom": "^10.0.1",
7
7
  "@prisma/client": "^6.16.3",
@@ -23,9 +23,9 @@
23
23
  "uuid": "^9.0.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@friggframework/eslint-config": "2.0.0--canary.460.ef50528.0",
27
- "@friggframework/prettier-config": "2.0.0--canary.460.ef50528.0",
28
- "@friggframework/test": "2.0.0--canary.460.ef50528.0",
26
+ "@friggframework/eslint-config": "2.0.0--canary.460.ad0a60d.0",
27
+ "@friggframework/prettier-config": "2.0.0--canary.460.ad0a60d.0",
28
+ "@friggframework/test": "2.0.0--canary.460.ad0a60d.0",
29
29
  "@types/lodash": "4.17.15",
30
30
  "@typescript-eslint/eslint-plugin": "^8.0.0",
31
31
  "chai": "^4.3.6",
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "ef50528e85534659a61cdc909e77babffc6ae0f7"
67
+ "gitHead": "ad0a60db3a1af2e7e55bd0fa837fdb352a0fd2c2"
68
68
  }
@@ -3,7 +3,7 @@ const { LoginUser } = require('../../use-cases/login-user');
3
3
  const { TestUserRepository } = require('../doubles/test-user-repository');
4
4
 
5
5
  jest.mock('bcryptjs', () => ({
6
- compareSync: jest.fn(),
6
+ compare: jest.fn(),
7
7
  }));
8
8
 
9
9
  describe('LoginUser Use Case', () => {
@@ -16,7 +16,7 @@ describe('LoginUser Use Case', () => {
16
16
  userRepository = new TestUserRepository({ userConfig });
17
17
  loginUser = new LoginUser({ userRepository, userConfig });
18
18
 
19
- bcrypt.compareSync.mockClear();
19
+ bcrypt.compare.mockClear();
20
20
  });
21
21
 
22
22
  describe('With Password Authentication', () => {
@@ -28,11 +28,11 @@ describe('LoginUser Use Case', () => {
28
28
  hashword: 'hashed-password',
29
29
  });
30
30
 
31
- bcrypt.compareSync.mockReturnValue(true);
31
+ bcrypt.compare.mockResolvedValue(true);
32
32
 
33
33
  const user = await loginUser.execute({ username, password });
34
34
 
35
- expect(bcrypt.compareSync).toHaveBeenCalledWith(
35
+ expect(bcrypt.compare).toHaveBeenCalledWith(
36
36
  password,
37
37
  'hashed-password'
38
38
  );
@@ -48,7 +48,7 @@ describe('LoginUser Use Case', () => {
48
48
  hashword: 'hashed-password',
49
49
  });
50
50
 
51
- bcrypt.compareSync.mockReturnValue(false);
51
+ bcrypt.compare.mockResolvedValue(false);
52
52
 
53
53
  await expect(
54
54
  loginUser.execute({ username, password })
@@ -145,7 +145,7 @@ describe('LoginUser Use Case', () => {
145
145
  loginUser = new LoginUser({ userRepository, userConfig });
146
146
  });
147
147
 
148
- it('should verify bcrypt.compareSync is called with plain password and hash', async () => {
148
+ it('should verify bcrypt.compare is called with plain password and hash', async () => {
149
149
  const username = 'bcrypt-test-user';
150
150
  const plainPassword = 'MyPlainPassword123';
151
151
  const bcryptHash = '$2b$10$abcdefghijklmnopqrstuv';
@@ -155,14 +155,14 @@ describe('LoginUser Use Case', () => {
155
155
  hashword: bcryptHash,
156
156
  });
157
157
 
158
- bcrypt.compareSync.mockReturnValue(true);
158
+ bcrypt.compare.mockResolvedValue(true);
159
159
 
160
160
  await loginUser.execute({ username, password: plainPassword });
161
161
 
162
- expect(bcrypt.compareSync).toHaveBeenCalledTimes(1);
163
- expect(bcrypt.compareSync).toHaveBeenCalledWith(plainPassword, bcryptHash);
162
+ expect(bcrypt.compare).toHaveBeenCalledTimes(1);
163
+ expect(bcrypt.compare).toHaveBeenCalledWith(plainPassword, bcryptHash);
164
164
 
165
- const [firstArg, secondArg] = bcrypt.compareSync.mock.calls[0];
165
+ const [firstArg, secondArg] = bcrypt.compare.mock.calls[0];
166
166
  expect(firstArg).toBe(plainPassword);
167
167
  expect(secondArg).toBe(bcryptHash);
168
168
  });
@@ -192,14 +192,14 @@ describe('LoginUser Use Case', () => {
192
192
  hashword: encryptedLookingValue,
193
193
  });
194
194
 
195
- bcrypt.compareSync.mockReturnValue(false);
195
+ bcrypt.compare.mockResolvedValue(false);
196
196
 
197
197
  await expect(
198
198
  loginUser.execute({ username, password: 'any-password' })
199
199
  ).rejects.toThrow('Incorrect username or password');
200
200
  });
201
201
 
202
- it('should verify bcrypt.compareSync returns false for mismatched passwords', async () => {
202
+ it('should verify bcrypt.compare returns false for mismatched passwords', async () => {
203
203
  const username = 'mismatch-test-user';
204
204
  const correctHash = '$2b$10$correcthash';
205
205
 
@@ -208,13 +208,13 @@ describe('LoginUser Use Case', () => {
208
208
  hashword: correctHash,
209
209
  });
210
210
 
211
- bcrypt.compareSync.mockReturnValue(false);
211
+ bcrypt.compare.mockResolvedValue(false);
212
212
 
213
213
  await expect(
214
214
  loginUser.execute({ username, password: 'wrong-password' })
215
215
  ).rejects.toThrow('Incorrect username or password');
216
216
 
217
- expect(bcrypt.compareSync).toHaveBeenCalledWith('wrong-password', correctHash);
217
+ expect(bcrypt.compare).toHaveBeenCalledWith('wrong-password', correctHash);
218
218
  });
219
219
  });
220
220
  });