@unito/integration-sdk 0.1.4 → 0.1.5

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.
@@ -54,7 +54,7 @@ type WebhookSubscriptionHandlers = {
54
54
  updateWebhookSubscriptions: UpdateWebhookSubscriptionsHandler;
55
55
  };
56
56
  type AcknowledgeWebhookHandlers = {
57
- acknowledgeWebhooks?: AckknowledgeWebhooksHandler;
57
+ acknowledgeWebhooks: AckknowledgeWebhooksHandler;
58
58
  };
59
59
  export type HandlersInput = ItemHandlers | CredentialAccountHandlers | ParseWebhookHandlers | WebhookSubscriptionHandlers | AcknowledgeWebhookHandlers;
60
60
  export declare class Handler {
@@ -6,11 +6,11 @@ const middleware = (req, res, next) => {
6
6
  const rawAdditionalContext = req.header(ADDITIONAL_CONTEXT_HEADER);
7
7
  if (typeof rawAdditionalContext === 'string') {
8
8
  try {
9
- const additionalContext = JSON.parse(Buffer.from(rawAdditionalContext, 'base64').toString('utf8'));
9
+ const additionalContext = JSON.parse(rawAdditionalContext);
10
10
  logger.decorate(additionalContext);
11
11
  }
12
12
  catch (error) {
13
- logger.warn(`Malformed HTTP header ${ADDITIONAL_CONTEXT_HEADER}: ${rawAdditionalContext}`);
13
+ logger.warn(`Failed parsing header ${ADDITIONAL_CONTEXT_HEADER}: ${rawAdditionalContext}`);
14
14
  }
15
15
  }
16
16
  next();
@@ -19,9 +19,9 @@ describe('logger middleware', () => {
19
19
  });
20
20
  });
21
21
  it('additional context', () => {
22
- const additional = Buffer.from(JSON.stringify({
22
+ const additional = JSON.stringify({
23
23
  foo: 'bar',
24
- })).toString('base64');
24
+ });
25
25
  const request = { header: (_key) => additional };
26
26
  const response = { locals: { correlationId: '123' } };
27
27
  middleware(request, response, () => { });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unito/integration-sdk",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Integration SDK",
5
5
  "type": "module",
6
6
  "types": "dist/src/index.d.ts",
package/src/handler.ts CHANGED
@@ -88,7 +88,7 @@ type WebhookSubscriptionHandlers = {
88
88
  };
89
89
 
90
90
  type AcknowledgeWebhookHandlers = {
91
- acknowledgeWebhooks?: AckknowledgeWebhooksHandler;
91
+ acknowledgeWebhooks: AckknowledgeWebhooksHandler;
92
92
  };
93
93
 
94
94
  export type HandlersInput =
@@ -22,11 +22,11 @@ const middleware = (req: Request, res: Response, next: NextFunction) => {
22
22
 
23
23
  if (typeof rawAdditionalContext === 'string') {
24
24
  try {
25
- const additionalContext = JSON.parse(Buffer.from(rawAdditionalContext, 'base64').toString('utf8'));
25
+ const additionalContext = JSON.parse(rawAdditionalContext);
26
26
 
27
27
  logger.decorate(additionalContext);
28
28
  } catch (error) {
29
- logger.warn(`Malformed HTTP header ${ADDITIONAL_CONTEXT_HEADER}: ${rawAdditionalContext}`);
29
+ logger.warn(`Failed parsing header ${ADDITIONAL_CONTEXT_HEADER}: ${rawAdditionalContext}`);
30
30
  }
31
31
  }
32
32
 
@@ -27,11 +27,9 @@ describe('logger middleware', () => {
27
27
  });
28
28
 
29
29
  it('additional context', () => {
30
- const additional = Buffer.from(
31
- JSON.stringify({
32
- foo: 'bar',
33
- }),
34
- ).toString('base64');
30
+ const additional = JSON.stringify({
31
+ foo: 'bar',
32
+ });
35
33
 
36
34
  const request = { header: (_key: string) => additional } as express.Request;
37
35
  const response = { locals: { correlationId: '123' } } as express.Response;