@isnap/sdk 0.1.0 → 1.1.0-next.38
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/CHANGELOG.md +15 -0
- package/README.md +173 -167
- package/dist/client.d.ts +48 -50
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +258 -89
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +43 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +55 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +53 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +100 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/openapi.d.ts +10924 -0
- package/dist/idempotency.d.ts +2 -0
- package/dist/idempotency.d.ts.map +1 -0
- package/dist/idempotency.js +4 -0
- package/dist/idempotency.js.map +1 -0
- package/dist/index.d.ts +26 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/internal/sleep.d.ts +10 -0
- package/dist/internal/sleep.d.ts.map +1 -0
- package/dist/internal/sleep.js +37 -0
- package/dist/internal/sleep.js.map +1 -0
- package/dist/pagination.d.ts +10 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +16 -0
- package/dist/pagination.js.map +1 -0
- package/dist/resources/attachments.d.ts +45 -0
- package/dist/resources/attachments.d.ts.map +1 -0
- package/dist/resources/attachments.js +120 -0
- package/dist/resources/attachments.js.map +1 -0
- package/dist/resources/base.d.ts +6 -0
- package/dist/resources/base.d.ts.map +1 -0
- package/dist/resources/base.js +7 -0
- package/dist/resources/base.js.map +1 -0
- package/dist/resources/byod.d.ts +15 -0
- package/dist/resources/byod.d.ts.map +1 -0
- package/dist/resources/byod.js +13 -0
- package/dist/resources/byod.js.map +1 -0
- package/dist/resources/chats.d.ts +29 -0
- package/dist/resources/chats.d.ts.map +1 -0
- package/dist/resources/chats.js +28 -0
- package/dist/resources/chats.js.map +1 -0
- package/dist/resources/lines.d.ts +64 -27
- package/dist/resources/lines.d.ts.map +1 -1
- package/dist/resources/lines.js +77 -37
- package/dist/resources/lines.js.map +1 -1
- package/dist/resources/lookup.d.ts +15 -0
- package/dist/resources/lookup.d.ts.map +1 -0
- package/dist/resources/lookup.js +13 -0
- package/dist/resources/lookup.js.map +1 -0
- package/dist/resources/messages.d.ts +36 -67
- package/dist/resources/messages.d.ts.map +1 -1
- package/dist/resources/messages.js +37 -94
- package/dist/resources/messages.js.map +1 -1
- package/dist/resources/trial.d.ts +28 -0
- package/dist/resources/trial.d.ts.map +1 -0
- package/dist/resources/trial.js +31 -0
- package/dist/resources/trial.js.map +1 -0
- package/dist/resources/webhooks.d.ts +49 -39
- package/dist/resources/webhooks.d.ts.map +1 -1
- package/dist/resources/webhooks.js +52 -39
- package/dist/resources/webhooks.js.map +1 -1
- package/dist/retry.d.ts +14 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +47 -0
- package/dist/retry.js.map +1 -0
- package/dist/types.d.ts +30 -196
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -28
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +20 -0
- package/dist/version.js.map +1 -0
- package/dist/webhooks/parse.d.ts +15 -0
- package/dist/webhooks/parse.d.ts.map +1 -0
- package/dist/webhooks/parse.js +47 -0
- package/dist/webhooks/parse.js.map +1 -0
- package/dist/webhooks/types.d.ts +93 -0
- package/dist/webhooks/types.d.ts.map +1 -0
- package/dist/webhooks/types.js +20 -0
- package/dist/webhooks/types.js.map +1 -0
- package/dist/webhooks/verify.d.ts +41 -0
- package/dist/webhooks/verify.d.ts.map +1 -0
- package/dist/webhooks/verify.js +110 -0
- package/dist/webhooks/verify.js.map +1 -0
- package/package.json +45 -30
- package/dist/paginate.d.ts +0 -33
- package/dist/paginate.d.ts.map +0 -1
- package/dist/paginate.js +0 -40
- package/dist/paginate.js.map +0 -1
- package/dist/webhook-events.d.ts +0 -61
- package/dist/webhook-events.d.ts.map +0 -1
- package/dist/webhook-events.js +0 -44
- package/dist/webhook-events.js.map +0 -1
- package/dist/webhook-verify.d.ts +0 -27
- package/dist/webhook-verify.d.ts.map +0 -1
- package/dist/webhook-verify.js +0 -42
- package/dist/webhook-verify.js.map +0 -1
package/dist/webhook-verify.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verify an incoming webhook signature.
|
|
3
|
-
*
|
|
4
|
-
* Checks that the HMAC-SHA256 signature matches and the timestamp is within
|
|
5
|
-
* the 5-minute replay window.
|
|
6
|
-
*
|
|
7
|
-
* @param secret - The webhook secret (from {@link Webhook.secret})
|
|
8
|
-
* @param signature - The `x-isnap-signature` header value
|
|
9
|
-
* @param timestamp - The `x-isnap-timestamp` header value (Unix seconds)
|
|
10
|
-
* @param payload - The raw request body string
|
|
11
|
-
* @returns `true` if the signature is valid and the timestamp is fresh
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { verifyWebhookSignature } from '@isnap/sdk';
|
|
16
|
-
*
|
|
17
|
-
* const valid = verifyWebhookSignature(
|
|
18
|
-
* webhookSecret,
|
|
19
|
-
* req.headers['x-isnap-signature'],
|
|
20
|
-
* req.headers['x-isnap-timestamp'],
|
|
21
|
-
* req.body,
|
|
22
|
-
* );
|
|
23
|
-
* if (!valid) return res.status(401).send('Invalid signature');
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare function verifyWebhookSignature(secret: string, signature: string, timestamp: string, payload: string): boolean;
|
|
27
|
-
//# sourceMappingURL=webhook-verify.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-verify.d.ts","sourceRoot":"","sources":["../src/webhook-verify.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAcT"}
|
package/dist/webhook-verify.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
2
|
-
/**
|
|
3
|
-
* Verify an incoming webhook signature.
|
|
4
|
-
*
|
|
5
|
-
* Checks that the HMAC-SHA256 signature matches and the timestamp is within
|
|
6
|
-
* the 5-minute replay window.
|
|
7
|
-
*
|
|
8
|
-
* @param secret - The webhook secret (from {@link Webhook.secret})
|
|
9
|
-
* @param signature - The `x-isnap-signature` header value
|
|
10
|
-
* @param timestamp - The `x-isnap-timestamp` header value (Unix seconds)
|
|
11
|
-
* @param payload - The raw request body string
|
|
12
|
-
* @returns `true` if the signature is valid and the timestamp is fresh
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { verifyWebhookSignature } from '@isnap/sdk';
|
|
17
|
-
*
|
|
18
|
-
* const valid = verifyWebhookSignature(
|
|
19
|
-
* webhookSecret,
|
|
20
|
-
* req.headers['x-isnap-signature'],
|
|
21
|
-
* req.headers['x-isnap-timestamp'],
|
|
22
|
-
* req.body,
|
|
23
|
-
* );
|
|
24
|
-
* if (!valid) return res.status(401).send('Invalid signature');
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export function verifyWebhookSignature(secret, signature, timestamp, payload) {
|
|
28
|
-
// Reject if timestamp is too old (5 minutes)
|
|
29
|
-
const ts = parseInt(timestamp, 10);
|
|
30
|
-
const age = Math.abs(Date.now() / 1000 - ts);
|
|
31
|
-
if (age > 300)
|
|
32
|
-
return false;
|
|
33
|
-
const data = `${ts}.${payload}`;
|
|
34
|
-
const expected = createHmac('sha256', secret).update(data).digest('hex');
|
|
35
|
-
try {
|
|
36
|
-
return timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=webhook-verify.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-verify.js","sourceRoot":"","sources":["../src/webhook-verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAc,EACd,SAAiB,EACjB,SAAiB,EACjB,OAAe;IAEf,6CAA6C;IAC7C,MAAM,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC;IAC7C,IAAI,GAAG,GAAG,GAAG;QAAE,OAAO,KAAK,CAAC;IAE5B,MAAM,IAAI,GAAG,GAAG,EAAE,IAAI,OAAO,EAAE,CAAC;IAChC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEzE,IAAI,CAAC;QACH,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|