@hermeticacomms/sdk-node 0.0.0-stage → 0.1.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/LICENSE +9 -0
- package/README.md +12 -2
- package/dist/contracts/analytics.d.ts +405 -0
- package/dist/contracts/analytics.js +77 -0
- package/dist/contracts/auth.d.ts +359 -0
- package/dist/contracts/auth.js +121 -0
- package/dist/contracts/billing.d.ts +141 -0
- package/dist/contracts/billing.js +31 -0
- package/dist/contracts/campaigns.d.ts +918 -0
- package/dist/contracts/campaigns.js +269 -0
- package/dist/contracts/common.d.ts +57 -0
- package/dist/contracts/common.js +35 -0
- package/dist/contracts/connectors.d.ts +179 -0
- package/dist/contracts/connectors.js +46 -0
- package/dist/contracts/consent.d.ts +604 -0
- package/dist/contracts/consent.js +180 -0
- package/dist/contracts/content-blocks.d.ts +164 -0
- package/dist/contracts/content-blocks.js +60 -0
- package/dist/contracts/content-library.d.ts +339 -0
- package/dist/contracts/content-library.js +50 -0
- package/dist/contracts/content.d.ts +949 -0
- package/dist/contracts/content.js +192 -0
- package/dist/contracts/delivery.d.ts +599 -0
- package/dist/contracts/delivery.js +214 -0
- package/dist/contracts/events.d.ts +513 -0
- package/dist/contracts/events.js +178 -0
- package/dist/contracts/experiments.d.ts +376 -0
- package/dist/contracts/experiments.js +136 -0
- package/dist/contracts/identity.d.ts +756 -0
- package/dist/contracts/identity.js +225 -0
- package/dist/contracts/index.d.ts +15 -0
- package/dist/contracts/index.js +15 -0
- package/dist/contracts/integrations.d.ts +381 -0
- package/dist/contracts/integrations.js +112 -0
- package/dist/contracts/leads.d.ts +733 -0
- package/dist/contracts/leads.js +125 -0
- package/dist/contracts/metrics.d.ts +460 -0
- package/dist/contracts/metrics.js +90 -0
- package/dist/contracts/outbound.d.ts +15510 -0
- package/dist/contracts/outbound.js +423 -0
- package/dist/contracts/pickers.d.ts +12 -0
- package/dist/contracts/pickers.js +20 -0
- package/dist/contracts/platform-admin.d.ts +230 -0
- package/dist/contracts/platform-admin.js +91 -0
- package/dist/contracts/postcards.d.ts +79 -0
- package/dist/contracts/postcards.js +29 -0
- package/dist/contracts/push.d.ts +530 -0
- package/dist/contracts/push.js +102 -0
- package/dist/contracts/rcs.d.ts +39 -0
- package/dist/contracts/rcs.js +19 -0
- package/dist/contracts/segments.d.ts +3182 -0
- package/dist/contracts/segments.js +416 -0
- package/dist/contracts/workflow-nodes.d.ts +2118 -0
- package/dist/contracts/workflow-nodes.js +341 -0
- package/dist/contracts/workflows.d.ts +46413 -0
- package/dist/contracts/workflows.js +341 -0
- package/dist/contracts/x10-platform.d.ts +2603 -0
- package/dist/contracts/x10-platform.js +129 -0
- package/dist/http.d.ts +30 -0
- package/dist/http.js +65 -0
- package/dist/index.d.ts +11507 -0
- package/dist/index.js +63 -0
- package/dist/platform.d.ts +163 -0
- package/dist/platform.js +40 -0
- package/dist/resources.d.ts +1318 -0
- package/dist/resources.js +56 -0
- package/dist/signature.d.ts +5 -0
- package/dist/signature.js +19 -0
- package/dist/x10.d.ts +1607 -0
- package/dist/x10.js +66 -0
- package/dist/z10.d.ts +251 -0
- package/dist/z10.js +46 -0
- package/package.json +40 -4
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const enc = encodeURIComponent;
|
|
2
|
+
/** Typed methods for the remaining first-class resources. Same retry/idempotency behaviour as the rest of the client. */
|
|
3
|
+
export function resources(http) {
|
|
4
|
+
const q = (v) => v;
|
|
5
|
+
return {
|
|
6
|
+
campaigns: {
|
|
7
|
+
list: (query = {}) => http('GET', '/v1/campaigns', { query: q(query) }),
|
|
8
|
+
get: (id) => http('GET', `/v1/campaigns/${enc(id)}`),
|
|
9
|
+
create: (body) => http('POST', '/v1/campaigns', { body }),
|
|
10
|
+
update: (id, body) => http('PATCH', `/v1/campaigns/${enc(id)}`, { body }),
|
|
11
|
+
/** Schedule (or, with no body, send now per the campaign's stored schedule). Consent and suppression are enforced server-side at send time. */
|
|
12
|
+
schedule: (id, body = {}, o) => http('POST', `/v1/campaigns/${enc(id)}/schedule`, { body, ...o }),
|
|
13
|
+
pause: (id) => http('POST', `/v1/campaigns/${enc(id)}/pause`),
|
|
14
|
+
resume: (id) => http('POST', `/v1/campaigns/${enc(id)}/resume`),
|
|
15
|
+
cancel: (id) => http('DELETE', `/v1/campaigns/${enc(id)}`),
|
|
16
|
+
report: (id) => http('GET', `/v1/campaigns/${enc(id)}/report`),
|
|
17
|
+
},
|
|
18
|
+
lists: {
|
|
19
|
+
list: () => http('GET', '/v1/lists'),
|
|
20
|
+
get: (id) => http('GET', `/v1/lists/${enc(id)}`),
|
|
21
|
+
create: (body) => http('POST', '/v1/lists', { body }),
|
|
22
|
+
update: (id, body) => http('PATCH', `/v1/lists/${enc(id)}`, { body }),
|
|
23
|
+
delete: (id) => http('DELETE', `/v1/lists/${enc(id)}`),
|
|
24
|
+
addMembers: (id, body) => http('POST', `/v1/lists/${enc(id)}/members`, { body }),
|
|
25
|
+
removeMember: (id, profileId) => http('DELETE', `/v1/lists/${enc(id)}/members/${enc(profileId)}`),
|
|
26
|
+
},
|
|
27
|
+
templates: {
|
|
28
|
+
list: (query = {}) => http('GET', '/v1/templates', { query: q(query) }),
|
|
29
|
+
get: (id) => http('GET', `/v1/templates/${enc(id)}`),
|
|
30
|
+
create: (body) => http('POST', '/v1/templates', { body }),
|
|
31
|
+
update: (id, body) => http('PATCH', `/v1/templates/${enc(id)}`, { body }),
|
|
32
|
+
preview: (id, body) => http('POST', `/v1/templates/${enc(id)}/preview`, { body }),
|
|
33
|
+
},
|
|
34
|
+
workflows: {
|
|
35
|
+
list: (query = {}) => http('GET', '/v1/workflows', { query: q(query) }),
|
|
36
|
+
get: (id) => http('GET', `/v1/workflows/${enc(id)}`),
|
|
37
|
+
create: (body) => http('POST', '/v1/workflows', { body }),
|
|
38
|
+
update: (id, body) => http('PATCH', `/v1/workflows/${enc(id)}`, { body }),
|
|
39
|
+
publish: (id) => http('POST', `/v1/workflows/${enc(id)}/publish`),
|
|
40
|
+
pause: (id) => http('POST', `/v1/workflows/${enc(id)}/pause`),
|
|
41
|
+
enroll: (id, body, o) => http('POST', `/v1/workflows/${enc(id)}/enroll`, { body, ...o }),
|
|
42
|
+
},
|
|
43
|
+
consent: {
|
|
44
|
+
get: (profileId) => http('GET', `/v1/profiles/${enc(profileId)}/consent`),
|
|
45
|
+
/** Records a consent change. Grants need a lawful source; the server rejects the ones it cannot accept. */
|
|
46
|
+
record: (profileId, body) => http('POST', `/v1/profiles/${enc(profileId)}/consent`, { body }),
|
|
47
|
+
},
|
|
48
|
+
suppressions: {
|
|
49
|
+
list: (query = {}) => http('GET', '/v1/suppressions', { query: q(query) }),
|
|
50
|
+
add: (body) => http('POST', '/v1/suppressions', { body }),
|
|
51
|
+
lift: (id, body) => http('POST', `/v1/suppressions/${enc(id)}/lift`, { body }),
|
|
52
|
+
blocklist: () => http('GET', '/v1/blocklist'),
|
|
53
|
+
block: (body) => http('POST', '/v1/blocklist', { body }),
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verify a `Hermetica-Signature: t=<unix>,v1=<hex>` header against the RAW request body.
|
|
3
|
+
* Rejects stale/future timestamps (default +-5 min) to stop replays. Several `v1=` values are accepted (secret rotation).
|
|
4
|
+
*/
|
|
5
|
+
export declare function verifyHermeticaSignature(secret: string, header: string, body: string, now?: Date | number, toleranceSec?: number): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Verify a `Hermetica-Signature: t=<unix>,v1=<hex>` header against the RAW request body.
|
|
4
|
+
* Rejects stale/future timestamps (default +-5 min) to stop replays. Several `v1=` values are accepted (secret rotation).
|
|
5
|
+
*/
|
|
6
|
+
export function verifyHermeticaSignature(secret, header, body, now = Date.now(), toleranceSec = 300) {
|
|
7
|
+
const nowSec = Math.floor((typeof now === 'number' ? now : now.getTime()) / 1000);
|
|
8
|
+
const parts = header.split(',').map((p) => p.trim().split('='));
|
|
9
|
+
const t = Number(parts.find(([k]) => k === 't')?.[1]);
|
|
10
|
+
if (!Number.isInteger(t) || Math.abs(nowSec - t) > toleranceSec)
|
|
11
|
+
return false;
|
|
12
|
+
const expected = Buffer.from(createHmac('sha256', secret).update(`${t}.${body}`).digest('hex'));
|
|
13
|
+
return parts.some(([k, v]) => {
|
|
14
|
+
if (k !== 'v1' || !v)
|
|
15
|
+
return false;
|
|
16
|
+
const got = Buffer.from(v);
|
|
17
|
+
return got.length === expected.length && timingSafeEqual(got, expected);
|
|
18
|
+
});
|
|
19
|
+
}
|