vessels-sdk 0.3.0 → 0.4.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/README.md +5 -5
- package/dist/index.cjs +20 -11
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# vessels-sdk
|
|
2
2
|
|
|
3
|
-
Node.js SDK for [Vessels](https://vessels
|
|
3
|
+
Node.js SDK for [Vessels](https://vessels.app) — let your agent reach you.
|
|
4
4
|
|
|
5
5
|
Vessels is the communication layer between AI agents and their human operators. Your agent pushes structured messages to a vessel; the human responds via the web or mobile app; your agent receives the answer via polling or webhooks.
|
|
6
6
|
|
|
@@ -38,7 +38,7 @@ const { messageId, vesselId } = await vessels.push({
|
|
|
38
38
|
});
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
Get your API key from Settings → API Keys in the [Vessels app](https://vessels
|
|
41
|
+
Get your API key from Settings → API Keys in the [Vessels app](https://vessels.app), or via the CLI:
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
44
|
npm install -g vessels
|
|
@@ -55,7 +55,7 @@ vessels keys create
|
|
|
55
55
|
| Option | Type | Default | Description |
|
|
56
56
|
|--------|------|---------|-------------|
|
|
57
57
|
| `apiKey` | `string` | required | Your `vsl_` prefixed API key |
|
|
58
|
-
| `baseUrl` | `string` | `https://vessels
|
|
58
|
+
| `baseUrl` | `string` | `https://vessels.app` | Override for local dev or self-hosted |
|
|
59
59
|
|
|
60
60
|
---
|
|
61
61
|
|
|
@@ -469,7 +469,7 @@ import type {
|
|
|
469
469
|
|
|
470
470
|
## Links
|
|
471
471
|
|
|
472
|
-
- Dashboard: [https://vessels
|
|
473
|
-
- Full integration reference: [https://vessels
|
|
472
|
+
- Dashboard: [https://vessels.app](https://vessels.app)
|
|
473
|
+
- Full integration reference: [https://vessels.app/docs](https://vessels.app/docs)
|
|
474
474
|
- CLI: `npm install -g vessels`
|
|
475
475
|
- npm: [https://www.npmjs.com/package/vessels-sdk](https://www.npmjs.com/package/vessels-sdk)
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var crypto = require('crypto');
|
|
4
|
-
|
|
5
3
|
// src/index.ts
|
|
6
4
|
var AgentActivityTypes = {
|
|
7
5
|
thinking: "thinking",
|
|
@@ -38,7 +36,7 @@ var Vessels = class {
|
|
|
38
36
|
_debug;
|
|
39
37
|
constructor(config) {
|
|
40
38
|
this.apiKey = config.apiKey;
|
|
41
|
-
this.baseUrl = config.baseUrl?.replace(/\/$/, "") ?? "https://vessels
|
|
39
|
+
this.baseUrl = config.baseUrl?.replace(/\/$/, "") ?? "https://vessels.app";
|
|
42
40
|
this._debug = config.debug ?? false;
|
|
43
41
|
}
|
|
44
42
|
async _fetch(url, init) {
|
|
@@ -189,16 +187,27 @@ var Vessels = class {
|
|
|
189
187
|
// body: raw request body string (before JSON.parse)
|
|
190
188
|
// signature: X-Vessels-Signature header value
|
|
191
189
|
// webhookSecret: the secret shown when you created the webhook endpoint in Settings
|
|
192
|
-
verifyWebhook(body, signature, webhookSecret) {
|
|
190
|
+
async verifyWebhook(body, signature, webhookSecret) {
|
|
193
191
|
if (!signature.startsWith("sha256=")) return false;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
192
|
+
try {
|
|
193
|
+
const enc = new TextEncoder();
|
|
194
|
+
const hexSig = signature.slice(7);
|
|
195
|
+
if (hexSig.length % 2 !== 0) return false;
|
|
196
|
+
const sigBytes = new Uint8Array(hexSig.length / 2);
|
|
197
|
+
for (let i = 0; i < sigBytes.length; i++) {
|
|
198
|
+
sigBytes[i] = parseInt(hexSig.slice(i * 2, i * 2 + 2), 16);
|
|
199
|
+
}
|
|
200
|
+
const key = await globalThis.crypto.subtle.importKey(
|
|
201
|
+
"raw",
|
|
202
|
+
enc.encode(webhookSecret),
|
|
203
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
204
|
+
false,
|
|
205
|
+
["verify"]
|
|
206
|
+
);
|
|
207
|
+
return await globalThis.crypto.subtle.verify("HMAC", key, sigBytes, enc.encode(body));
|
|
208
|
+
} catch {
|
|
209
|
+
return false;
|
|
200
210
|
}
|
|
201
|
-
return diff === 0;
|
|
202
211
|
}
|
|
203
212
|
};
|
|
204
213
|
|
package/dist/index.d.cts
CHANGED
|
@@ -137,7 +137,7 @@ declare class Vessels {
|
|
|
137
137
|
metadata?: Record<string, unknown>;
|
|
138
138
|
}): _vessels_types.ConfirmPreviewInteraction;
|
|
139
139
|
poll(options?: PollOptions): Promise<PollResponse>;
|
|
140
|
-
verifyWebhook(body: string, signature: string, webhookSecret: string): boolean
|
|
140
|
+
verifyWebhook(body: string, signature: string, webhookSecret: string): Promise<boolean>;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export { AgentActivityTypes, type InteractionResponseEvent, type PollEvent, type PollOptions, type PollResponse, type PushManyResult, type PushResponse, type UserMessageEvent, type VesselContext, Vessels, VesselsAuthError, type VesselsConfig, VesselsRateLimitError, VesselsValidationError };
|
package/dist/index.d.ts
CHANGED
|
@@ -137,7 +137,7 @@ declare class Vessels {
|
|
|
137
137
|
metadata?: Record<string, unknown>;
|
|
138
138
|
}): _vessels_types.ConfirmPreviewInteraction;
|
|
139
139
|
poll(options?: PollOptions): Promise<PollResponse>;
|
|
140
|
-
verifyWebhook(body: string, signature: string, webhookSecret: string): boolean
|
|
140
|
+
verifyWebhook(body: string, signature: string, webhookSecret: string): Promise<boolean>;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export { AgentActivityTypes, type InteractionResponseEvent, type PollEvent, type PollOptions, type PollResponse, type PushManyResult, type PushResponse, type UserMessageEvent, type VesselContext, Vessels, VesselsAuthError, type VesselsConfig, VesselsRateLimitError, VesselsValidationError };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { createHmac } from 'crypto';
|
|
2
|
-
|
|
3
1
|
// src/index.ts
|
|
4
2
|
var AgentActivityTypes = {
|
|
5
3
|
thinking: "thinking",
|
|
@@ -36,7 +34,7 @@ var Vessels = class {
|
|
|
36
34
|
_debug;
|
|
37
35
|
constructor(config) {
|
|
38
36
|
this.apiKey = config.apiKey;
|
|
39
|
-
this.baseUrl = config.baseUrl?.replace(/\/$/, "") ?? "https://vessels
|
|
37
|
+
this.baseUrl = config.baseUrl?.replace(/\/$/, "") ?? "https://vessels.app";
|
|
40
38
|
this._debug = config.debug ?? false;
|
|
41
39
|
}
|
|
42
40
|
async _fetch(url, init) {
|
|
@@ -187,16 +185,27 @@ var Vessels = class {
|
|
|
187
185
|
// body: raw request body string (before JSON.parse)
|
|
188
186
|
// signature: X-Vessels-Signature header value
|
|
189
187
|
// webhookSecret: the secret shown when you created the webhook endpoint in Settings
|
|
190
|
-
verifyWebhook(body, signature, webhookSecret) {
|
|
188
|
+
async verifyWebhook(body, signature, webhookSecret) {
|
|
191
189
|
if (!signature.startsWith("sha256=")) return false;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
190
|
+
try {
|
|
191
|
+
const enc = new TextEncoder();
|
|
192
|
+
const hexSig = signature.slice(7);
|
|
193
|
+
if (hexSig.length % 2 !== 0) return false;
|
|
194
|
+
const sigBytes = new Uint8Array(hexSig.length / 2);
|
|
195
|
+
for (let i = 0; i < sigBytes.length; i++) {
|
|
196
|
+
sigBytes[i] = parseInt(hexSig.slice(i * 2, i * 2 + 2), 16);
|
|
197
|
+
}
|
|
198
|
+
const key = await globalThis.crypto.subtle.importKey(
|
|
199
|
+
"raw",
|
|
200
|
+
enc.encode(webhookSecret),
|
|
201
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
202
|
+
false,
|
|
203
|
+
["verify"]
|
|
204
|
+
);
|
|
205
|
+
return await globalThis.crypto.subtle.verify("HMAC", key, sigBytes, enc.encode(body));
|
|
206
|
+
} catch {
|
|
207
|
+
return false;
|
|
198
208
|
}
|
|
199
|
-
return diff === 0;
|
|
200
209
|
}
|
|
201
210
|
};
|
|
202
211
|
|