@segment/action-destinations 3.78.0 → 3.79.1-alpha.1
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/dist/destinations/snap-conversions-api/_tests_/index.test.js +4 -4
- package/dist/destinations/snap-conversions-api/reportConversionEvent/index.js +2 -2
- package/dist/destinations/snap-conversions-api/reportConversionEvent/index.js.map +1 -1
- package/dist/destinations/webhook/__test__/webhook.test.js +34 -9
- package/dist/destinations/webhook/__test__/webhook.test.js.map +1 -1
- package/dist/destinations/webhook/generated-types.d.ts +1 -0
- package/dist/destinations/webhook/index.js +20 -0
- package/dist/destinations/webhook/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -51,7 +51,7 @@ describe('Snap Conversions API ', () => {
|
|
|
51
51
|
});
|
|
52
52
|
expect(responses).not.toBeNull();
|
|
53
53
|
expect(responses[0].status).toBe(200);
|
|
54
|
-
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"event_type\\":\\"PURCHASE\\",\\"event_conversion_type\\":\\"WEB\\",\\"timestamp\\":1652368875449,\\"hashed_email\\":\\"cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9\\",\\"hashed_phone_number\\":\\"dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383\\",\\"user_agent\\":\\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\\",\\"hashed_ip_address\\":\\"838c4c2573848f58e74332341a7ca6bc5cd86a8aec7d644137d53b4d597f10f5\\",\\"price\\":15,\\"currency\\":\\"USD\\",\\"page_url\\":\\"https://segment.com/academy/\\",\\"pixel_id\\":\\"test123\\"
|
|
54
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"integration\\":\\"segment\\",\\"event_type\\":\\"PURCHASE\\",\\"event_conversion_type\\":\\"WEB\\",\\"timestamp\\":1652368875449,\\"hashed_email\\":\\"cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9\\",\\"hashed_phone_number\\":\\"dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383\\",\\"user_agent\\":\\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\\",\\"hashed_ip_address\\":\\"838c4c2573848f58e74332341a7ca6bc5cd86a8aec7d644137d53b4d597f10f5\\",\\"price\\":15,\\"currency\\":\\"USD\\",\\"page_url\\":\\"https://segment.com/academy/\\",\\"pixel_id\\":\\"test123\\"}"`);
|
|
55
55
|
});
|
|
56
56
|
it('should fail web event without pixel_id', async () => {
|
|
57
57
|
nock_1.default(conversionEventUrl).post('').reply(400, {});
|
|
@@ -110,7 +110,7 @@ describe('Snap Conversions API ', () => {
|
|
|
110
110
|
});
|
|
111
111
|
expect(responses).not.toBeNull();
|
|
112
112
|
expect(responses[0].status).toBe(200);
|
|
113
|
-
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"event_type\\":\\"SAVE\\",\\"event_conversion_type\\":\\"OFFLINE\\",\\"timestamp\\":1652368875449,\\"hashed_email\\":\\"cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9\\",\\"hashed_phone_number\\":\\"dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383\\",\\"user_agent\\":\\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\\",\\"hashed_ip_address\\":\\"838c4c2573848f58e74332341a7ca6bc5cd86a8aec7d644137d53b4d597f10f5\\",\\"price\\":15,\\"currency\\":\\"USD\\",\\"page_url\\":\\"https://segment.com/academy/\\",\\"pixel_id\\":\\"test123\\"
|
|
113
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"integration\\":\\"segment\\",\\"event_type\\":\\"SAVE\\",\\"event_conversion_type\\":\\"OFFLINE\\",\\"timestamp\\":1652368875449,\\"hashed_email\\":\\"cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9\\",\\"hashed_phone_number\\":\\"dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383\\",\\"user_agent\\":\\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\\",\\"hashed_ip_address\\":\\"838c4c2573848f58e74332341a7ca6bc5cd86a8aec7d644137d53b4d597f10f5\\",\\"price\\":15,\\"currency\\":\\"USD\\",\\"page_url\\":\\"https://segment.com/academy/\\",\\"pixel_id\\":\\"test123\\"}"`);
|
|
114
114
|
});
|
|
115
115
|
it('should handle a mobile app event conversion type', async () => {
|
|
116
116
|
nock_1.default(conversionEventUrl).post('').reply(200, {});
|
|
@@ -133,7 +133,7 @@ describe('Snap Conversions API ', () => {
|
|
|
133
133
|
});
|
|
134
134
|
expect(responses).not.toBeNull();
|
|
135
135
|
expect(responses[0].status).toBe(200);
|
|
136
|
-
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"event_type\\":\\"SAVE\\",\\"event_conversion_type\\":\\"MOBILE_APP\\",\\"timestamp\\":1652368875449,\\"hashed_email\\":\\"cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9\\",\\"hashed_phone_number\\":\\"dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383\\",\\"user_agent\\":\\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\\",\\"hashed_ip_address\\":\\"838c4c2573848f58e74332341a7ca6bc5cd86a8aec7d644137d53b4d597f10f5\\",\\"price\\":15,\\"currency\\":\\"USD\\",\\"page_url\\":\\"https://segment.com/academy/\\",\\"snap_app_id\\":\\"123\\",\\"app_id\\":\\"123\\"
|
|
136
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"integration\\":\\"segment\\",\\"event_type\\":\\"SAVE\\",\\"event_conversion_type\\":\\"MOBILE_APP\\",\\"timestamp\\":1652368875449,\\"hashed_email\\":\\"cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9\\",\\"hashed_phone_number\\":\\"dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383\\",\\"user_agent\\":\\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\\",\\"hashed_ip_address\\":\\"838c4c2573848f58e74332341a7ca6bc5cd86a8aec7d644137d53b4d597f10f5\\",\\"price\\":15,\\"currency\\":\\"USD\\",\\"page_url\\":\\"https://segment.com/academy/\\",\\"snap_app_id\\":\\"123\\",\\"app_id\\":\\"123\\"}"`);
|
|
137
137
|
});
|
|
138
138
|
it('should fail invalid currency', async () => {
|
|
139
139
|
nock_1.default(conversionEventUrl).post('').reply(400, {});
|
|
@@ -197,7 +197,7 @@ describe('Snap Conversions API ', () => {
|
|
|
197
197
|
});
|
|
198
198
|
expect(responses).not.toBeNull();
|
|
199
199
|
expect(responses[0].status).toBe(200);
|
|
200
|
-
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"event_type\\":\\"CUSTOM_EVENT_5\\",\\"event_conversion_type\\":\\"MOBILE_APP\\",\\"timestamp\\":1652368875449,\\"hashed_email\\":\\"cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9\\",\\"hashed_phone_number\\":\\"dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383\\",\\"user_agent\\":\\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\\",\\"hashed_ip_address\\":\\"838c4c2573848f58e74332341a7ca6bc5cd86a8aec7d644137d53b4d597f10f5\\",\\"price\\":15,\\"currency\\":\\"USD\\",\\"page_url\\":\\"https://segment.com/academy/\\",\\"snap_app_id\\":\\"123\\",\\"app_id\\":\\"123\\"
|
|
200
|
+
expect(responses[0].options.body).toMatchInlineSnapshot(`"{\\"integration\\":\\"segment\\",\\"event_type\\":\\"CUSTOM_EVENT_5\\",\\"event_conversion_type\\":\\"MOBILE_APP\\",\\"timestamp\\":1652368875449,\\"hashed_email\\":\\"cc779c04191c2e736d89e45c11339c8382832bcaf70383f7df94e3d08ba7a6d9\\",\\"hashed_phone_number\\":\\"dc008fda46e2e64002cf2f82a4906236282d431c4f75e5b60bfe79fc48546383\\",\\"user_agent\\":\\"Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\\",\\"hashed_ip_address\\":\\"838c4c2573848f58e74332341a7ca6bc5cd86a8aec7d644137d53b4d597f10f5\\",\\"price\\":15,\\"currency\\":\\"USD\\",\\"page_url\\":\\"https://segment.com/academy/\\",\\"snap_app_id\\":\\"123\\",\\"app_id\\":\\"123\\"}"`);
|
|
201
201
|
});
|
|
202
202
|
});
|
|
203
203
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/snap-conversions-api/reportConversionEvent/index.ts"],"names":[],"mappings":";;AAAA,wDAA0E;AAG1E,kEA2BgC;AAEhC,MAAM,oBAAoB,GAAG,uCAAuC,CAAA;AAEpE,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,yBAAyB;IAChC,WAAW,EACT,2JAA2J;IAC7J,MAAM,EAAE;QACN,UAAU,EAAE,EAAE,GAAG,iCAAU,EAAE,QAAQ,EAAE,IAAI,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M;YACd,IAAI,EAAE;gBACJ,GAAG,OAAO;gBACV,GAAG,QAAQ;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/snap-conversions-api/reportConversionEvent/index.ts"],"names":[],"mappings":";;AAAA,wDAA0E;AAG1E,kEA2BgC;AAEhC,MAAM,oBAAoB,GAAG,uCAAuC,CAAA;AAEpE,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,yBAAyB;IAChC,WAAW,EACT,2JAA2J;IAC7J,MAAM,EAAE;QACN,UAAU,EAAE,EAAE,GAAG,iCAAU,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC7C,qBAAqB,EAAE,EAAE,GAAG,4CAAqB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACnE,SAAS,EAAE,gCAAS;QACpB,SAAS,EAAE,EAAE,GAAG,gCAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC3C,KAAK,EAAE,4BAAK;QACZ,YAAY,EAAE,mCAAY;QAC1B,OAAO,EAAE,8BAAO;QAChB,IAAI,EAAE,2BAAI;QACV,YAAY,EAAE,mCAAY;QAC1B,UAAU,EAAE,iCAAU;QACtB,UAAU,EAAE,iCAAU;QACtB,aAAa,EAAE,oCAAa;QAC5B,QAAQ,EAAE,+BAAQ;QAClB,WAAW,EAAE,kCAAW;QACxB,YAAY,EAAE,mCAAY;QAC1B,KAAK,EAAE,4BAAK;QACZ,QAAQ,EAAE,+BAAQ;QAClB,cAAc,EAAE,qCAAc;QAC9B,KAAK,EAAE,4BAAK;QACZ,eAAe,EAAE,sCAAe;QAChC,aAAa,EAAE,oCAAa;QAC5B,QAAQ,EAAE,+BAAQ;QAClB,cAAc,EAAE,qCAAc;KAC/B;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,OAAO,GAAW,oCAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnD,MAAM,QAAQ,GAAa,qCAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAA;QAE5F,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,8CAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,EAAE;YAC9F,MAAM,IAAI,+BAAgB,CACxB,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,gCAAgC,EACxD,8BAA8B,EAC9B,GAAG,CACJ,CAAA;SACF;QAGD,OAAO,OAAO,CAAC,oBAAoB,EAAE;YACnC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,WAAW,EAAE,SAAS;gBACtB,GAAG,OAAO;gBACV,GAAG,QAAQ;aACZ;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -6,16 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const nock_1 = __importDefault(require("nock"));
|
|
7
7
|
const actions_core_1 = require("@segment/actions-core");
|
|
8
8
|
const index_1 = __importDefault(require("../index"));
|
|
9
|
+
const crypto_1 = require("crypto");
|
|
9
10
|
const testDestination = actions_core_1.createTestIntegration(index_1.default);
|
|
10
|
-
const timestamp = new Date().toISOString();
|
|
11
11
|
describe('Webhook', () => {
|
|
12
12
|
describe('send', () => {
|
|
13
13
|
it('should work with default mapping', async () => {
|
|
14
14
|
const url = 'https://example.com';
|
|
15
|
-
const event = actions_core_1.createTestEvent(
|
|
16
|
-
timestamp,
|
|
17
|
-
event: 'Test Event'
|
|
18
|
-
});
|
|
15
|
+
const event = actions_core_1.createTestEvent();
|
|
19
16
|
nock_1.default(url)
|
|
20
17
|
.post('/', event)
|
|
21
18
|
.reply(200);
|
|
@@ -31,10 +28,7 @@ describe('Webhook', () => {
|
|
|
31
28
|
});
|
|
32
29
|
it('supports customizations', async () => {
|
|
33
30
|
const url = 'https://example.build';
|
|
34
|
-
const event = actions_core_1.createTestEvent(
|
|
35
|
-
timestamp,
|
|
36
|
-
event: 'Test Event'
|
|
37
|
-
});
|
|
31
|
+
const event = actions_core_1.createTestEvent();
|
|
38
32
|
const headerField = 'Custom-Header';
|
|
39
33
|
const headerValue = 'Custom-Value';
|
|
40
34
|
const data = { cool: true };
|
|
@@ -51,6 +45,37 @@ describe('Webhook', () => {
|
|
|
51
45
|
expect(responses.length).toBe(1);
|
|
52
46
|
expect(responses[0].status).toBe(200);
|
|
53
47
|
});
|
|
48
|
+
it('supports request signing', async () => {
|
|
49
|
+
const url = 'https://example.com';
|
|
50
|
+
const event = actions_core_1.createTestEvent({
|
|
51
|
+
properties: { cool: true }
|
|
52
|
+
});
|
|
53
|
+
const payload = JSON.stringify(event.properties);
|
|
54
|
+
const sharedSecret = 'abc123';
|
|
55
|
+
nock_1.default(url)
|
|
56
|
+
.post('/', payload)
|
|
57
|
+
.reply(async function (_uri, body) {
|
|
58
|
+
const bodyString = JSON.stringify(body);
|
|
59
|
+
const expectSignature = this.req.headers['x-signature'][0];
|
|
60
|
+
const actualSignature = crypto_1.createHmac('sha1', sharedSecret).update(bodyString).digest('hex');
|
|
61
|
+
if (expectSignature.length !== actualSignature.length ||
|
|
62
|
+
!crypto_1.timingSafeEqual(Buffer.from(actualSignature, 'hex'), Buffer.from(expectSignature, 'hex'))) {
|
|
63
|
+
return [400, 'Invalid signature'];
|
|
64
|
+
}
|
|
65
|
+
return [200, 'OK'];
|
|
66
|
+
});
|
|
67
|
+
const responses = await testDestination.testAction('send', {
|
|
68
|
+
event,
|
|
69
|
+
mapping: {
|
|
70
|
+
url,
|
|
71
|
+
data: { '@path': '$.properties' }
|
|
72
|
+
},
|
|
73
|
+
settings: { sharedSecret },
|
|
74
|
+
useDefaultMappings: true
|
|
75
|
+
});
|
|
76
|
+
expect(responses.length).toBe(1);
|
|
77
|
+
expect(responses[0].status).toBe(200);
|
|
78
|
+
});
|
|
54
79
|
});
|
|
55
80
|
});
|
|
56
81
|
//# sourceMappingURL=webhook.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.test.js","sourceRoot":"","sources":["../../../../src/destinations/webhook/__test__/webhook.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,wDAA8E;AAC9E,qDAA8B;
|
|
1
|
+
{"version":3,"file":"webhook.test.js","sourceRoot":"","sources":["../../../../src/destinations/webhook/__test__/webhook.test.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,wDAA8E;AAC9E,qDAA8B;AAC9B,mCAAoD;AAEpD,MAAM,eAAe,GAAG,oCAAqB,CAAC,eAAO,CAAC,CAAA;AAEtD,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;QACpB,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,GAAG,GAAG,qBAAqB,CAAA;YACjC,MAAM,KAAK,GAAG,8BAAe,EAAE,CAAA;YAE/B,cAAI,CAAC,GAAG,CAAC;iBACN,IAAI,CAAC,GAAG,EAAE,KAAY,CAAC;iBACvB,KAAK,CAAC,GAAG,CAAC,CAAA;YAEb,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE;gBACzD,KAAK;gBACL,OAAO,EAAE;oBACP,GAAG;iBACJ;gBACD,kBAAkB,EAAE,IAAI;aACzB,CAAC,CAAA;YAEF,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAChC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;YACvC,MAAM,GAAG,GAAG,uBAAuB,CAAA;YACnC,MAAM,KAAK,GAAG,8BAAe,EA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C,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;gBAC1D,MAAM,eAAe,GAAG,mBAAU,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;gBAGzF,IACE,eAAe,CAAC,MAAM,KAAK,eAAe,CAAC,MAAM;oBACjD,CAAC,wBAAe,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,EAC1F;oBACA,OAAO,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAA;iBAClC;gBAED,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;YACpB,CAAC,CAAC,CAAA;YAEJ,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE;gBACzD,KAAK;gBACL,OAAO,EAAE;oBACP,GAAG;oBACH,IAAI,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE;iBAClC;gBACD,QAAQ,EAAE,EAAE,YAAY,EAAE;gBAC1B,kBAAkB,EAAE,IAAI;aACzB,CAAC,CAAA;YAEF,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAChC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -3,11 +3,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
6
7
|
const send_1 = __importDefault(require("./send"));
|
|
7
8
|
const destination = {
|
|
8
9
|
name: 'Webhook',
|
|
9
10
|
slug: 'actions-webhook',
|
|
10
11
|
mode: 'cloud',
|
|
12
|
+
authentication: {
|
|
13
|
+
scheme: 'custom',
|
|
14
|
+
fields: {
|
|
15
|
+
sharedSecret: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
label: 'Shared Secret',
|
|
18
|
+
description: 'If set, Segment will sign requests with an HMAC in the "X-Signature" request header. The HMAC is a hex-encoded SHA1 hash generated using this shared secret and the request body.'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
extendRequest: ({ settings, payload }) => {
|
|
23
|
+
if (settings.sharedSecret && payload?.data) {
|
|
24
|
+
const digest = crypto_1.createHmac('sha1', settings.sharedSecret)
|
|
25
|
+
.update(JSON.stringify(payload.data), 'utf8')
|
|
26
|
+
.digest('hex');
|
|
27
|
+
return { headers: { 'X-Signature': digest } };
|
|
28
|
+
}
|
|
29
|
+
return {};
|
|
30
|
+
},
|
|
11
31
|
actions: {
|
|
12
32
|
send: send_1.default
|
|
13
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/webhook/index.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/webhook/index.ts"],"names":[],"mappings":";;;;;AAEA,mCAAmC;AAEnC,kDAAyB;AAEzB,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,OAAO;IACb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,YAAY,EAAE;gBACZ,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,eAAe;gBACtB,WAAW,EACT,mLAAmL;aACtL;SACF;KACF;IACD,aAAa,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QACvC,IAAI,QAAQ,CAAC,YAAY,IAAI,OAAO,EAAE,IAAI,EAAE;YAC1C,MAAM,MAAM,GAAG,mBAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC;iBACrD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;iBAC5C,MAAM,CAAC,KAAK,CAAC,CAAA;YAChB,OAAO,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,CAAA;SAC9C;QACD,OAAO,EAAE,CAAA;IACX,CAAC;IACD,OAAO,EAAE;QACP,IAAI,EAAJ,cAAI;KACL;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segment/action-destinations",
|
|
3
3
|
"description": "Destination Actions engine and definitions.",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.79.1-alpha.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@amplitude/ua-parser-js": "^0.7.25",
|
|
40
40
|
"@segment/a1-notation": "^2.1.4",
|
|
41
|
-
"@segment/actions-core": "^3.27.
|
|
42
|
-
"@segment/actions-shared": "^1.10.
|
|
41
|
+
"@segment/actions-core": "^3.27.1-alpha.1",
|
|
42
|
+
"@segment/actions-shared": "^1.10.1-alpha.1",
|
|
43
43
|
"cheerio": "^1.0.0-rc.10",
|
|
44
44
|
"dayjs": "^1.10.7",
|
|
45
45
|
"escape-goat": "^3",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"lcov"
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "850844a8e31bfc5bb016795493018ec76a059991"
|
|
69
69
|
}
|