@linqapp/sdk 0.24.2 → 0.26.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/CHANGELOG.md +2 -506
- package/client.d.mts +165 -87
- package/client.d.mts.map +1 -1
- package/client.d.ts +165 -87
- package/client.d.ts.map +1 -1
- package/client.js +162 -84
- package/client.js.map +1 -1
- package/client.mjs +162 -84
- package/client.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/chats/chats.d.mts +67 -63
- package/resources/chats/chats.d.mts.map +1 -1
- package/resources/chats/chats.d.ts +67 -63
- package/resources/chats/chats.d.ts.map +1 -1
- package/resources/chats/chats.js +63 -59
- package/resources/chats/chats.js.map +1 -1
- package/resources/chats/chats.mjs +63 -59
- package/resources/chats/chats.mjs.map +1 -1
- package/resources/chats/index.d.mts +3 -2
- package/resources/chats/index.d.mts.map +1 -1
- package/resources/chats/index.d.ts +3 -2
- package/resources/chats/index.d.ts.map +1 -1
- package/resources/chats/index.js +3 -1
- package/resources/chats/index.js.map +1 -1
- package/resources/chats/index.mjs +1 -0
- package/resources/chats/index.mjs.map +1 -1
- package/resources/chats/location.d.mts +107 -0
- package/resources/chats/location.d.mts.map +1 -0
- package/resources/chats/location.d.ts +107 -0
- package/resources/chats/location.d.ts.map +1 -0
- package/resources/chats/location.js +68 -0
- package/resources/chats/location.js.map +1 -0
- package/resources/chats/location.mjs +64 -0
- package/resources/chats/location.mjs.map +1 -0
- package/resources/chats/messages.d.mts +17 -17
- package/resources/chats/messages.d.mts.map +1 -1
- package/resources/chats/messages.d.ts +17 -17
- package/resources/chats/messages.d.ts.map +1 -1
- package/resources/chats/messages.js +16 -16
- package/resources/chats/messages.js.map +1 -1
- package/resources/chats/messages.mjs +16 -16
- package/resources/chats/messages.mjs.map +1 -1
- package/resources/contact-card.d.mts +18 -18
- package/resources/contact-card.d.mts.map +1 -1
- package/resources/contact-card.d.ts +18 -18
- package/resources/contact-card.d.ts.map +1 -1
- package/resources/contact-card.js +12 -12
- package/resources/contact-card.js.map +1 -1
- package/resources/contact-card.mjs +12 -12
- package/resources/contact-card.mjs.map +1 -1
- package/resources/index.d.mts +3 -3
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +3 -3
- package/resources/index.d.ts.map +1 -1
- package/resources/messages.d.mts +34 -34
- package/resources/messages.d.mts.map +1 -1
- package/resources/messages.d.ts +34 -34
- package/resources/messages.d.ts.map +1 -1
- package/resources/messages.js +29 -29
- package/resources/messages.js.map +1 -1
- package/resources/messages.mjs +29 -29
- package/resources/messages.mjs.map +1 -1
- package/resources/webhook-events.d.mts +83 -44
- package/resources/webhook-events.d.mts.map +1 -1
- package/resources/webhook-events.d.ts +83 -44
- package/resources/webhook-events.d.ts.map +1 -1
- package/resources/webhook-events.js +81 -42
- package/resources/webhook-events.js.map +1 -1
- package/resources/webhook-events.mjs +81 -42
- package/resources/webhook-events.mjs.map +1 -1
- package/resources/webhook-subscriptions.d.mts +100 -55
- package/resources/webhook-subscriptions.d.mts.map +1 -1
- package/resources/webhook-subscriptions.d.ts +100 -55
- package/resources/webhook-subscriptions.d.ts.map +1 -1
- package/resources/webhook-subscriptions.js +103 -58
- package/resources/webhook-subscriptions.js.map +1 -1
- package/resources/webhook-subscriptions.mjs +103 -58
- package/resources/webhook-subscriptions.mjs.map +1 -1
- package/resources/webhooks.d.mts +4 -4
- package/resources/webhooks.d.mts.map +1 -1
- package/resources/webhooks.d.ts +4 -4
- package/resources/webhooks.d.ts.map +1 -1
- package/src/client.ts +166 -88
- package/src/resources/chats/chats.ts +88 -78
- package/src/resources/chats/index.ts +3 -2
- package/src/resources/chats/location.ts +138 -0
- package/src/resources/chats/messages.ts +28 -28
- package/src/resources/contact-card.ts +25 -25
- package/src/resources/index.ts +4 -4
- package/src/resources/messages.ts +46 -46
- package/src/resources/webhook-events.ts +85 -44
- package/src/resources/webhook-subscriptions.ts +103 -58
- package/src/resources/webhooks.ts +6 -4
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -20,55 +20,82 @@ import { path } from '../internal/utils/path';
|
|
|
20
20
|
*
|
|
21
21
|
* ## Webhook Headers
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* All webhook requests include two sets of headers. **If you have an existing integration
|
|
24
|
+
* using the `X-Webhook-*` headers, nothing changes** — those headers are still sent on
|
|
25
|
+
* every delivery and work exactly as before. The new `webhook-*` headers follow the
|
|
26
|
+
* [Standard Webhooks](https://github.com/standard-webhooks/standard-webhooks) specification.
|
|
27
|
+
* You can safely ignore them if your current verification code works and you don't want to use this convention.
|
|
28
|
+
*
|
|
29
|
+
* ### Standard Webhooks Headers (Recommended)
|
|
30
|
+
*
|
|
31
|
+
* Used by [our SDK](https://github.com/linq-team/linq-node) and any [Standard Webhooks library](https://github.com/standard-webhooks/standard-webhooks).
|
|
24
32
|
*
|
|
25
33
|
* | Header | Description |
|
|
26
34
|
* |--------|-------------|
|
|
27
|
-
* | `
|
|
28
|
-
* | `
|
|
29
|
-
* | `
|
|
30
|
-
* | `X-Webhook-Signature` | HMAC-SHA256 signature for verification |
|
|
35
|
+
* | `webhook-id` | Unique event identifier (use as idempotency key) |
|
|
36
|
+
* | `webhook-timestamp` | Unix timestamp (seconds) when the webhook was sent |
|
|
37
|
+
* | `webhook-signature` | Standard Webhooks signature (`v1,{base64}` format) |
|
|
31
38
|
*
|
|
32
|
-
*
|
|
39
|
+
* ### Legacy Headers (Deprecated)
|
|
33
40
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
41
|
+
* Still sent on every delivery for backwards compatibility. Existing verification code
|
|
42
|
+
* using these headers continues to work — no changes required.
|
|
36
43
|
*
|
|
37
|
-
*
|
|
44
|
+
* | Header | Description |
|
|
45
|
+
* |--------|-------------|
|
|
46
|
+
* | `X-Webhook-Event` | *(deprecated)* Event type (e.g., `message.sent`) |
|
|
47
|
+
* | `X-Webhook-Subscription-ID` | *(deprecated)* Webhook subscription ID |
|
|
48
|
+
* | `X-Webhook-Timestamp` | *(deprecated)* Unix timestamp (seconds) |
|
|
49
|
+
* | `X-Webhook-Signature` | *(deprecated)* HMAC-SHA256 signature (hex-encoded) |
|
|
38
50
|
*
|
|
39
|
-
*
|
|
51
|
+
* ## Signing Secrets
|
|
40
52
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
53
|
+
* Signing secrets use the Standard Webhooks format: a `whsec_` prefix followed
|
|
54
|
+
* by base64-encoded random bytes (e.g., `whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw7Jxx2Oll+OE=`).
|
|
55
|
+
*
|
|
56
|
+
* Strip the `whsec_` prefix and base64-decode the remainder to get the raw key bytes.
|
|
57
|
+
*
|
|
58
|
+
* ## Verifying Webhook Signatures
|
|
59
|
+
*
|
|
60
|
+
* Webhooks are signed following the [Standard Webhooks specification](https://github.com/standard-webhooks/standard-webhooks).
|
|
61
|
+
* You can use any [Standard Webhooks library](https://github.com/standard-webhooks/standard-webhooks) to verify
|
|
62
|
+
* signatures, or implement verification manually:
|
|
44
63
|
*
|
|
45
|
-
*
|
|
46
|
-
* - `timestamp` is the value from the `X-Webhook-Timestamp` header
|
|
47
|
-
* - `payload` is the raw JSON request body (exact bytes, not re-serialized)
|
|
64
|
+
* **Signed content:** `{webhook-id}.{webhook-timestamp}.{body}`
|
|
48
65
|
*
|
|
49
66
|
* **Verification Steps:**
|
|
50
67
|
*
|
|
51
|
-
* 1. Extract the `
|
|
52
|
-
* 2.
|
|
53
|
-
* 3.
|
|
54
|
-
* 4.
|
|
55
|
-
* 5.
|
|
56
|
-
* 6.
|
|
68
|
+
* 1. Extract the `webhook-id`, `webhook-timestamp`, and `webhook-signature` headers
|
|
69
|
+
* 2. Reject if the timestamp is more than 5 minutes old (replay protection)
|
|
70
|
+
* 3. Get the raw request body bytes (do not parse and re-serialize)
|
|
71
|
+
* 4. Construct signed content: `"{webhook-id}.{webhook-timestamp}.{body}"`
|
|
72
|
+
* 5. Strip the `whsec_` prefix from your secret and base64-decode to get key bytes
|
|
73
|
+
* 6. Compute HMAC-SHA256 using the key bytes over the signed content
|
|
74
|
+
* 7. Base64-encode the result and compare with the value after `v1,` in `webhook-signature`
|
|
75
|
+
* 8. Use constant-time comparison to prevent timing attacks
|
|
57
76
|
*
|
|
58
77
|
* **Example (Python):**
|
|
59
78
|
*
|
|
60
79
|
* ```python
|
|
61
|
-
* import hmac
|
|
62
|
-
* import hashlib
|
|
80
|
+
* import base64, hmac, hashlib
|
|
63
81
|
*
|
|
64
|
-
* def verify_webhook(
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
82
|
+
* def verify_webhook(secret, body, headers):
|
|
83
|
+
* msg_id = headers['webhook-id']
|
|
84
|
+
* timestamp = headers['webhook-timestamp']
|
|
85
|
+
* signature = headers['webhook-signature']
|
|
86
|
+
*
|
|
87
|
+
* secret_str = secret.removeprefix('whsec_')
|
|
88
|
+
* key = base64.b64decode(secret_str)
|
|
89
|
+
*
|
|
90
|
+
* signed_content = f"{msg_id}.{timestamp}.{body}"
|
|
91
|
+
* expected = base64.b64encode(
|
|
92
|
+
* hmac.new(key, signed_content.encode(), hashlib.sha256).digest()
|
|
93
|
+
* ).decode()
|
|
94
|
+
*
|
|
95
|
+
* for sig in signature.split(' '):
|
|
96
|
+
* if sig.startswith('v1,') and hmac.compare_digest(expected, sig[3:]):
|
|
97
|
+
* return True
|
|
98
|
+
* return False
|
|
72
99
|
* ```
|
|
73
100
|
*
|
|
74
101
|
* **Example (Node.js):**
|
|
@@ -76,16 +103,28 @@ import { path } from '../internal/utils/path';
|
|
|
76
103
|
* ```javascript
|
|
77
104
|
* const crypto = require('crypto');
|
|
78
105
|
*
|
|
79
|
-
* function verifyWebhook(
|
|
80
|
-
* const
|
|
106
|
+
* function verifyWebhook(secret, rawBody, headers) {
|
|
107
|
+
* const msgId = headers['webhook-id'];
|
|
108
|
+
* const timestamp = headers['webhook-timestamp'];
|
|
109
|
+
* const signature = headers['webhook-signature'];
|
|
110
|
+
*
|
|
111
|
+
* const secretStr = secret.startsWith('whsec_') ? secret.slice(6) : secret;
|
|
112
|
+
* const keyBytes = Buffer.from(secretStr, 'base64');
|
|
113
|
+
* const signedContent = `${msgId}.${timestamp}.${rawBody}`;
|
|
81
114
|
* const expected = crypto
|
|
82
|
-
* .createHmac('sha256',
|
|
83
|
-
* .update(
|
|
84
|
-
* .digest('
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
115
|
+
* .createHmac('sha256', keyBytes)
|
|
116
|
+
* .update(signedContent)
|
|
117
|
+
* .digest('base64');
|
|
118
|
+
*
|
|
119
|
+
* return signature.split(' ').some(sig => {
|
|
120
|
+
* if (!sig.startsWith('v1,')) return false;
|
|
121
|
+
* try {
|
|
122
|
+
* return crypto.timingSafeEqual(
|
|
123
|
+
* Buffer.from(expected, 'base64'),
|
|
124
|
+
* Buffer.from(sig.slice(3), 'base64')
|
|
125
|
+
* );
|
|
126
|
+
* } catch { return false; }
|
|
127
|
+
* });
|
|
89
128
|
* }
|
|
90
129
|
* ```
|
|
91
130
|
*
|
|
@@ -115,9 +154,15 @@ export class WebhookSubscriptions extends APIResource {
|
|
|
115
154
|
* **Webhook Delivery:**
|
|
116
155
|
*
|
|
117
156
|
* - Events are sent via HTTP POST to the target URL
|
|
118
|
-
* - Each request includes
|
|
119
|
-
* -
|
|
120
|
-
*
|
|
157
|
+
* - Each request includes
|
|
158
|
+
* [Standard Webhooks](https://github.com/standard-webhooks/standard-webhooks)
|
|
159
|
+
* headers (`webhook-id`, `webhook-timestamp`, `webhook-signature`) for signature
|
|
160
|
+
* verification
|
|
161
|
+
* - Legacy `X-Webhook-*` headers are also sent for backwards compatibility
|
|
162
|
+
* (deprecated)
|
|
163
|
+
* - See
|
|
164
|
+
* [Verifying Webhook Signatures](https://docs.linqapp.com/guides/webhooks#verifying-webhook-signatures)
|
|
165
|
+
* for verification details
|
|
121
166
|
* - Failed deliveries (5xx, 429, network errors) are retried up to 10 times over
|
|
122
167
|
* ~25 minutes with exponential backoff
|
|
123
168
|
* - Client errors (4xx except 429) are not retried
|
|
@@ -142,6 +187,20 @@ export class WebhookSubscriptions extends APIResource {
|
|
|
142
187
|
return this._client.post('/v3/webhook-subscriptions', { body, ...options });
|
|
143
188
|
}
|
|
144
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Retrieve all webhook subscriptions for the authenticated partner. Returns a list
|
|
192
|
+
* of active and inactive subscriptions with their configuration and status.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* const webhookSubscriptions =
|
|
197
|
+
* await client.webhookSubscriptions.list();
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
list(options?: RequestOptions): APIPromise<WebhookSubscriptionListResponse> {
|
|
201
|
+
return this._client.get('/v3/webhook-subscriptions', options);
|
|
202
|
+
}
|
|
203
|
+
|
|
145
204
|
/**
|
|
146
205
|
* Retrieve details for a specific webhook subscription including its target URL,
|
|
147
206
|
* subscribed events, and current status.
|
|
@@ -184,20 +243,6 @@ export class WebhookSubscriptions extends APIResource {
|
|
|
184
243
|
return this._client.put(path`/v3/webhook-subscriptions/${subscriptionID}`, { body, ...options });
|
|
185
244
|
}
|
|
186
245
|
|
|
187
|
-
/**
|
|
188
|
-
* Retrieve all webhook subscriptions for the authenticated partner. Returns a list
|
|
189
|
-
* of active and inactive subscriptions with their configuration and status.
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```ts
|
|
193
|
-
* const webhookSubscriptions =
|
|
194
|
-
* await client.webhookSubscriptions.list();
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
|
-
list(options?: RequestOptions): APIPromise<WebhookSubscriptionListResponse> {
|
|
198
|
-
return this._client.get('/v3/webhook-subscriptions', options);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
246
|
/**
|
|
202
247
|
* Delete a webhook subscription.
|
|
203
248
|
*
|
|
@@ -794,7 +794,7 @@ export namespace MessageFailedWebhookEvent {
|
|
|
794
794
|
*/
|
|
795
795
|
export interface Data {
|
|
796
796
|
/**
|
|
797
|
-
* Error codes in webhook failure events (3007, 4001).
|
|
797
|
+
* Error codes in webhook failure events (3007, 4001, 4005).
|
|
798
798
|
*/
|
|
799
799
|
code: number;
|
|
800
800
|
|
|
@@ -1638,7 +1638,7 @@ export namespace ChatGroupNameUpdateFailedWebhookEvent {
|
|
|
1638
1638
|
chat_id: string;
|
|
1639
1639
|
|
|
1640
1640
|
/**
|
|
1641
|
-
* Error codes in webhook failure events (3007, 4001).
|
|
1641
|
+
* Error codes in webhook failure events (3007, 4001, 4005).
|
|
1642
1642
|
*/
|
|
1643
1643
|
error_code: number;
|
|
1644
1644
|
|
|
@@ -1715,7 +1715,7 @@ export namespace ChatGroupIconUpdateFailedWebhookEvent {
|
|
|
1715
1715
|
chat_id: string;
|
|
1716
1716
|
|
|
1717
1717
|
/**
|
|
1718
|
-
* Error codes in webhook failure events (3007, 4001).
|
|
1718
|
+
* Error codes in webhook failure events (3007, 4001, 4005).
|
|
1719
1719
|
*/
|
|
1720
1720
|
error_code: number;
|
|
1721
1721
|
|
|
@@ -1904,7 +1904,9 @@ export interface PhoneNumberStatusUpdatedWebhookEvent {
|
|
|
1904
1904
|
| 'call.ended'
|
|
1905
1905
|
| 'call.failed'
|
|
1906
1906
|
| 'call.declined'
|
|
1907
|
-
| 'call.no_answer'
|
|
1907
|
+
| 'call.no_answer'
|
|
1908
|
+
| 'location.sharing.started'
|
|
1909
|
+
| 'location.sharing.stopped';
|
|
1908
1910
|
|
|
1909
1911
|
/**
|
|
1910
1912
|
* Partner identifier. Present on all webhooks for cross-referencing.
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.26.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.26.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.26.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.26.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|